var l=Object.defineProperty;var c=(a,n)=>l(a,"name",{value:n,configurable:!0});import{definePlugin as f}from"./definePlugin-CWm4Dv_t.js";var o;(function(a){a[a.UNSET=0]="UNSET",a[a.OK=1]="OK",a[a.ERROR=2]="ERROR"})(o||(o={}));var k=Object.defineProperty,u=c((a,n)=>k(a,"name",{value:n,configurable:!0}),"i");const p=u(a=>{const{renameSpan:n,tracer:d}=a;let r;const i=new Map;return f({hooks:{"run:after":u(e=>{if(!r)return;const t=[...e.values()].filter(s=>s.status==="failure").length;r.setAttribute("vis.run.tasks_total",e.size),r.setAttribute("vis.run.tasks_failed",t),t>0?r.setStatus({code:o.ERROR,message:`${String(t)} task(s) failed`}):r.setStatus({code:o.OK}),r.end(),r=void 0;for(const s of i.values())s.end();i.clear()},"run:after"),"run:before":u(e=>{r&&(r.setStatus({code:o.ERROR,message:"run:before fired while previous run was still active"}),r.end());for(const t of i.values())t.end();i.clear(),r=d.startSpan("vis.run",{attributes:{"vis.run.task_count":e.tasks.length,"vis.workspace_root":e.workspaceRoot}})},"run:before"),"task:after":u((e,t)=>{const s=i.get(e.id);s&&(s.setAttribute("vis.task.exit_code",t.code??0),s.setAttribute("vis.task.cache_status",t.status),s.end(),i.delete(e.id))},"task:after"),"task:before":u(e=>{const t=i.get(e.id);t&&(t.setStatus({code:o.ERROR,message:"retried — superseded by new attempt"}),t.end());const s=d.startSpan(n?n(e):e.id,{attributes:{"vis.task.id":e.id,"vis.task.project":e.target.project,"vis.task.target":e.target.target}});i.set(e.id,s)},"task:before"),"task:failure":u((e,t)=>{const s=i.get(e.id);s&&s.setStatus({code:o.ERROR,message:`Task failed with exit code ${String(t.code??-1)}`})},"task:failure")},name:"otel"})},"otelPlugin");export{p as otelPlugin};
