@datalayer/agent-runtimes 1.6.30 → 1.6.33
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist-embed/chunks/AgentInspector-C66D0b0W.js +1 -0
- package/dist-embed/chunks/{AgentInspectorDialog-DTQHUrHA.js → AgentInspectorDialog-DeK96QG1.js} +1 -1
- package/dist-embed/datalayer-app-main.js +8 -8
- package/lib/examples/pap/traces/account-tokens.json +6 -8
- package/lib/examples/pap/traces/conversation-control.json +16 -18
- package/lib/examples/pap/traces/conversation-streaming.json +10 -12
- package/lib/examples/pap/traces/mediated-sign-in.json +6 -8
- package/lib/examples/pap/traces/operations.json +38 -32
- package/lib/examples/pap/traces/two-companies.json +40 -37
- package/lib/examples/pap/traces/user-with-a-company.json +22 -22
- package/lib/portable/displays.d.ts +8 -1
- package/lib/portable/displays.js +46 -3
- package/package.json +2 -2
- package/dist-embed/chunks/AgentInspector-CPJcLyP9.js +0 -1
|
@@ -1 +0,0 @@
|
|
|
1
|
-
import{j as e,B as s,I as te,T as f,r as m,ds as ce,f2 as ue,bB as P,dr as H,L as W,f3 as fe,f4 as J,v as V,P as xe,f5 as he,V as pe,f6 as me,e6 as G,bs as M,f7 as ge,f8 as be,f9 as X,fa as je,fb as Se}from"../datalayer-app-main.js";import{B,U as L}from"./index-BbcMy3Al.js";const we={default:{bg:"canvas.default",borderColor:"border.default"},subtle:{bg:"canvas.subtle",borderColor:"border.default"},inset:{bg:"canvas.inset",borderColor:"border.default"},accent:{bg:"accent.subtle",borderColor:"accent.muted"},success:{bg:"success.subtle",borderColor:"success.muted"},attention:{bg:"attention.subtle",borderColor:"attention.muted"},danger:{bg:"danger.subtle",borderColor:"danger.muted"}},_e="card",ne={none:"none",small:"shadow.small",medium:"shadow.medium",large:"shadow.large",extraLarge:"shadow.extraLarge"},ye={cursor:"pointer",textAlign:"left",font:"inherit",transition:"border-color 160ms ease, box-shadow 160ms ease, background-color 160ms ease",hover:{borderColor:"accent.emphasis",boxShadow:ne.medium},focusVisible:{outline:"2px solid",outlineColor:"accent.emphasis",outlineOffset:"2px"},reducedMotion:{transition:"none"}},O="cubic-bezier(0.22, 1, 0.36, 1)",re="data-card-icon",K=`[${re}]`,ve=["&:hover","&:focus-visible","&:has(:focus-visible)"];function ke(t){const n={boxShadow:"shadow.large",transform:"translateY(-3px)",borderColor:t},r={transition:`box-shadow 260ms ${O}, transform 260ms ${O}, border-color 260ms ${O}`,"&::after":{content:'""',position:"absolute",top:0,left:0,right:0,height:"2px",background:"linear-gradient(90deg, transparent, var(--fgColor-accent), transparent)",opacity:0,pointerEvents:"none",transition:`opacity 260ms ${O}`}},o={transition:`box-shadow 260ms ${O}, border-color 260ms ${O}`,[`& ${K}`]:{transition:"none"}};for(const a of ve)r[a]=n,r[`${a}::after`]={opacity:1},r[`${a} ${K}`]={transform:"scale(1.06) rotate(-3deg)"},o[a]={transform:"none"},o[`${a} ${K}`]={transform:"none"};return r["@media (prefers-reduced-motion: reduce)"]=o,r}const Ce={cursor:"not-allowed",opacity:.6,hover:{}},v=t=>{const{rounded:n,border:r,shadow:o="small",variant:a="default",interactive:i,selected:d,dashed:x,disabled:u,accent:h,hoverEffect:c,sx:g,children:j,...S}=t,p=c==="lift"&&!u,A=r||i||d||x||p,l=we[a],w=p?ke(i?"accent.emphasis":"border.muted"):void 0,b=w?{...w,...g}:g;return e.jsx(s,{display:"flex",flexDirection:"column",bg:d?"accent.subtle":l.bg,color:"fg.default",borderRadius:n??_e,boxShadow:ne[o],...A?{border:"1px solid",borderColor:d?"accent.emphasis":l.borderColor}:void 0,...x?{borderStyle:"dashed"}:void 0,...h?{borderTop:"3px solid",borderTopColor:h}:void 0,...i?ye:void 0,...u?Ce:void 0,...i&&u?{"aria-disabled":!0}:void 0,...p?{position:"relative",overflow:"hidden"}:void 0,...S,sx:b,children:j})};v.Header=t=>{const{title:n,description:r,leadingVisual:o,action:a}=t;return e.jsxs(s,{display:"flex",alignItems:"center",p:3,children:[o&&e.jsx(s,{mr:3,children:e.jsx(te,{size:"medium",icon:o,"aria-label":""})}),e.jsxs(s,{flexGrow:1,children:[e.jsx(f,{as:"div",display:"block",children:n}),e.jsx(f,{display:"block",color:"fg.muted",children:r})]}),a&&e.jsx(s,{children:a})]})};v.Image=({url:t,image:n,svg:r,height:o})=>e.jsxs(s,{display:"block",width:"100%",height:`${o}px`,backgroundImage:t?`url(${t})`:void 0,backgroundSize:"cover",backgroundRepeat:"no-repeat",backgroundPosition:"center",objectFit:"cover",children:[n&&e.jsx("img",{src:n,style:{maxHeight:`${o}px`}}),r&&e.jsx("img",{src:`data:image/svg+xml;utf8,${r}`,style:{maxHeight:o}})]});v.Cover=({height:t=110,image:n,gradient:r,color:o="neutral.emphasis",accessory:a,children:i,...d})=>e.jsxs(s,{position:"relative",width:"100%",height:`${t}px`,flexShrink:0,display:"flex",alignItems:"center",justifyContent:"center",bg:o,backgroundImage:n?`url(${n})`:r?`linear-gradient(135deg, ${r.from} 0%, ${r.to} 100%)`:void 0,backgroundSize:"cover",backgroundPosition:"center",color:"fg.onEmphasis",fontSize:4,fontWeight:"semibold",...d,children:[i,a&&e.jsx(s,{position:"absolute",top:2,right:2,display:"flex",alignItems:"center",gap:1,children:a})]});v.Content=({children:t,...n})=>e.jsx(s,{display:"block",p:3,...n,children:t});v.Footer=({children:t,...n})=>e.jsx(s,{display:"flex",alignItems:"center",gap:2,flexWrap:"wrap",mt:"auto",px:3,py:2,borderTop:"1px solid",borderColor:"border.muted",...n,children:t});v.Icon=({icon:t,color:n="accent.fg",bg:r="accent.subtle",size:o=46,...a})=>e.jsx(s,{[re]:"",display:"inline-flex",alignItems:"center",justifyContent:"center",flexShrink:0,width:o,height:o,borderRadius:`${Math.round(o*13/46)}px`,color:n,bg:r,mb:3,boxShadow:"inset 0 0 0 1px currentColor",transition:`transform 320ms ${O}`,...a,children:e.jsx(t,{size:Math.round(o*22/46),fill:"currentColor"})});v.Actions=({children:t})=>e.jsx(s,{display:"block",p:3,mt:"auto",children:t});function D(t){const n=Number(t);return!isNaN(n)&&n>1e15?n/1e6:!isNaN(n)&&n>1e12?n/1e3:isNaN(n)?new Date(String(t)).getTime():n}function Y(t){return t==null?"—":t<.001?"<1µs":t<1?`${(t*1e3).toFixed(0)}µs`:t<1e3?`${t.toFixed(1)}ms`:t<6e4?`${(t/1e3).toFixed(2)}s`:`${(t/6e4).toFixed(1)}m`}function Ie(t){if(t==null||t==="")return"—";try{const n=D(t),r=new Date(n);return isNaN(r.getTime())?String(t):r.toLocaleTimeString(void 0,{hour:"2-digit",minute:"2-digit",second:"2-digit",fractionalSecondDigits:3})}catch{return String(t)}}const Q=["#0969da","#1a7f37","#cf222e","#8250df","#bf8700","#0550ae","#116329","#a40e26","#6639ba","#953800","#0e8a16","#e36209"];function Te(t){let n=0;for(let r=0;r<t.length;r++)n=n*31+t.charCodeAt(r)|0;return Q[Math.abs(n)%Q.length]}function oe(t){const n=new Map,r=t.map(i=>({...i,children:[],depth:0}));for(const i of r)n.set(i.span_id,i);const o=[];for(const i of r)if(i.parent_span_id&&n.has(i.parent_span_id)){const d=n.get(i.parent_span_id);d.children=d.children??[],d.children.push(i)}else o.push(i);function a(i,d){i.depth=d;for(const x of i.children??[])a(x,d+1)}for(const i of o)a(i,0);return o}const Ae="peer.service";function ze(t,n){return t.service_name===n||t.attributes?.[Ae]===n}function $e(t,n){return n?t.filter(r=>ze(r,n)):[...t]}const Z=[],Oe=()=>()=>{};function Ee(t){return m.useSyncExternalStore(t?t.subscribe:Oe,()=>t?t.spans():Z,()=>t?t.spans():Z)}const Re="140px 1fr 160px 90px",Ne="96px minmax(0, 1fr) 96px 64px";function De(t){const n=t.attributes;if(!n)return null;const r=n["gen_ai.usage.input_tokens"]!=null?Number(n["gen_ai.usage.input_tokens"]):void 0,o=n["gen_ai.usage.output_tokens"]!=null?Number(n["gen_ai.usage.output_tokens"]):void 0;return r==null&&o==null?null:{input:r,output:o}}const Me=({spans:t,loading:n,selectedSpanId:r,onSelectSpan:o,emptyText:a,compact:i=!1,defaultExpanded:d=!1,renderSpanMark:x,describeSpan:u})=>{const[h,c]=m.useState(new Set),g=m.useMemo(()=>({has:l=>d?!h.has(l):h.has(l)}),[h,d]),j=i?Ne:Re,S=m.useMemo(()=>oe(t),[t]),p=m.useMemo(()=>{const l=[];function w(b,E){const k=b.children??[];if(l.push({span:b,depth:E,hasChildren:k.length>0}),g.has(b.span_id))for(const $ of k)w($,E+1)}for(const b of S)w(b,0);return l},[S,g]),A=m.useCallback(l=>{c(w=>{const b=new Set(w);return b.has(l)?b.delete(l):b.add(l),b})},[]);return n?e.jsx(s,{display:"flex",justifyContent:"center",p:5,children:e.jsx(ce,{size:"medium"})}):t.length===0?e.jsxs(B,{children:[e.jsx(B.Visual,{children:e.jsx(ue,{size:24})}),e.jsx(B.Heading,{children:"No traces found"}),e.jsx(B.Description,{children:a??"Send some telemetry data first."})]}):e.jsxs(s,{width:"100%",flex:1,minHeight:0,overflow:"auto",children:[e.jsx(s,{display:"grid",gridTemplateColumns:j,gap:2,px:3,position:"sticky",top:0,bg:"canvas.subtle",zIndex:1,borderBottom:"2px solid",borderColor:"border.default",children:["Time","Message","Scope","Duration"].map(l=>e.jsx(f,{sx:{fontWeight:"bold",fontSize:0,color:"fg.muted",textTransform:"uppercase",letterSpacing:"0.05em",py:2,...l==="Duration"?{textAlign:"right"}:{}},children:l},l))}),p.map(({span:l,depth:w,hasChildren:b},E)=>{const k=r===l.span_id,$=g.has(l.span_id),I=w*(i?12:20),C=u?.(l);return e.jsxs(s,{"data-otel-span":l.span_id,"data-otel-span-name":l.span_name,onClick:()=>{b&&A(l.span_id),o?.(l)},display:"grid",gridTemplateColumns:j,gap:2,px:3,py:"5px",cursor:"pointer",bg:k?"accent.subtle":w>0?"canvas.inset":"canvas.default",borderBottom:"1px solid",borderColor:"border.muted",hover:{bg:k?"accent.subtle":"canvas.subtle"},children:[e.jsx(f,{sx:{fontSize:i?0:1,fontFamily:"mono",color:"fg.muted",whiteSpace:"nowrap",lineHeight:"22px"},children:Ie(l.start_time)}),e.jsxs(s,{display:"flex",alignItems:"center",gap:1,overflow:"hidden",lineHeight:"22px",pl:`${I}px`,children:[b?e.jsx(s,{flexShrink:0,color:"fg.muted",display:"flex",alignItems:"center",children:$?e.jsx(P,{size:14}):e.jsx(H,{size:14})}):w>0?e.jsx(s,{flexShrink:0,width:"14px",display:"flex",alignItems:"center",justifyContent:"center",color:"fg.subtle",fontSize:0,children:"─"}):null,x?.(l),e.jsx(f,{sx:{fontSize:1,overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",flexShrink:C?0:1,maxWidth:C?"60%":void 0},title:l.span_name,children:l.span_name}),l.in_progress&&e.jsx(W,{variant:"attention",size:"small",children:"running"}),l.status_code==="ERROR"&&e.jsx(W,{variant:"danger",size:"small",children:"ERROR"}),(()=>{const z=De(l);return z?e.jsxs(v,{border:!0,shadow:"none",display:"inline-flex",alignItems:"center",gap:"2px",px:1,fontSize:"10px",fontFamily:"mono",color:"fg.muted",flexShrink:0,lineHeight:"16px",children:[z.input!=null&&e.jsxs(s,{display:"inline-flex",alignItems:"center",gap:"1px",children:[e.jsx(f,{sx:{fontSize:"9px",color:"fg.subtle"},children:"↗"}),e.jsx(f,{children:z.input})]}),z.output!=null&&e.jsxs(s,{display:"inline-flex",alignItems:"center",gap:"1px",children:[e.jsx(f,{sx:{fontSize:"9px",color:"fg.subtle"},children:"↙"}),e.jsx(f,{children:z.output})]})]}):null})(),C&&e.jsx(f,{sx:{fontSize:1,color:"fg.muted",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",minWidth:0},title:C,"data-otel-span-description":"",children:C}),l.otel_scope_name&&!i&&e.jsx(W,{size:"small",variant:"secondary",sx:{flexShrink:0,fontSize:"10px"},children:l.otel_scope_name})]}),e.jsx(f,{sx:{fontSize:1,color:"fg.muted",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",lineHeight:"22px"},title:`${l.service_name} / ${l.otel_scope_name??""}`,children:l.service_name}),e.jsx(f,{sx:{fontSize:1,fontFamily:"mono",textAlign:"right",lineHeight:"22px",color:l.duration_ms!=null&&l.duration_ms>1e3?"danger.fg":"fg.default"},children:l.in_progress?"…":Y(l.duration_ms)})]},`${l.trace_id}-${l.span_id}-${E}`)})]})},Be=20,se=({span:t,depth:n,selectedSpanId:r,onSelectSpan:o,expandedIds:a,toggleExpanded:i,traceMinTime:d,traceDuration:x})=>{const u=(t.children?.length??0)>0,h=a.has(t.span_id),c=r===t.span_id,g=Te(t.service_name),j=(D(t.start_time)-d)/x*100,S=Math.max((t.duration_ms||0)/x*100,.5);return e.jsxs(e.Fragment,{children:[e.jsxs(s,{display:"flex",alignItems:"center",height:28,pl:`${n*Be}px`,pr:2,cursor:"pointer",bg:c?"accent.subtle":"canvas.default",borderBottom:"1px solid",borderColor:"border.muted",hover:{bg:c?"accent.subtle":"canvas.subtle"},onClick:()=>o?.(t),children:[e.jsx(s,{width:20,textAlign:"center",color:"fg.muted",userSelect:"none",flexShrink:0,cursor:u?"pointer":"default",onClick:p=>{p.stopPropagation(),u&&i(t.span_id)},children:u?h?e.jsx(P,{size:12}):e.jsx(H,{size:12}):e.jsx(f,{sx:{color:"fg.subtle",fontSize:0},children:"·"})}),e.jsx(s,{width:8,height:8,borderRadius:"50%",bg:g,flexShrink:0,mr:1}),e.jsx(f,{sx:{flex:"0 0 200px",overflow:"hidden",textOverflow:"ellipsis",whiteSpace:"nowrap",fontSize:1,fontWeight:c?"bold":"normal"},title:`${t.service_name} / ${t.span_name}`,children:t.span_name}),e.jsx(s,{flex:1,position:"relative",height:12,bg:"canvas.subtle",borderRadius:1,mx:2,overflow:"hidden",children:e.jsx(s,{position:"absolute",left:`${j}%`,width:`${S}%`,height:"100%",bg:g,borderRadius:1,opacity:c?1:.7})}),e.jsx(f,{sx:{minWidth:60,textAlign:"right",fontSize:0,fontFamily:"mono",color:"fg.muted",flexShrink:0},children:Y(t.duration_ms)})]}),u&&h&&t.children.map(p=>e.jsx(se,{span:p,depth:n+1,selectedSpanId:r,onSelectSpan:o,expandedIds:a,toggleExpanded:i,traceMinTime:d,traceDuration:x},p.span_id))]})},Le=({spans:t,selectedSpanId:n,onSelectSpan:r,defaultExpandDepth:o=2})=>{const a=m.useMemo(()=>{const c=new Set;function g(j,S){for(const p of j)S<o&&c.add(p.span_id),p.children&&g(p.children,S+1)}return g(t,0),c},[t,o]),[i,d]=m.useState(a),x=m.useCallback(c=>{d(g=>{const j=new Set(g);return j.has(c)?j.delete(c):j.add(c),j})},[]),{traceMinTime:u,traceDuration:h}=m.useMemo(()=>{let c=1/0,g=-1/0;function j(S){for(const p of S){const A=D(p.start_time),l=D(p.end_time);A<c&&(c=A),l>g&&(g=l),p.children&&j(p.children)}}return j(t),c===1/0?{traceMinTime:0,traceDuration:1}:{traceMinTime:c,traceDuration:g-c||1}},[t]);return t.length===0?e.jsx(s,{p:3,color:"fg.muted",textAlign:"center",children:e.jsx(f,{children:"No span tree to display."})}):e.jsxs(s,{width:"100%",overflow:"auto",children:[e.jsxs(s,{display:"flex",alignItems:"center",height:28,px:2,borderBottom:"2px solid",borderColor:"border.default",bg:"canvas.subtle",children:[e.jsx(s,{width:20}),e.jsx(s,{width:8,mr:1}),e.jsx(f,{sx:{flex:"0 0 200px",fontSize:0,fontWeight:"bold",color:"fg.muted",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Span"}),e.jsx(f,{sx:{flex:1,mx:2,fontSize:0,fontWeight:"bold",color:"fg.muted",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Timeline"}),e.jsx(f,{sx:{minWidth:60,textAlign:"right",fontSize:0,fontWeight:"bold",color:"fg.muted",textTransform:"uppercase",letterSpacing:"0.05em"},children:"Duration"})]}),t.map(c=>e.jsx(se,{span:c,depth:0,selectedSpanId:n,onSelectSpan:r,expandedIds:i,toggleExpanded:x,traceMinTime:u,traceDuration:h},c.span_id))]})},y=({label:t,value:n,mono:r=!1})=>n==null||n===""?null:e.jsxs(s,{display:"flex",py:1,borderBottom:"1px solid",borderColor:"border.muted",gap:2,children:[e.jsx(f,{sx:{width:140,minWidth:140,color:"fg.muted",fontSize:1,fontWeight:"bold"},children:t}),e.jsx(f,{sx:{fontSize:1,fontFamily:r?"mono":"normal",wordBreak:"break-all"},children:String(n)})]}),ee=({title:t,data:n,defaultOpen:r=!1})=>{const[o,a]=m.useState(r);return!n||Object.keys(n).length===0?null:e.jsxs(s,{mt:3,children:[e.jsxs(s,{display:"flex",alignItems:"center",gap:1,cursor:"pointer",py:1,userSelect:"none",onClick:()=>a(!o),children:[o?e.jsx(P,{size:16}):e.jsx(H,{size:16}),e.jsx(f,{sx:{fontSize:1,fontWeight:"bold"},children:t}),e.jsx(J,{children:Object.keys(n).length})]}),o&&e.jsx(v,{border:!0,shadow:"none",variant:"subtle",display:"block",p:2,mt:1,overflowX:"auto",children:Object.entries(n).map(([i,d])=>e.jsx(F,{attrKey:i,value:d,depth:0},i))})]})};function We(t){if(typeof t!="string")return t;const n=t.trim();if(!/^[[{]/.test(n))return t;try{const r=JSON.parse(n);return typeof r=="object"&&r!==null?r:t}catch{return t}}const F=({attrKey:t,value:n,depth:r})=>{const o=m.useMemo(()=>We(n),[n]),[a,i]=m.useState(r<1),d=typeof o=="object"&&o!==null&&!Array.isArray(o),x=Array.isArray(o),u=d||x;return e.jsxs(s,{borderBottom:r===0?"1px solid":"none",borderColor:"border.muted",pb:r===0?1:0,mb:r===0?1:0,children:[e.jsxs(s,{display:"flex",gap:2,py:1,pl:r*16+"px",alignItems:"flex-start",children:[u?e.jsx(s,{cursor:"pointer",color:"fg.muted",userSelect:"none",width:16,flexShrink:0,onClick:()=>i(!a),children:a?e.jsx(P,{size:12}):e.jsx(H,{size:12})}):e.jsx(s,{width:16,flexShrink:0}),e.jsx(f,{sx:{color:"accent.fg",fontSize:1,fontFamily:"mono",minWidth:180,wordBreak:"break-all",flexShrink:0},children:t}),!u&&e.jsx(f,{sx:{fontSize:1,fontFamily:"mono",whiteSpace:"pre-wrap",wordBreak:"break-word",color:typeof o=="string"?"accent.emphasis":"attention.fg"},children:typeof o=="string"?o:JSON.stringify(o)}),u&&!a&&e.jsx(f,{sx:{fontSize:0,color:"fg.muted",fontFamily:"mono"},children:x?`[${o.length} items]`:`{${Object.keys(o).length} keys}`})]}),u&&a&&e.jsx(s,{children:x?o.map((h,c)=>e.jsx(F,{attrKey:`[${c}]`,value:h,depth:r+1},c)):Object.entries(o).map(([h,c])=>e.jsx(F,{attrKey:h,value:c,depth:r+1},h))})]})},Fe=({span:t,traceSpans:n,onClose:r})=>{const[o,a]=m.useState("details");if(!t)return e.jsx(s,{p:5,color:"fg.muted",textAlign:"center",children:e.jsx(f,{children:"Select a span to view details."})});const i={},d={};if(t.attributes)for(const[u,h]of Object.entries(t.attributes))u.startsWith("gen_ai.")||u.startsWith("model_request")?i[u]=h:d[u]=h;const x=n&&n.length>0?oe(n):void 0;return e.jsxs(s,{height:"100%",overflow:"auto",borderLeft:"1px solid",borderColor:"border.default",bg:"canvas.default",display:"flex",flexDirection:"column",children:[e.jsxs(s,{px:3,py:2,borderBottom:"1px solid",borderColor:"border.default",display:"flex",justifyContent:"space-between",alignItems:"center",bg:"canvas.subtle",flexShrink:0,children:[e.jsx(f,{sx:{fontSize:2,fontWeight:"bold"},children:t.span_name}),r&&e.jsx(te,{icon:fe,"aria-label":"Close detail panel",variant:"invisible",size:"small",onClick:r})]}),e.jsxs(L,{"aria-label":"Span detail tabs",children:[e.jsx(L.Item,{"aria-current":o==="details"?"page":void 0,onClick:()=>a("details"),children:"Details"}),x&&e.jsx(L.Item,{"aria-current":o==="tree"?"page":void 0,onClick:()=>a("tree"),children:"Trace Tree"}),e.jsx(L.Item,{"aria-current":o==="raw"?"page":void 0,onClick:()=>a("raw"),children:"Raw Data"})]}),e.jsxs(s,{flex:1,overflow:"auto",children:[o==="details"&&e.jsxs(s,{p:3,children:[e.jsx(y,{label:"span_name",value:t.span_name}),e.jsx(y,{label:"service_name",value:t.service_name}),e.jsx(y,{label:"otel_scope_name",value:t.otel_scope_name}),e.jsx(y,{label:"kind",value:t.kind}),e.jsx(y,{label:"trace_id",value:t.trace_id,mono:!0}),e.jsx(y,{label:"span_id",value:t.span_id,mono:!0}),e.jsx(y,{label:"parent_span_id",value:t.parent_span_id,mono:!0}),e.jsx(y,{label:"duration",value:Y(t.duration_ms)}),e.jsx(y,{label:"start_time",value:t.start_time,mono:!0}),e.jsx(y,{label:"end_time",value:t.end_time,mono:!0}),e.jsx(y,{label:"status_code",value:t.status_code}),e.jsx(y,{label:"status_message",value:t.status_message}),e.jsx(ee,{title:"Arguments",data:i,defaultOpen:Object.keys(i).length>0}),e.jsx(ee,{title:"Attributes",data:d}),t.events&&t.events.length>0&&e.jsxs(s,{mt:3,children:[e.jsxs(s,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(f,{sx:{fontWeight:"bold",fontSize:1},children:"Events"}),e.jsx(J,{children:t.events.length})]}),t.events.map((u,h)=>e.jsxs(v,{border:!0,shadow:"none",variant:"subtle",display:"block",p:2,mt:2,children:[e.jsxs(s,{display:"flex",gap:2,children:[e.jsx(W,{children:u.name}),e.jsx(f,{sx:{fontSize:0,color:"fg.muted",fontFamily:"mono"},children:u.timestamp})]}),u.attributes&&Object.keys(u.attributes).length>0&&e.jsx(s,{mt:1,children:Object.entries(u.attributes).map(([c,g])=>e.jsx(F,{attrKey:c,value:g,depth:0},c))})]},h))]}),t.links&&t.links.length>0&&e.jsxs(s,{mt:3,children:[e.jsxs(s,{display:"flex",alignItems:"center",gap:1,children:[e.jsx(f,{sx:{fontWeight:"bold",fontSize:1},children:"Links"}),e.jsx(J,{children:t.links.length})]}),t.links.map((u,h)=>e.jsxs(f,{sx:{display:"block",fontSize:1,fontFamily:"mono",py:1,borderBottom:"1px solid",borderColor:"border.muted"},children:["trace: ",u.trace_id," → span: ",u.span_id]},h))]})]}),o==="tree"&&x&&e.jsx(Le,{spans:x,selectedSpanId:t.span_id,defaultExpandDepth:4}),o==="raw"&&e.jsx(s,{as:"pre",p:3,fontSize:0,fontFamily:"mono",whiteSpace:"pre-wrap",wordBreak:"break-word",m:0,bg:"canvas.subtle",children:JSON.stringify(t,null,2)})]})]})},Pe=[{label:"Service",value:t=>t.service_name},{label:"Kind",value:t=>t.kind}];function He(t,n,r){return t.filter(o=>n.every((a,i)=>{const d=r[i];if(!d?.size)return!0;const x=a.value(o);return x!==void 0&&d.has(x)}))}function Ue(t,n){const r=new Set(t);return r.has(n)?r.delete(n):r.add(n),r}function Ve({facet:t,options:n,selected:r,onChange:o}){const a=t.name??(i=>i);return e.jsxs(G,{children:[e.jsxs(G.Button,{size:"small","data-otel-facet":t.label.toLowerCase(),children:[t.label,r.size?` · ${r.size}`:""]}),e.jsx(G.Overlay,{width:"auto",children:e.jsxs(M,{selectionVariant:"multiple","aria-label":t.label,children:[e.jsx(M.Item,{selected:!r.size,onSelect:()=>o(new Set),children:"All"}),e.jsx(M.Divider,{}),n.map(i=>e.jsx(M.Item,{selected:r.has(i),onSelect:()=>o(Ue(r,i)),children:a(i)},i))]})})]})}function Ge(t,n){const r=new Blob([JSON.stringify(n,null,2)],{type:"application/json"}),o=URL.createObjectURL(r),a=document.createElement("a");a.href=o,a.download=`${t}.json`,a.click(),setTimeout(()=>URL.revokeObjectURL(o),1e3)}const Ke=({tracer:t,spans:n,service:r,facets:o=Pe,compact:a=!1,maxHeight:i=420,detailPlacement:d="below",emptyText:x="Nothing recorded yet.",exportName:u="otel-spans",label:h="Spans",renderSpanMark:c,describeSpan:g})=>{const j=Ee(n?null:t),S=n??j,[p,A]=m.useState(0),[l,w]=m.useState(null),[b,E]=m.useState(()=>o.map(()=>new Set)),[k,$]=m.useState(null),I=m.useMemo(()=>{const _=$e(S,r);return p?_.filter(T=>D(T.start_time)>=p):_},[S,r,p]),C=l??I,z=l?I.length-l.length:0,ie=m.useMemo(()=>o.map(_=>[...new Set(I.map(T=>_.value(T)).filter(T=>T!==void 0))].sort()),[o,I]),R=m.useMemo(()=>He(C,o,b),[C,o,b]),N=m.useMemo(()=>k?S.find(_=>_.span_id===k)??null:null,[S,k]),le=m.useMemo(()=>N?S.filter(_=>_.trace_id===N.trace_id):[],[S,N]),U=d==="side"&&!a;return e.jsxs(v,{border:!0,shadow:"none",display:"block","data-otel-live-spans":"",color:"fg.default",minWidth:0,children:[e.jsxs(s,{role:"toolbar","aria-label":h,display:"flex",flexWrap:"wrap",gap:2,alignItems:"center",p:2,borderBottom:"1px solid",borderColor:"border.default",children:[o.map((_,T)=>e.jsx(Ve,{facet:_,options:ie[T]??[],selected:b[T]??new Set,onChange:ae=>E(de=>o.map((Ye,q)=>q===T?ae:de[q]??new Set))},_.label)),e.jsx(s,{flex:1}),e.jsxs(f,{sx:{fontSize:0,color:"fg.muted"},"data-otel-span-count":"",children:[R.length===C.length?`${R.length} ${R.length===1?"span":"spans"}`:`${R.length} of ${C.length}`,z>0?` · ${z} new`:""]}),e.jsx(V,{size:"small",leadingVisual:l?xe:he,"aria-pressed":l!==null,onClick:()=>w(l?null:I),"data-otel-pause":"",children:l?"Resume":"Pause"}),e.jsx(V,{size:"small",leadingVisual:pe,onClick:()=>{w(null),$(null),t&&!n&&!r?t.clear():A(Date.now())},"data-otel-clear":"",children:"Clear"}),e.jsx(V,{size:"small",leadingVisual:me,disabled:!I.length,onClick:()=>Ge(u,{exportedAt:new Date().toISOString(),spans:[...I]}),"data-otel-export":"",children:"Export"})]}),e.jsxs(s,{display:U?"grid":"block",gridTemplateColumns:U?"minmax(0, 3fr) minmax(0, 2fr)":void 0,children:[e.jsx(s,{maxHeight:i,overflowY:"auto",minWidth:0,children:e.jsx(Me,{spans:R,selectedSpanId:k,onSelectSpan:_=>$(_.span_id),emptyText:x,compact:a,defaultExpanded:!0,renderSpanMark:c,describeSpan:g})}),N&&e.jsx(s,{"data-otel-live-detail":"",maxHeight:i,overflowY:"auto",minWidth:0,borderTop:U?"none":"1px solid",borderColor:"border.default",children:e.jsx(Fe,{span:N,traceSpans:le,onClose:()=>$(null)})})]})]})},Je=[{label:"Source",value:be,name:t=>ge[t]??t},{label:"Operation",value:t=>{const n=t.attributes??{},r=n[X.operation]??n["rpc.method"];return r===void 0?void 0:String(r)}},{label:"Agent",value:t=>t.service_name}];function Xe(t){const n=t.attributes?.[X.markIcon],r=t.attributes?.[X.markEmoji];return n||r?e.jsx(Se,{icon:typeof n=="string"?n:void 0,emoji:typeof r=="string"?r:void 0,size:14}):null}function Ze({tracer:t,spans:n,agent:r,maxHeight:o=420,compact:a=!1,emptyText:i="Nothing recorded yet.",exportName:d="agent-inspector"}){return e.jsx("div",{"data-agent-inspector":r??"",children:e.jsx(Ke,{tracer:t,spans:n,service:r,facets:Je,compact:a,maxHeight:o,detailPlacement:"side",emptyText:i,exportName:d,label:r?`${r}'s Agent Inspector`:"Agent Inspector",renderSpanMark:Xe,describeSpan:je})})}export{Je as AGENT_INSPECTOR_FACETS,Ze as AgentInspector,Ze as default};
|