next-observer 0.3.21 → 0.3.22
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.
|
@@ -14,4 +14,4 @@ Error generating stack: `+e.message+`
|
|
|
14
14
|
`).map(e=>` ${e}`)," ```")}}m.push(``,`## Where the time went`,`Own time of each operation (without the calls it makes), share of all own time in the trace:`);for(let e of s){let t=c(e.name,e.service);m.push(`- \`${e.name}\`: ${H(e.selfMs)} (${wl(e.selfShare)})${e.calls>1?`, ${e.calls} calls`:``}${t?`, \`${t}\``:``}`)}return d.length>0&&m.push(``,`## Repeated calls`,...d),m.push(``,`## Task`,u?`1. Open the code named above and find why it throws.`:`1. Open the code named above and find what makes it slow.`,`2. Explain the cause in a few sentences, pointing at the lines.`,`3. Propose the smallest change that fixes it. Do not change behaviour elsewhere.`,xl),m.join(`
|
|
15
15
|
`)}function kl(e){let t=[bl,``,`## Problem`,e.category===`browser-error`?`In the browser (service ${e.service}), ${e.pages.length?`on ${e.pages.map(e=>`\`${e.path}\``).join(`, `)}, `:``}this was recorded as "${e.operation}":`:e.category===`request`?`${ll(e.source)} \`${e.operation}\` (service ${e.service}) fails with:`:`\`${e.operation}\` (service ${e.service}) fails with:`,"```",`${e.type?`${e.type}: `:``}${e.message}`,"```",`${e.count} ${e.count===1?`occurrence`:`occurrences`} in the selected window.`],n=ul(e);return n.length>0&&t.push(`Requests failing because of it: ${n.map(e=>`\`${e.operation}\` (${e.count})`).join(`, `)}.`),e.isNew?t.push(`It first appeared in version ${e.firstSeenVersion}; it was not seen in earlier versions.`):e.versions.length>0&&t.push(`Seen in ${e.versions.length===1?`version`:`versions`} ${e.versions.join(`, `)}; first seen in ${e.firstSeenVersion??`an unknown version`}.`),e.exampleTraceIds.length>0&&t.push(`Example traces: ${e.exampleTraceIds.map(e=>`\`${e}\``).join(`, `)}.`),t.push(``,`## Task`,e.category===`browser-error`?`1. Find the client code on that page that can produce this error (the message and the component named in it are the leads).`:e.category===`request`?`1. Find where the app makes this request and the route that should answer it; say which side is wrong (the URL, the route, or what the route does).`:`1. Find where \`${e.operation}\` is implemented and which line can throw this.`,e.isNew?`2. Look at what changed in ${e.firstSeenVersion} around it (git log / diff) and explain the cause.`:`2. Explain under which inputs or conditions it throws.`,`3. Propose the smallest change that fixes it, and say how to verify the fix.`,xl),t.join(`
|
|
16
16
|
`)}function Al(e){switch(e.kind){case`regression`:return`\`${e.operation}\` (${e.service}): p95 ${H(e.from.p95Ms)} in ${e.from.version} → ${H(e.to.p95Ms)} in ${e.to.version}${e.p95Ratio===null?``:` (×${e.p95Ratio})`}; error rate ${wl(e.from.errorRate)} → ${wl(e.to.errorRate)}.`;case`errors`:return e.message===Tl?void 0:`\`${e.operation}\` (${e.service}) fails in ${e.errorRate===null?`some`:wl(e.errorRate)} of calls: "${e.message}". Example traces: ${e.traceIds.map(e=>`\`${e}\``).join(`, `)}.`;case`n-plus-one`:return`\`${e.parent}\` calls \`${e.operation}\` ${e.count} times in one request (${H(e.totalMs)} in total, trace \`${e.traceId}\`).`;case`hotspot`:return`\`${e.operation}\` spends ${H(e.selfMs)} of a ${H(e.traceMs)} request in its own code${e.codeFile?` — \`${e.codeFile}\``:``} (trace \`${e.traceId}\`).`;case`silent`:return`No spans from ${e.service} for ${e.lastSpanSecondsAgo} s.`;case`traces`:return}}function jl(e,t,n){let r=n.map(Al).filter(e=>e!==void 0),i=[bl,``,`## Problem`,e];return r.length>0&&i.push(``,`## Measured`,...[...new Set(r)].map(e=>`- ${e}`)),i.push(``,`## Diagnosis by the observability agents`,`Written by a model from the data above — check it against the code rather than trusting it.`,``,t.trim(),``,`## Task`,`1. Open the code named above and confirm or correct the diagnosis.`,`2. Propose the smallest change that fixes the problem. Do not change behaviour elsewhere.`,xl),i.join(`
|
|
17
|
-
`)}function Ml(e){return e.split(/(\*\*[^*\n]+\*\*|`[^`\n]+`)/g).map((e,t)=>e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?(0,m.jsx)(`strong`,{children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,m.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.85em]`,children:e.slice(1,-1)},t):(0,m.jsx)(p.Fragment,{children:e},t))}var Nl=[`Checkout is slow. What's causing it and which deployment introduced it?`,`There are 500 errors on product pages. Which operation is failing and why?`,`The product catalog is slower than expected but no single span stands out. What is wrong?`],Pl=oa(`/chat`),Fl=e=>e.type===`report`||e.type===`error`;function Il(){let e=nt({queryKey:[`chat-info`],queryFn:Ba.chatInfo}),t=e.data?.enabled??!1,[n,r]=(0,p.useState)([]),[i,a]=(0,p.useState)(``),[o,s]=(0,p.useState)(),c=n.some(e=>e.running&&!e.proactive),l=(0,p.useRef)(c);l.current=c;let u=(0,p.useRef)(t);u.current=t,(0,p.useEffect)(()=>{let e=0,t=new Map,n=new EventSource(`/api/chat/events`);return n.onmessage=n=>{let{seq:i,turnId:a,event:o}=JSON.parse(n.data);if(i<=e)return;e=i,o.type===`status`&&t.set(a,o.sessionId),r(e=>{let t=e.find(e=>e.id===a),n=t??{id:a,question:o.type===`anomaly`?Gc(o.anomaly):`Anomaly`,events:[],running:u.current,proactive:!0},r={...n,events:[...n.events,o],running:n.running&&!Fl(o)};return t?e.map(e=>e.id===a?r:e):[...e,r]});let c=t.get(a);o.type===`report`&&c&&!l.current&&s(c)},()=>n.close()},[]);async function d(e){let t=`q-${Date.now()}`,n=e=>r(n=>n.map(n=>n.id===t?e(n):n));r(n=>[...n,{id:t,question:e,events:[],running:!0}]),a(``);try{await Ba.ask(e,o,e=>{e.type===`status`&&s(e.sessionId),n(t=>({...t,events:[...t.events,e]}))})}catch(e){n(t=>({...t,events:[...t.events,{type:`error`,message:e instanceof Error?e.message:String(e)}]}))}finally{n(e=>({...e,running:!1}))}}let{ask:f}=Pl.useSearch(),h=Ui({from:`/chat`}),g=(0,p.useRef)(void 0);(0,p.useEffect)(()=>{f&&t&&g.current!==f&&(g.current=f,h({search:{},replace:!0}),d(f))},[f,t]);function _(){r([]),s(void 0)}function v(e){e.preventDefault(),i.trim()&&!c&&d(i.trim())}let y=n.map(e=>(0,m.jsx)(Ll,{turn:e},e.id));return e.data&&!e.data.enabled?(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(Xc,{"data-testid":`chat-disabled`,children:(0,m.jsxs)($c,{className:`space-y-2 text-sm`,children:[(0,m.jsx)(`p`,{className:`font-medium`,children:`Chat is disabled`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:e.data.reason})]})}),y]}):(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:[(0,m.jsxs)(sl,{title:`Ask the agents`,subtitle:`They read your traces with tools — every fact comes from the data.`,children:[e.data?.enabled&&(0,m.jsx)(Uc,{variant:e.data.mode===`mock`?`outline`:`secondary`,className:`font-mono`,"data-testid":`chat-mode`,children:e.data.mode===`mock`?`MOCK — no real model`:`REAL model`}),n.length>0&&(0,m.jsx)(Mc,{type:`button`,variant:`ghost`,size:`sm`,onClick:_,disabled:c,children:`New chat`})]}),n.length===0&&(0,m.jsx)(`div`,{className:`flex flex-col items-start gap-2`,children:Nl.map(e=>(0,m.jsx)(Mc,{type:`button`,variant:`outline`,size:`sm`,className:`h-auto whitespace-normal py-2 text-left font-normal`,onClick:()=>void d(e),disabled:c,children:e},e))}),y,(0,m.jsxs)(`form`,{onSubmit:v,className:`flex gap-2`,children:[(0,m.jsx)(ol,{"aria-label":`Question`,placeholder:`Why is checkout slow?`,value:i,onChange:e=>a(e.target.value),disabled:c}),(0,m.jsx)(Mc,{type:`submit`,disabled:c||!i.trim(),children:c?`Investigating…`:`Ask`})]})]})}function Ll({turn:e}){let t=e.events.find(e=>e.type===`anomaly`),n=e.events.filter(e=>e.type===`step`),r=e.events.flatMap(e=>e.type===`card`?[e.card]:[]),i=e.events.find(e=>e.type===`report`),a=e.events.find(e=>e.type===`error`),o=n.length>0||r.length>0||i||a||e.running;return(0,m.jsxs)(`div`,{className:`space-y-2`,"data-testid":`chat-turn`,"data-proactive":e.proactive?`true`:void 0,children:[t?(0,m.jsx)(qc,{anomaly:t.anomaly}):(0,m.jsx)(`div`,{className:`ml-auto w-fit max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm text-primary-foreground`,children:e.question}),o&&(0,m.jsx)(Xc,{children:(0,m.jsxs)($c,{className:`space-y-3 text-sm`,children:[(0,m.jsxs)(`ol`,{className:`space-y-1 font-mono text-xs text-muted-foreground`,"data-testid":`chat-steps`,children:[n.map((e,t)=>(0,m.jsxs)(`li`,{children:[(0,m.jsxs)(`span`,{className:e.agent===`orchestrator`?`text-foreground`:`pl-4`,children:[e.agent,` → `,e.tool]}),Object.keys(e.args).length>0&&(0,m.jsx)(`span`,{className:`ml-1 opacity-70`,children:JSON.stringify(e.args).slice(0,120)})]},t)),e.running&&(0,m.jsx)(`li`,{className:`animate-pulse`,children:e.proactive?`agents are investigating on their own…`:`working…`})]}),r.length>0&&(0,m.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`chat-cards`,children:r.map((e,t)=>(0,m.jsx)(al,{card:e},t))}),i&&(0,m.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed [overflow-wrap:anywhere]`,"data-testid":`chat-report`,children:Ml(i.text)}),i&&(0,m.jsx)(`div`,{className:`flex justify-end`,children:(0,m.jsx)(Yc,{build:()=>jl(e.question,i.text,r)})}),a&&(0,m.jsx)(`p`,{className:`text-destructive`,"data-testid":`chat-error`,children:a.message})]})})]})}var Rl={"5m":3e5,"15m":9e5,"1h":36e5,"24h":864e5},zl=e=>typeof e==`string`&&e in Rl?e:void 0;function Bl({value:e,onChange:t}){return(0,m.jsx)(`div`,{className:`flex overflow-hidden rounded-md border`,role:`group`,"aria-label":`Time window`,children:Object.keys(Rl).map(n=>(0,m.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>t(n===`15m`?void 0:n),className:`border-l px-3 py-1 font-mono text-xs text-muted-foreground uppercase first:border-l-0 hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,children:n},n))})}var Vl=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function Hl({series:e}){let t=Math.max(1,...e.map(e=>e.ok+e.clientErrors+e.serverErrors));return(0,m.jsx)(`div`,{className:`flex h-40 items-end gap-1`,role:`img`,"aria-label":`Requests over time`,children:e.map(e=>{let n=e.ok+e.clientErrors+e.serverErrors;return(0,m.jsxs)(`div`,{className:`flex h-full flex-1 flex-col justify-end`,title:`${Vl(e.startMs)} · ${n} requests · ${e.clientErrors} 4xx · ${e.serverErrors} 5xx`,"data-testid":`requests-bucket`,children:[(0,m.jsx)(Ul,{value:e.serverErrors,max:t,tone:`bg-destructive`}),(0,m.jsx)(Ul,{value:e.clientErrors,max:t,tone:`bg-warning`}),(0,m.jsx)(Ul,{value:e.ok,max:t,tone:`bg-foreground/25`}),n===0&&(0,m.jsx)(`span`,{className:`h-px bg-foreground/10`})]},e.startMs)})})}function Ul({value:e,max:t,tone:n}){return e===0?null:(0,m.jsx)(`span`,{className:`block min-h-0.5 rounded-[2px] ${n}`,style:{height:`${e/t*100}%`}})}function Wl({series:e}){let t=Math.max(1,...e.map(e=>e.p95Ms??0))*1.15,n=t=>(t+.5)/e.length*100,r=e=>100-e/t*100,i=[];e.forEach((e,t)=>{if(e.p95Ms===null||e.avgMs===null)return i.push([]);i.length===0&&i.push([]),i[i.length-1].push({i:t,avg:e.avgMs,p95:e.p95Ms})});let a=i.filter(e=>e.length>0);return(0,m.jsxs)(`div`,{className:`relative h-40`,children:[(0,m.jsxs)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`h-full w-full overflow-visible`,role:`img`,"aria-label":`Duration over time`,children:[[25,50,75].map(e=>(0,m.jsx)(`line`,{x1:`0`,x2:`100`,y1:e,y2:e,className:`stroke-foreground/10`,strokeDasharray:`1 1.5`,vectorEffect:`non-scaling-stroke`},e)),a.map(t=>{let i=t.map(e=>`${n(e.i)},${r(e.p95)}`),a=t.length===1?[`${n(t[0].i)-50/e.length},${r(t[0].p95)}`,`${n(t[0].i)+50/e.length},${r(t[0].p95)}`]:i,o=a[0].split(`,`)[0],s=a[a.length-1].split(`,`)[0];return(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`polygon`,{points:`${o},100 ${a.join(` `)} ${s},100`,className:`fill-chart-1/15`}),(0,m.jsx)(`polyline`,{points:a.join(` `),fill:`none`,className:`stroke-chart-1`,strokeWidth:`1.5`,vectorEffect:`non-scaling-stroke`}),(0,m.jsx)(`polyline`,{points:t.length===1?a.map(e=>`${e.split(`,`)[0]},${r(t[0].avg)}`).join(` `):t.map(e=>`${n(e.i)},${r(e.avg)}`).join(` `),fill:`none`,className:`stroke-foreground/50`,strokeWidth:`1`,strokeDasharray:`2 2`,vectorEffect:`non-scaling-stroke`})]},t[0].i)})]}),(0,m.jsx)(`span`,{className:`absolute top-0 left-0 font-mono text-[11px] text-muted-foreground`,children:H(t)})]})}function Gl({rows:e,value:t,meta:n,empty:r}){return e.length===0?(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r}):(0,m.jsx)(`ul`,{className:`-my-1 divide-y`,children:e.map(e=>{let[r,...i]=e.operation.split(` `),a=i.length>0&&/^[A-Z]+$/.test(r);return(0,m.jsx)(`li`,{children:(0,m.jsxs)(R,{to:`/operation`,search:{name:e.operation,service:e.service},className:`group flex items-center gap-3 py-2.5`,"data-testid":`route-row`,children:[a&&(0,m.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] tracking-wider text-muted-foreground`,children:r}),(0,m.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm group-hover:text-signal`,children:a?i.join(` `):e.operation}),(0,m.jsxs)(`span`,{className:`text-right`,children:[(0,m.jsx)(`span`,{className:`block font-mono text-sm tabular-nums`,children:t(e)}),(0,m.jsx)(`span`,{className:`block font-mono text-[11px] text-muted-foreground`,children:n(e)})]})]})},`${e.service}:${e.operation}`)})})}function Kl({title:e,count:t,change:n,children:r,aside:i,testId:a}){return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":a,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-5 py-3.5`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:e}),t!==void 0&&(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums`,children:t}),n,i&&(0,m.jsx)(`div`,{className:`ml-auto flex items-center gap-3 font-mono text-xs text-muted-foreground`,children:i})]}),(0,m.jsx)(`div`,{className:`px-5 py-4`,children:r})]})}function ql({value:e,upIsBad:t}){if(e===null)return null;let n=Math.round(e*100),r=n>0,i=n===0||t===void 0?`text-muted-foreground`:r===t?`text-destructive`:`text-signal`,a=r?po:uo;return(0,m.jsxs)(`span`,{className:`flex items-center gap-1 text-xs ${i}`,"data-testid":`change`,children:[n!==0&&(0,m.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),r?`+`:``,n,`% `,(0,m.jsx)(`span`,{className:`text-muted-foreground`,children:`since last period`})]})}function Jl({tone:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`h-3 w-0.5 rounded-full ${e}`,"aria-hidden":!0}),t]})}function Yl({label:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e,(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-foreground tabular-nums`,children:t})]})}function Xl({fromMs:e,toMs:t}){let n=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:n(e)}),(0,m.jsx)(`span`,{children:n(t)})]})}var Zl=2e3,Ql=oa(`/`),$l=e=>`${Math.round(e*100)}%`;function eu(){let{window:e=`15m`,service:t}=Ql.useSearch(),n=Ui({from:`/`}),r=nt({queryKey:[`overview`,e,t],queryFn:()=>Ba.overview(Rl[e],t),refetchInterval:Zl}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Zl}),a=r.data;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(sl,{title:`Overview`,subtitle:`Your app's requests, latency and errors — compared with the period before.`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-8 rounded-md border bg-card px-2 text-sm`,value:t??``,onChange:e=>n({search:t=>({...t,service:e.target.value||void 0}),replace:!0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.filter(e=>!e.name.endsWith(`-browser`)).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})]}),a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Requests`,testId:`panel-requests`,count:a.requests.total,change:(0,m.jsx)(ql,{value:a.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`tabular-nums`,children:[a.requests.perSecond,`/s`]}),(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`2/3xx`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`5xx`})]}),children:[(0,m.jsx)(Hl,{series:a.requests.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:a.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:a.duration.avgMs===null?`—`:H(a.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:a.duration.p95Ms===null?`—`:H(a.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:a.duration.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,m.jsxs)(Kl,{title:`Errors`,testId:`panel-errors`,count:a.errors.count,change:(0,m.jsx)(ql,{value:a.errors.change,upIsBad:!0}),aside:(0,m.jsx)(R,{to:`/errors`,search:{window:e===`15m`?void 0:e,service:t},className:`hover:text-signal`,children:`view all →`}),children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`font-mono text-4xl font-medium tabular-nums ${a.errors.count>0?`text-destructive`:``}`,"data-testid":`error-rate`,children:$l(a.errors.rate)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`of requests failed with 5xx`})]}),(0,m.jsx)(`div`,{className:`mt-4 flex h-12 items-end gap-0.5`,"aria-hidden":!0,children:a.requests.series.map(e=>{let t=Math.max(1,...a.requests.series.map(e=>e.serverErrors));return(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e.serverErrors?`bg-destructive`:`bg-foreground/10`}`,style:{height:e.serverErrors?`${e.serverErrors/t*100}%`:`2px`}},e.startMs)})})]}),(0,m.jsx)(Kl,{title:`Slowest`,testId:`panel-slowest`,aside:`P95`,children:(0,m.jsx)(Gl,{rows:a.slowest,value:e=>H(e.p95Ms),meta:e=>`${e.count} ${e.count===1?`call`:`calls`}${e.errorRate>0?` · ${$l(e.errorRate)} errors`:``}${e.coldOnly?` · cold start only`:``}`,empty:`No requests in this window.`})}),(0,m.jsx)(Kl,{title:`Busiest`,testId:`panel-busiest`,aside:`CALLS`,children:(0,m.jsx)(Gl,{rows:a.busiest,value:e=>String(e.count),meta:e=>`${$l(e.share)} of requests`,empty:`No requests in this window.`})})]})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}var tu=2e3,nu=oa(`/errors`);function ru(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function iu(){let{window:e=`15m`,service:t}=nu.useSearch(),n=Ui({from:`/errors`}),r=nt({queryKey:[`defects`,e,t],queryFn:()=>Ba.defects(Rl[e],t),refetchInterval:tu});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Errors`,count:r.data?.length,subtitle:`Failures grouped by where they start and what they say — one entry per defect, not per request.`,children:(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})}),r.data?r.data.length===0?(0,m.jsxs)(Xc,{className:`items-center py-12 text-center`,"data-testid":`errors-empty`,children:[(0,m.jsxs)(`p`,{className:`font-medium`,children:[`No errors in the last `,e]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A defect shows up here as soon as a span fails.`})]}):(0,m.jsx)(`div`,{className:`space-y-4`,children:r.data.map(e=>(0,m.jsx)(au,{defect:e},e.id))}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}function au({defect:e}){let t=Ui(),n=Math.max(1,...e.series),r=ul(e);return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":`defect`,"data-new":e.isNew?`true`:void 0,children:[(0,m.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 px-5 py-4 lg:grid-cols-[minmax(0,1fr)_14rem]`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.isNew?(0,m.jsxs)(`span`,{className:`rounded-md bg-warning/15 px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-warning uppercase`,"data-testid":`defect-new`,children:[`new in `,e.firstSeenVersion]}):e.versions.length>0&&(0,m.jsxs)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[`seen in `,e.versions.join(`, `)]}),(0,m.jsx)(`span`,{className:`rounded-md border px-1.5 py-0.5 font-mono text-[11px] tracking-wider uppercase ${e.source===`browser`?`border-signal/40 text-signal`:`text-muted-foreground`}`,"data-testid":`defect-source`,children:e.source}),e.type&&(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.type})]}),(0,m.jsx)(`p`,{className:`font-mono text-sm break-words text-destructive`,"data-testid":`defect-message`,children:e.message}),(0,m.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`defect-where`,children:[e.category===`code`?(0,m.jsxs)(m.Fragment,{children:[`in`,` `,(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground underline decoration-dotted underline-offset-4 hover:text-signal`,children:e.operation})]}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation}),e.pages.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· on`,` `,e.pages.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.path})]},e.path))]}),r.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· fails`,` `,r.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,e.spanName===e.operation?(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground hover:text-signal`,children:e.operation}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation})]},`${e.service}:${e.spanName}:${e.operation}`))]})]})]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,m.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums`,"data-testid":`defect-count`,children:e.count}),(0,m.jsx)(`span`,{className:`font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:e.count===1?`occurrence`:`occurrences`})]}),(0,m.jsx)(`div`,{className:`flex h-8 items-end gap-0.5`,"aria-hidden":!0,children:e.series.map((e,t)=>(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e?`bg-destructive`:`bg-foreground/10`}`,style:{height:e?`${Math.max(e/n*100,12)}%`:`2px`}},t))})]})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2 border-t px-5 py-2.5 font-mono text-xs text-muted-foreground`,children:[(0,m.jsxs)(`span`,{children:[`first seen `,ru(e.firstSeenMs)]}),(0,m.jsxs)(`span`,{children:[`last seen `,ru(e.lastSeenMs)]}),(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`traces`,e.exampleTraceIds.map(e=>(0,m.jsxs)(R,{to:`/traces/$traceId`,params:{traceId:e},className:`text-signal underline-offset-2 hover:underline`,children:[e.slice(0,6),`…`,e.slice(-4)]},e))]}),(0,m.jsx)(Yc,{build:()=>kl(e),className:`ml-auto font-sans`}),(0,m.jsx)(Mc,{type:`button`,size:`sm`,variant:`outline`,className:`font-sans`,"data-testid":`defect-investigate`,onClick:()=>void t({to:`/chat`,search:{ask:fl(e)}}),children:`Investigate`})]})]})}function W(e,t,n=.06){let r=[{label:`median`,ms:e.p50Ms},{label:`p95`,ms:e.p95Ms},{label:`p99`,ms:e.p99Ms}],i=[];for(let e of r)(i.length===0||(e.ms-i[i.length-1].ms)/t>n)&&i.push(e);return i}var ou=e=>`${Math.round(e*100)}%`;function su({histogram:e,speeds:t}){let n=e.bins[e.bins.length-1].toMs||1,r=Math.max(1,...e.bins.map(e=>e.count)),i=W(e,n);return(0,m.jsxs)(`div`,{"data-testid":`latency-histogram`,children:[(0,m.jsxs)(`div`,{className:`relative mt-6 h-40`,children:[i.map(e=>(0,m.jsx)(`div`,{className:`absolute -top-6 bottom-0 border-l border-dashed border-foreground/30`,style:{left:`${Math.min(e.ms/n*100,100)}%`},children:(0,m.jsxs)(`span`,{className:`absolute top-0 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/n>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`div`,{className:`flex h-full items-end gap-0.5`,role:`img`,"aria-label":`Latency distribution`,children:e.bins.map((t,n)=>(0,m.jsx)(`span`,{"data-testid":`histogram-bin`,title:`${H(t.fromMs)} – ${n===e.bins.length-1&&e.overflow?`and slower`:H(t.toMs)} · ${t.count} calls (${ou(t.count/e.total)})`,className:`flex-1 rounded-t-[2px] ${t.count?`bg-chart-1/70`:`bg-foreground/10`}`,style:{height:t.count?`${Math.max(t.count/r*100,2)}%`:`1px`}},n))})]}),(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:`0`}),(0,m.jsx)(`span`,{children:H(n/2)}),(0,m.jsxs)(`span`,{children:[e.overflow?`≥ `:``,H(n)]})]}),t&&(0,m.jsxs)(`p`,{className:`mt-3 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,"data-testid":`two-speeds`,children:[(0,m.jsx)(`span`,{className:`text-warning`,children:`Two speeds`}),` · `,H(t[0].medianMs),` (`,ou(t[0].share),`) and `,H(t[1].medianMs),` (`,ou(t[1].share),`) ·`,` `,Math.round(t[1].medianMs/t[0].medianMs),`× apart`]})]})}function cu({label:e,children:t}){return(0,m.jsxs)(`div`,{className:`flex items-baseline gap-2 py-1 text-xs`,children:[(0,m.jsxs)(`dt`,{className:`flex min-w-0 flex-1 items-baseline gap-2 text-muted-foreground`,children:[(0,m.jsx)(`span`,{className:`shrink-0`,children:e}),(0,m.jsx)(`span`,{"aria-hidden":!0,className:`min-w-4 flex-1 border-b border-dotted border-foreground/20`})]}),(0,m.jsx)(`dd`,{className:`min-w-0 max-w-[70%] break-all text-right font-mono`,children:t})]})}var lu=`The first request of this route after the server started. In next dev it includes compiling the route, so it is slower than the rest — the agents leave it out of latency statistics.`;function uu(){return(0,m.jsx)(Uc,{variant:`outline`,title:lu,className:`ml-2 cursor-help font-normal text-muted-foreground`,children:`cold start`})}function du({className:e,...t}){return(0,m.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,m.jsx)(`table`,{"data-slot":`table`,className:ds(`w-full caption-bottom text-sm`,e),...t})})}function fu({className:e,...t}){return(0,m.jsx)(`thead`,{"data-slot":`table-header`,className:ds(`[&_tr]:border-b`,e),...t})}function pu({className:e,...t}){return(0,m.jsx)(`tbody`,{"data-slot":`table-body`,className:ds(`[&_tr:last-child]:border-0`,e),...t})}function mu({className:e,...t}){return(0,m.jsx)(`tr`,{"data-slot":`table-row`,className:ds(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function hu({className:e,...t}){return(0,m.jsx)(`th`,{"data-slot":`table-head`,className:ds(`h-10 px-2 text-left align-middle font-mono text-[11px] font-normal tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0`,e),...t})}function gu({className:e,...t}){return(0,m.jsx)(`td`,{"data-slot":`table-cell`,className:ds(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function _u({traces:e,empty:t}){return(0,m.jsx)(Xc,{className:`py-0`,children:(0,m.jsxs)(du,{children:[(0,m.jsx)(fu,{children:(0,m.jsxs)(mu,{children:[(0,m.jsx)(hu,{className:`pl-4`,children:`Trace`}),(0,m.jsx)(hu,{children:`Services`}),(0,m.jsx)(hu,{className:`text-right`,children:`Duration`}),(0,m.jsx)(hu,{className:`text-right`,children:`Spans`}),(0,m.jsx)(hu,{className:`text-right`,children:`Errors`}),(0,m.jsx)(hu,{className:`pr-4 text-right`,children:`Started`})]})}),(0,m.jsxs)(pu,{children:[e?.map(e=>(0,m.jsxs)(mu,{"data-testid":`trace-row`,children:[(0,m.jsxs)(gu,{className:`pl-4`,children:[(0,m.jsx)(R,{to:`/traces/$traceId`,params:{traceId:e.traceId},className:`font-medium hover:underline`,children:e.rootName}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:e.traceId.slice(0,16)})]}),(0,m.jsx)(gu,{className:`space-x-1`,children:e.services.map(e=>(0,m.jsx)(Uc,{variant:`secondary`,children:e},e))}),(0,m.jsx)(gu,{className:`text-right font-mono tabular-nums`,children:H(e.durationMs)}),(0,m.jsx)(gu,{className:`text-right font-mono text-muted-foreground tabular-nums`,children:e.spanCount}),(0,m.jsx)(gu,{className:`text-right`,children:e.errorCount>0?(0,m.jsx)(Uc,{variant:`destructive`,children:e.errorCount}):`—`}),(0,m.jsx)(gu,{className:`pr-4 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:new Date(e.startTimeMs).toLocaleTimeString()})]},e.traceId)),e?.length===0&&(0,m.jsx)(mu,{children:(0,m.jsx)(gu,{colSpan:6,className:`py-10 text-center text-muted-foreground`,children:t})})]})]})})}var vu=2e3,yu=oa(`/operation`),bu=e=>`${Math.round(e*100)}%`,G=e=>e==null?`—`:H(e);function xu(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function Su(){let{name:e,service:t,window:n=`15m`}=yu.useSearch(),r=Ui({from:`/operation`}),i=nt({queryKey:[`operation`,e,t,n],queryFn:()=>Ba.operation(e,Rl[n],t),refetchInterval:vu,enabled:e!==``}),a=i.data,o=a?.overview.fromMs,s=nt({queryKey:[`operation-traces`,e,t,o],queryFn:()=>Ba.traces({operation:e,exactOperation:!0,service:t,fromMs:o,limit:50}),enabled:e!==``&&o!==void 0,placeholderData:e=>e});if(e===``)return(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`No operation selected — pick one on the Overview.`});let c=a?.overview;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← overview`}),(0,m.jsx)(sl,{title:(0,m.jsx)(`span`,{className:`font-mono text-xl`,children:e}),subtitle:a?.service?`One operation of ${a.service} — its traffic, latency and every call.`:`One operation — its traffic, latency and every call.`,children:(0,m.jsx)(Bl,{value:n,onChange:e=>r({search:t=>({...t,window:e}),replace:!0})})})]}),!a||!c?(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:i.isError?`The observer is not reachable.`:`Loading…`}):c.requests.total===0?(0,m.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`operation-empty`,children:[`No calls of this operation in the last `,n,`. Try a longer window.`]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Details`,testId:`panel-details`,children:[(0,m.jsxs)(`dl`,{children:[(0,m.jsx)(cu,{label:`Calls`,children:c.requests.total}),(0,m.jsx)(cu,{label:`Avg duration`,children:G(c.duration.avgMs)}),(0,m.jsx)(cu,{label:`Median`,children:G(a.histogram?.p50Ms)}),(0,m.jsx)(cu,{label:`95th percentile`,children:G(c.duration.p95Ms)}),(0,m.jsx)(cu,{label:`Errors`,children:(0,m.jsxs)(`span`,{className:c.errors.count?`text-destructive`:``,children:[c.errors.count,` (`,bu(c.errors.rate),`)`]})}),a.coldStarts>0&&(0,m.jsx)(cu,{label:`Cold starts (not in latency)`,children:a.coldStarts}),(0,m.jsx)(cu,{label:`Last call`,children:a.lastSeenMs===null?`—`:xu(a.lastSeenMs)})]}),a.versions.length>1&&(0,m.jsxs)(`table`,{className:`mt-4 w-full font-mono text-xs`,"data-testid":`versions`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`py-1 font-normal`,children:`Version`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Calls`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Median`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`P95`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Errors`})]})}),(0,m.jsx)(`tbody`,{children:a.versions.map(e=>(0,m.jsxs)(`tr`,{className:`border-t tabular-nums`,children:[(0,m.jsx)(`td`,{className:`py-1.5`,children:e.version}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:e.count}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p50Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p95Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right ${e.errorRate>0?`text-destructive`:``}`,children:bu(e.errorRate)})]},e.version))})]})]}),(0,m.jsx)(Kl,{title:`Latency distribution`,testId:`panel-distribution`,aside:a.histogram?`${a.histogram.total} calls`:void 0,children:a.histogram?(0,m.jsx)(su,{histogram:a.histogram,speeds:a.speeds}):(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`Only cold starts so far — no representative latency yet.`})})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Calls`,testId:`panel-requests`,count:c.requests.total,change:(0,m.jsx)(ql,{value:c.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`ok`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`failed`})]}),children:[(0,m.jsx)(Hl,{series:c.requests.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:c.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:G(c.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:G(c.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:c.duration.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:`Traces with this operation`}),(0,m.jsx)(_u,{traces:s.data,empty:`No traces in this window.`})]})]})]})}var Cu=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/,wu=e=>e.kind===`client`&&Cu.test(e.name);function Tu(e){if(!wu(e))return;let t=e.attributes[`url.full`]??e.attributes[`http.url`];if(typeof t==`string`)try{return{method:e.name,pathname:new URL(t).pathname}}catch{return}}function Eu(e){let t=Tu(e);return t?`${t.method} ${t.pathname}`:e.name}var Du=oa(`/traces/$traceId`),Ou=[`bg-chart-1`,`bg-chart-2`,`bg-chart-4`,`bg-chart-3`,`bg-chart-5`];function ku(e,t){return Ou[t.indexOf(e)%Ou.length]}function Au(){let{traceId:e}=Du.useParams(),t=nt({queryKey:[`trace`,e],queryFn:()=>Ba.trace(e)}),[n,r]=(0,p.useState)(null),i=(0,p.useMemo)(()=>Pc(t.data?.spans??[]),[t.data]),a=(0,p.useMemo)(()=>[...new Set(i.rows.map(e=>e.span.service))],[i]),o=i.rows.find(e=>e.span.spanId===n)?.span??i.rows[0]?.span,[s,c]=(0,p.useState)(!1),l=t.data?.spans,u=(0,p.useMemo)(()=>vl(l??[]),[l]),d=(0,p.useMemo)(()=>gl(l??[]),[l]),f=(0,p.useMemo)(()=>U(l??[]),[l]),h=(0,p.useMemo)(()=>_l(l??[]),[l]),g=nt({queryKey:[`trace-operation`,h?.service,h?.name,h?.startTimeMs],queryFn:()=>Ba.operation(h.name,Mu,h.service,h.startTimeMs+Mu/2),enabled:h!==void 0});return t.isError?(0,m.jsxs)(`p`,{className:`text-destructive`,children:[`Trace `,e,` not found.`]}):t.data?(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/traces`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← traces`}),(0,m.jsx)(sl,{title:(0,m.jsxs)(m.Fragment,{children:[i.rows[0]?Eu(i.rows[0].span):``,t.data.spans.some(e=>e.coldStart)&&(0,m.jsx)(uu,{})]}),subtitle:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-foreground tabular-nums`,children:H(i.durationMs)}),` · `,i.rows.length,` spans · `,e]}),children:(0,m.jsx)(Yc,{build:()=>{let n=g.data?.histogram;return Ol({traceId:e,spans:t.data.spans,usual:n&&n.total>=ju?{p50Ms:n.p50Ms,p95Ms:n.p95Ms,calls:n.total}:void 0})}})})]}),h&&g.data?.histogram&&g.data.histogram.total>=ju&&(0,m.jsx)(Fu,{durationMs:h.durationMs,histogram:g.data.histogram,operation:h.name,service:h.service,coldStart:h.coldStart===!0}),(0,m.jsxs)(`div`,{className:`grid grid-cols-[1fr_380px] gap-4`,children:[(0,m.jsxs)(Xc,{className:`gap-0 self-start py-0`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b px-4 py-2.5`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":s,"data-testid":`critical-path-toggle`,onClick:()=>c(e=>!e),className:`rounded-full border px-3 py-1 font-mono text-[11px] tracking-wider text-muted-foreground uppercase hover:text-foreground aria-pressed:border-warning/60 aria-pressed:bg-warning/10 aria-pressed:text-warning`,children:`Critical path`}),(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:s?`The spans that decided the duration — values show their own time.`:`Highlight the spans that decided the duration.`})]}),(0,m.jsx)(`div`,{role:`tree`,"aria-label":`Waterfall`,children:i.rows.map(({span:e,depth:t,offsetPct:n,widthPct:i})=>(0,m.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":e.spanId===o?.spanId,"data-span-name":e.name,"data-critical":u.has(e.spanId)?`true`:void 0,onClick:()=>r(e.spanId),className:`grid w-full grid-cols-[minmax(0,2fr)_minmax(0,3fr)_4.5rem] items-center gap-3 border-b px-4 py-2 text-left text-sm last:border-b-0 hover:bg-muted/50 aria-selected:bg-muted ${s&&!u.has(e.spanId)?`opacity-30`:``}`,children:[(0,m.jsxs)(`span`,{className:`truncate`,style:{paddingLeft:t*14},children:[(0,m.jsx)(`span`,{className:e.status===`error`?`font-medium text-destructive`:``,children:Eu(e)}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`span`,{className:`relative h-2.5`,children:(0,m.jsx)(`span`,{className:`absolute top-0 h-2.5 min-w-0.5 rounded-full opacity-80 ${e.status===`error`?`bg-destructive`:ku(e.service,a)}`,style:{left:`${n}%`,width:`${i}%`}})}),(0,m.jsx)(`span`,{className:`text-right font-mono text-xs tabular-nums ${s?`text-warning`:`text-muted-foreground`}`,children:H(s?d.get(e.spanId)??0:e.durationMs)})]},e.spanId))})]}),o&&(0,m.jsx)(Iu,{span:o,selfMs:d.get(o.spanId)})]}),(0,m.jsx)(Kl,{title:`Where the time went`,testId:`panel-self-time`,aside:`own time, without calls to others · % of all own time`,children:(0,m.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`pb-2 font-normal`,children:`Operation`}),(0,m.jsx)(`th`,{className:`w-1/4 pb-2 font-normal`,children:`Self %`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Self`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Total`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Calls`})]})}),(0,m.jsx)(`tbody`,{children:f.map(e=>(0,m.jsxs)(`tr`,{className:`border-t`,"data-testid":`self-time-row`,children:[(0,m.jsxs)(`td`,{className:`max-w-0 truncate py-2 pr-3 font-mono`,children:[(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`hover:text-signal`,children:e.name}),a.length>1&&(0,m.jsx)(`span`,{className:`ml-2 font-sans text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`td`,{className:`py-2 pr-3`,children:(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`h-1.5 flex-1 rounded-full bg-muted`,children:(0,m.jsx)(`span`,{className:`block h-1.5 rounded-full bg-warning/80`,style:{width:`${e.selfShare*100}%`}})}),(0,m.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:[Math.round(e.selfShare*100),`%`]})]})}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono tabular-nums`,children:H(e.selfMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:H(e.totalMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:e.calls})]},`${e.service}:${e.name}`))})]})})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading…`})}var ju=5,Mu=36e5,Nu={slow:{text:`slower than 95% of the calls`,tone:`text-warning`,dot:`bg-warning`},typical:{text:`a typical call`,tone:`text-signal`,dot:`bg-signal`},fast:{text:`faster than half of the calls`,tone:`text-signal`,dot:`bg-signal`}},Pu={text:`a cold start`,tone:`text-muted-foreground`,dot:`bg-muted-foreground`};function Fu({durationMs:e,histogram:t,operation:n,service:r,coldStart:i}){let a=i?Pu:Nu[yl(e,t)],o=Math.max(t.p99Ms,e)*1.05||1,s=e=>`${Math.min(e/o*100,100)}%`;return(0,m.jsxs)(Kl,{title:`Compared to other calls`,testId:`panel-compared`,aside:(0,m.jsxs)(R,{to:`/operation`,search:{name:n,service:r},className:`hover:text-signal`,children:[t.total,` calls · the hour around this one →`]}),children:[(0,m.jsxs)(`div`,{className:`relative mt-5 mb-9 h-1.5 rounded-full bg-muted`,children:[[{label:`median`,ms:t.p50Ms},{label:`p95`,ms:t.p95Ms}].map(e=>(0,m.jsx)(`span`,{className:`absolute -top-5 h-8 border-l border-dashed border-foreground/30`,style:{left:s(e.ms)},children:(0,m.jsxs)(`span`,{className:`absolute -top-0.5 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/o>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`span`,{className:`absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full ring-4 ring-background ${a.dot}`,style:{left:s(e)},"data-testid":`this-call`}),(0,m.jsxs)(`span`,{className:`absolute top-4 -translate-x-1/2 font-mono text-xs whitespace-nowrap ${a.tone}`,style:{left:`clamp(3rem, ${s(e)}, calc(100% - 3rem))`},children:[H(e),` · this call`]})]}),(0,m.jsxs)(`p`,{className:`text-sm`,"data-testid":`standing`,children:[(0,m.jsx)(`span`,{className:a.tone,children:a.text[0].toUpperCase()+a.text.slice(1)}),(0,m.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`— `,i?`it includes compiling the route, so it is not judged against the warm calls.`:`${(e/(t.p50Ms||1)).toFixed(1)}× the median.`]})]})]})}function Iu({span:e,selfMs:t}){let n=[[`service`,e.serviceVersion?`${e.service}@${e.serviceVersion}`:e.service],[`kind`,e.kind],[`duration`,H(e.durationMs)],...t===void 0?[]:[[`own time`,H(t)]],[`status`,e.statusMessage?`${e.status}: ${e.statusMessage}`:e.status],...Object.entries(e.attributes)];return(0,m.jsxs)(Xc,{className:`self-start`,"data-testid":`span-details`,children:[(0,m.jsxs)(Zc,{children:[(0,m.jsxs)(Qc,{className:`flex items-center gap-2 text-base`,children:[Eu(e),e.status===`error`&&(0,m.jsx)(Uc,{variant:`destructive`,children:`error`})]}),(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`font-mono text-xs text-signal underline-offset-2 hover:underline`,"data-testid":`operation-link`,children:`all calls of this operation →`})]}),(0,m.jsxs)($c,{className:`space-y-3`,children:[(0,m.jsx)(`dl`,{children:n.map(([e,t])=>(0,m.jsx)(cu,{label:e,children:typeof t==`string`?t:JSON.stringify(t)},e))}),e.events.map((e,t)=>(0,m.jsxs)(`div`,{className:`rounded-md bg-muted p-2 text-xs`,children:[(0,m.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:String(e.attributes[`exception.message`]??``)})]},t))]})]})}function Lu({className:e,size:t=`default`,...n}){return(0,m.jsx)(wc,{"data-slot":`switch`,"data-size":t,className:ds(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,m.jsx)(Ec,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Ru=2e3,zu=oa(`/traces`);function Bu(){let e=zu.useSearch(),t=Ui({from:`/traces`}),n=e=>t({search:t=>({...t,...e}),replace:!0}),r=nt({queryKey:[`traces`,e],queryFn:()=>Ba.traces(e),refetchInterval:Ru}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Ru});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Traces`,count:r.data?.length,subtitle:`Every request your app made — server and browser, live.`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-9 rounded-md border bg-card px-2 text-sm`,value:e.service??``,onChange:e=>n({service:e.target.value||void 0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.map(e=>(0,m.jsxs)(`option`,{value:e.name,children:[e.name,e.versions.length?` (${e.versions.join(`, `)})`:``]},e.name))]}),(0,m.jsx)(ol,{"aria-label":`Operation`,className:`w-64`,placeholder:`Operation contains…`,defaultValue:e.operation??``,onChange:e=>n({operation:e.target.value||void 0})}),(0,m.jsx)(ol,{"aria-label":`Min duration (ms)`,className:`w-40`,type:`number`,min:0,placeholder:`Min ms`,defaultValue:e.minDurationMs??``,onChange:e=>n({minDurationMs:Number(e.target.value)||void 0})}),(0,m.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,m.jsx)(Lu,{checked:e.hasError??!1,onCheckedChange:e=>n({hasError:e||void 0})}),`Errors only`]}),r.isError&&(0,m.jsx)(`span`,{className:`ml-auto font-mono text-xs text-destructive`,children:`collector unreachable`})]}),(0,m.jsx)(_u,{traces:r.data,empty:(0,m.jsxs)(m.Fragment,{children:[`No traces yet — open your app while `,(0,m.jsx)(`code`,{children:`next-observer dev`}),` is running.`]})})]})}function Vu({to:e,children:t}){return(0,m.jsx)(R,{to:e,activeOptions:{exact:e===`/`,includeSearch:!1},className:`rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground [&.active]:bg-muted [&.active]:text-foreground`,children:t})}var Hu=da({component:()=>(0,m.jsxs)(`div`,{className:`min-h-screen text-foreground`,children:[(0,m.jsx)(`header`,{className:`sticky top-0 z-20 border-b bg-background/70 backdrop-blur-md`,children:(0,m.jsxs)(`div`,{className:`mx-auto flex h-14 max-w-7xl items-center gap-2 px-6`,children:[(0,m.jsxs)(R,{to:`/`,className:`mr-4 flex items-center gap-2 font-semibold tracking-tight`,children:[(0,m.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 rounded-sm bg-signal shadow-[0_0_12px_var(--signal)]`}),`next-observer`]}),(0,m.jsx)(Vu,{to:`/`,children:`Overview`}),(0,m.jsx)(Vu,{to:`/errors`,children:`Errors`}),(0,m.jsx)(Vu,{to:`/traces`,children:`Traces`}),(0,m.jsx)(Vu,{to:`/chat`,children:`Chat`}),(0,m.jsx)(`span`,{className:`ml-auto`,children:(0,m.jsx)(Va,{})})]})}),(0,m.jsx)(Ha,{}),(0,m.jsx)(`main`,{className:`mx-auto max-w-7xl px-6 py-8`,children:(0,m.jsx)(Sa,{})}),(0,m.jsx)(Vc,{})]})}),Uu=la({getParentRoute:()=>Hu,path:`/`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:eu});function Wu(e){let t=e=>typeof e==`string`&&e.trim()?e.trim():void 0,n=Number(e.minDurationMs);return{service:t(e.service),operation:t(e.operation),minDurationMs:Number.isFinite(n)&&n>0?n:void 0,hasError:e.hasError===!0||e.hasError===`true`||void 0}}var Gu=la({getParentRoute:()=>Hu,path:`/traces`,validateSearch:Wu,component:Bu}),Ku=la({getParentRoute:()=>Hu,path:`/traces/$traceId`,component:Au}),qu=la({getParentRoute:()=>Hu,path:`/errors`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:iu}),Ju=la({getParentRoute:()=>Hu,path:`/operation`,validateSearch:e=>({name:typeof e.name==`string`?e.name:``,service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0,window:zl(e.window)}),component:Su}),Yu=la({getParentRoute:()=>Hu,path:`/chat`,validateSearch:e=>({ask:typeof e.ask==`string`&&e.ask.trim()?e.ask.trim():void 0}),component:Il}),Xu=Oa({routeTree:Hu.addChildren([Uu,qu,Gu,Ku,Ju,Yu])}),Zu=new Ue;(0,La.createRoot)(document.getElementById(`root`)).render((0,m.jsx)(p.StrictMode,{children:(0,m.jsx)(_,{client:Zu,children:(0,m.jsx)(ja,{router:Xu})})}));
|
|
17
|
+
`)}function Ml(e){return e.split(/(\*\*[^*\n]+\*\*|`[^`\n]+`)/g).map((e,t)=>e.startsWith(`**`)&&e.endsWith(`**`)&&e.length>4?(0,m.jsx)(`strong`,{children:e.slice(2,-2)},t):e.startsWith("`")&&e.endsWith("`")&&e.length>2?(0,m.jsx)(`code`,{className:`rounded bg-muted px-1 font-mono text-[0.85em]`,children:e.slice(1,-1)},t):(0,m.jsx)(p.Fragment,{children:e},t))}var Nl=[`Checkout is slow. What's causing it and which deployment introduced it?`,`There are 500 errors on product pages. Which operation is failing and why?`,`The product catalog is slower than expected but no single span stands out. What is wrong?`],Pl=oa(`/chat`),Fl=e=>e.type===`report`||e.type===`error`;function Il(){let e=nt({queryKey:[`chat-info`],queryFn:Ba.chatInfo}),t=e.data?.enabled??!1,[n,r]=(0,p.useState)([]),[i,a]=(0,p.useState)(``),[o,s]=(0,p.useState)(),c=n.some(e=>e.running&&!e.proactive),l=(0,p.useRef)(c);l.current=c;let u=(0,p.useRef)(t);u.current=t,(0,p.useEffect)(()=>{let e=0,t=new Map,n=new EventSource(`/api/chat/events`);return n.onmessage=n=>{let{seq:i,turnId:a,event:o}=JSON.parse(n.data);if(i<=e)return;e=i,o.type===`status`&&t.set(a,o.sessionId),r(e=>{let t=e.find(e=>e.id===a),n=t??{id:a,question:o.type===`anomaly`?Gc(o.anomaly):`Anomaly`,events:[],running:u.current,proactive:!0},r={...n,events:[...n.events,o],running:n.running&&!Fl(o)};return t?e.map(e=>e.id===a?r:e):[...e,r]});let c=t.get(a);o.type===`report`&&c&&!l.current&&s(c)},()=>n.close()},[]);async function d(e){let t=`q-${Date.now()}`,n=e=>r(n=>n.map(n=>n.id===t?e(n):n));r(n=>[...n,{id:t,question:e,events:[],running:!0}]),a(``);try{await Ba.ask(e,o,e=>{e.type===`status`&&s(e.sessionId),n(t=>({...t,events:[...t.events,e]}))})}catch(e){n(t=>({...t,events:[...t.events,{type:`error`,message:e instanceof Error?e.message:String(e)}]}))}finally{n(e=>({...e,running:!1}))}}let{ask:f}=Pl.useSearch(),h=Ui({from:`/chat`}),g=(0,p.useRef)(void 0);(0,p.useEffect)(()=>{f&&t&&g.current!==f&&(g.current=f,h({search:{},replace:!0}),d(f))},[f,t]);function _(){r([]),s(void 0)}function v(e){e.preventDefault(),i.trim()&&!c&&d(i.trim())}let y=n.map(e=>(0,m.jsx)(Ll,{turn:e},e.id));return e.data&&!e.data.enabled?(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-4`,children:[(0,m.jsx)(Xc,{"data-testid":`chat-disabled`,children:(0,m.jsxs)($c,{className:`space-y-2 text-sm`,children:[(0,m.jsx)(`p`,{className:`font-medium`,children:`Chat is disabled`}),(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:e.data.reason})]})}),y]}):(0,m.jsxs)(`div`,{className:`mx-auto max-w-3xl space-y-6`,children:[(0,m.jsxs)(sl,{title:`Ask the agents`,subtitle:`They read your traces with tools — every fact comes from the data.`,children:[e.data?.enabled&&(0,m.jsx)(Uc,{variant:e.data.mode===`mock`?`outline`:`secondary`,className:`font-mono`,"data-testid":`chat-mode`,children:e.data.mode===`mock`?`MOCK — no real model`:`REAL model`}),n.length>0&&(0,m.jsx)(Mc,{type:`button`,variant:`ghost`,size:`sm`,onClick:_,disabled:c,children:`New chat`})]}),n.length===0&&(0,m.jsx)(`div`,{className:`flex flex-col items-start gap-2`,children:Nl.map(e=>(0,m.jsx)(Mc,{type:`button`,variant:`outline`,size:`sm`,className:`h-auto whitespace-normal py-2 text-left font-normal`,onClick:()=>void d(e),disabled:c,children:e},e))}),y,(0,m.jsxs)(`form`,{onSubmit:v,className:`flex gap-2`,children:[(0,m.jsx)(ol,{"aria-label":`Question`,placeholder:`Why is checkout slow?`,value:i,onChange:e=>a(e.target.value),disabled:c}),(0,m.jsx)(Mc,{type:`submit`,disabled:c||!i.trim(),children:c?`Investigating…`:`Ask`})]})]})}function Ll({turn:e}){let t=e.events.find(e=>e.type===`anomaly`),n=e.events.filter(e=>e.type===`step`),r=e.events.flatMap(e=>e.type===`card`?[e.card]:[]),i=e.events.find(e=>e.type===`report`),a=e.events.find(e=>e.type===`error`),o=n.length>0||r.length>0||i||a||e.running;return(0,m.jsxs)(`div`,{className:`space-y-2`,"data-testid":`chat-turn`,"data-proactive":e.proactive?`true`:void 0,children:[t?(0,m.jsx)(qc,{anomaly:t.anomaly}):(0,m.jsx)(`div`,{className:`ml-auto w-fit max-w-[80%] rounded-2xl rounded-br-sm bg-primary px-3.5 py-2 text-sm text-primary-foreground`,children:e.question}),o&&(0,m.jsx)(Xc,{children:(0,m.jsxs)($c,{className:`space-y-3 text-sm`,children:[(0,m.jsxs)(`ol`,{className:`space-y-1 font-mono text-xs text-muted-foreground`,"data-testid":`chat-steps`,children:[n.map((e,t)=>(0,m.jsxs)(`li`,{children:[(0,m.jsxs)(`span`,{className:e.agent===`orchestrator`?`text-foreground`:`pl-4`,children:[e.agent,` → `,e.tool]}),Object.keys(e.args).length>0&&(0,m.jsx)(`span`,{className:`ml-1 opacity-70`,children:JSON.stringify(e.args).slice(0,120)})]},t)),e.running&&(0,m.jsx)(`li`,{className:`animate-pulse`,children:e.proactive?`agents are investigating on their own…`:`working…`})]}),r.length>0&&(0,m.jsx)(`div`,{className:`grid gap-2 sm:grid-cols-2`,"data-testid":`chat-cards`,children:r.map((e,t)=>(0,m.jsx)(al,{card:e},t))}),i&&(0,m.jsx)(`p`,{className:`whitespace-pre-wrap leading-relaxed [overflow-wrap:anywhere]`,"data-testid":`chat-report`,children:Ml(i.text)}),i&&(0,m.jsx)(`div`,{className:`flex justify-end`,children:(0,m.jsx)(Yc,{build:()=>jl(e.question,i.text,r)})}),a&&(0,m.jsx)(`p`,{className:`text-destructive`,"data-testid":`chat-error`,children:a.message})]})})]})}var Rl={"5m":3e5,"15m":9e5,"1h":36e5,"24h":864e5},zl=e=>typeof e==`string`&&e in Rl?e:void 0;function Bl({value:e,onChange:t}){return(0,m.jsx)(`div`,{className:`flex overflow-hidden rounded-md border`,role:`group`,"aria-label":`Time window`,children:Object.keys(Rl).map(n=>(0,m.jsx)(`button`,{type:`button`,"aria-pressed":n===e,onClick:()=>t(n===`15m`?void 0:n),className:`border-l px-3 py-1 font-mono text-xs text-muted-foreground uppercase first:border-l-0 hover:text-foreground aria-pressed:bg-muted aria-pressed:text-foreground`,children:n},n))})}var Vl=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`,second:`2-digit`});function Hl({series:e}){let t=Math.max(1,...e.map(e=>e.ok+e.clientErrors+e.serverErrors));return(0,m.jsx)(`div`,{className:`flex h-40 items-end gap-1`,role:`img`,"aria-label":`Requests over time`,children:e.map(e=>{let n=e.ok+e.clientErrors+e.serverErrors;return(0,m.jsxs)(`div`,{className:`flex h-full flex-1 flex-col justify-end`,title:`${Vl(e.startMs)} · ${n} requests · ${e.clientErrors} 4xx · ${e.serverErrors} 5xx`,"data-testid":`requests-bucket`,children:[(0,m.jsx)(Ul,{value:e.serverErrors,max:t,tone:`bg-destructive`}),(0,m.jsx)(Ul,{value:e.clientErrors,max:t,tone:`bg-warning`}),(0,m.jsx)(Ul,{value:e.ok,max:t,tone:`bg-foreground/25`}),n===0&&(0,m.jsx)(`span`,{className:`h-px bg-foreground/10`})]},e.startMs)})})}function Ul({value:e,max:t,tone:n}){return e===0?null:(0,m.jsx)(`span`,{className:`block min-h-0.5 rounded-[2px] ${n}`,style:{height:`${e/t*100}%`}})}function Wl({series:e}){let t=Math.max(1,...e.map(e=>e.p95Ms??0))*1.15,n=t=>(t+.5)/e.length*100,r=e=>100-e/t*100,i=[];e.forEach((e,t)=>{if(e.p95Ms===null||e.avgMs===null)return i.push([]);i.length===0&&i.push([]),i[i.length-1].push({i:t,avg:e.avgMs,p95:e.p95Ms})});let a=i.filter(e=>e.length>0);return(0,m.jsxs)(`div`,{className:`relative h-40`,children:[(0,m.jsxs)(`svg`,{viewBox:`0 0 100 100`,preserveAspectRatio:`none`,className:`h-full w-full overflow-visible`,role:`img`,"aria-label":`Duration over time`,children:[[25,50,75].map(e=>(0,m.jsx)(`line`,{x1:`0`,x2:`100`,y1:e,y2:e,className:`stroke-foreground/10`,strokeDasharray:`1 1.5`,vectorEffect:`non-scaling-stroke`},e)),a.map(t=>{let i=t.map(e=>`${n(e.i)},${r(e.p95)}`),a=t.length===1?[`${n(t[0].i)-50/e.length},${r(t[0].p95)}`,`${n(t[0].i)+50/e.length},${r(t[0].p95)}`]:i,o=a[0].split(`,`)[0],s=a[a.length-1].split(`,`)[0];return(0,m.jsxs)(`g`,{children:[(0,m.jsx)(`polygon`,{points:`${o},100 ${a.join(` `)} ${s},100`,className:`fill-chart-1/15`}),(0,m.jsx)(`polyline`,{points:a.join(` `),fill:`none`,className:`stroke-chart-1`,strokeWidth:`1.5`,vectorEffect:`non-scaling-stroke`}),(0,m.jsx)(`polyline`,{points:t.length===1?a.map(e=>`${e.split(`,`)[0]},${r(t[0].avg)}`).join(` `):t.map(e=>`${n(e.i)},${r(e.avg)}`).join(` `),fill:`none`,className:`stroke-foreground/50`,strokeWidth:`1`,strokeDasharray:`2 2`,vectorEffect:`non-scaling-stroke`})]},t[0].i)})]}),(0,m.jsx)(`span`,{className:`absolute top-0 left-0 font-mono text-[11px] text-muted-foreground`,children:H(t)})]})}function Gl({rows:e,value:t,meta:n,empty:r}){return e.length===0?(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:r}):(0,m.jsx)(`ul`,{className:`-my-1 divide-y`,children:e.map(e=>{let[r,...i]=e.operation.split(` `),a=i.length>0&&/^[A-Z]+$/.test(r);return(0,m.jsx)(`li`,{children:(0,m.jsxs)(R,{to:`/operation`,search:{name:e.operation,service:e.service},className:`group flex items-center gap-3 py-2.5`,"data-testid":`route-row`,children:[a&&(0,m.jsx)(`span`,{className:`rounded bg-muted px-1.5 py-0.5 font-mono text-[10px] tracking-wider text-muted-foreground`,children:r}),(0,m.jsx)(`span`,{className:`min-w-0 flex-1 truncate font-mono text-sm group-hover:text-signal`,children:a?i.join(` `):e.operation}),(0,m.jsxs)(`span`,{className:`text-right`,children:[(0,m.jsx)(`span`,{className:`block font-mono text-sm tabular-nums`,children:t(e)}),(0,m.jsx)(`span`,{className:`block font-mono text-[11px] text-muted-foreground`,children:n(e)})]})]})},`${e.service}:${e.operation}`)})})}function Kl({title:e,count:t,change:n,children:r,aside:i,testId:a}){return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":a,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-3 gap-y-1 border-b px-5 py-3.5`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:e}),t!==void 0&&(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-xs tabular-nums`,children:t}),n,i&&(0,m.jsx)(`div`,{className:`ml-auto flex items-center gap-3 font-mono text-xs text-muted-foreground`,children:i})]}),(0,m.jsx)(`div`,{className:`px-5 py-4`,children:r})]})}function ql({value:e,upIsBad:t}){if(e===null)return null;let n=Math.round(e*100),r=n>0,i=n===0||t===void 0?`text-muted-foreground`:r===t?`text-destructive`:`text-signal`,a=r?po:uo;return(0,m.jsxs)(`span`,{className:`flex items-center gap-1 text-xs ${i}`,"data-testid":`change`,children:[n!==0&&(0,m.jsx)(a,{className:`size-3.5`,"aria-hidden":!0}),r?`+`:``,n,`% `,(0,m.jsx)(`span`,{className:`text-muted-foreground`,children:`since last period`})]})}function Jl({tone:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[(0,m.jsx)(`span`,{className:`h-3 w-0.5 rounded-full ${e}`,"aria-hidden":!0}),t]})}function Yl({label:e,children:t}){return(0,m.jsxs)(`span`,{className:`flex items-center gap-1.5`,children:[e,(0,m.jsx)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 text-foreground tabular-nums`,children:t})]})}function Xl({fromMs:e,toMs:t}){let n=e=>new Date(e).toLocaleTimeString([],{hour:`2-digit`,minute:`2-digit`});return(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:n(e)}),(0,m.jsx)(`span`,{children:n(t)})]})}var Zl=2e3,Ql=oa(`/`),$l=e=>`${Math.round(e*100)}%`;function eu(){let{window:e=`15m`,service:t}=Ql.useSearch(),n=Ui({from:`/`}),r=nt({queryKey:[`overview`,e,t],queryFn:()=>Ba.overview(Rl[e],t),refetchInterval:Zl}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Zl}),a=r.data;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(sl,{title:`Overview`,subtitle:`Your app's requests, latency and errors — compared with the period before.`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-8 rounded-md border bg-card px-2 text-sm`,value:t??``,onChange:e=>n({search:t=>({...t,service:e.target.value||void 0}),replace:!0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.filter(e=>!e.name.endsWith(`-browser`)).map(e=>(0,m.jsx)(`option`,{value:e.name,children:e.name},e.name))]}),(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})]}),a?(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Requests`,testId:`panel-requests`,count:a.requests.total,change:(0,m.jsx)(ql,{value:a.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`span`,{className:`tabular-nums`,children:[a.requests.perSecond,`/s`]}),(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`2/3xx`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`5xx`})]}),children:[(0,m.jsx)(Hl,{series:a.requests.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:a.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:a.duration.avgMs===null?`—`:H(a.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:a.duration.p95Ms===null?`—`:H(a.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:a.duration.series}),(0,m.jsx)(Xl,{fromMs:a.fromMs,toMs:a.toMs})]})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-3`,children:[(0,m.jsxs)(Kl,{title:`Errors`,testId:`panel-errors`,count:a.errors.count,change:(0,m.jsx)(ql,{value:a.errors.change,upIsBad:!0}),aside:(0,m.jsx)(R,{to:`/errors`,search:{window:e===`15m`?void 0:e,service:t},className:`hover:text-signal`,children:`view all →`}),children:[(0,m.jsxs)(`div`,{className:`space-y-1`,children:[(0,m.jsx)(`div`,{className:`font-mono text-4xl font-medium tabular-nums ${a.errors.count>0?`text-destructive`:``}`,"data-testid":`error-rate`,children:$l(a.errors.rate)}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`of requests failed with 5xx`})]}),(0,m.jsx)(`div`,{className:`mt-4 flex h-12 items-end gap-0.5`,"aria-hidden":!0,children:a.requests.series.map(e=>{let t=Math.max(1,...a.requests.series.map(e=>e.serverErrors));return(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e.serverErrors?`bg-destructive`:`bg-foreground/10`}`,style:{height:e.serverErrors?`${e.serverErrors/t*100}%`:`2px`}},e.startMs)})})]}),(0,m.jsx)(Kl,{title:`Slowest`,testId:`panel-slowest`,aside:`P95`,children:(0,m.jsx)(Gl,{rows:a.slowest,value:e=>H(e.p95Ms),meta:e=>`${e.count} ${e.count===1?`call`:`calls`}${e.errorRate>0?` · ${$l(e.errorRate)} errors`:``}${e.coldOnly?` · cold start only`:``}`,empty:`No requests in this window.`})}),(0,m.jsx)(Kl,{title:`Busiest`,testId:`panel-busiest`,aside:`CALLS`,children:(0,m.jsx)(Gl,{rows:a.busiest,value:e=>String(e.count),meta:e=>`${$l(e.share)} of requests`,empty:`No requests in this window.`})})]})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}var tu=2e3,nu=oa(`/errors`);function ru(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function iu(){let{window:e=`15m`,service:t}=nu.useSearch(),n=Ui({from:`/errors`}),r=nt({queryKey:[`defects`,e,t],queryFn:()=>Ba.defects(Rl[e],t),refetchInterval:tu});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Errors`,count:r.data?.length,subtitle:`Failures grouped by where they start and what they say — one entry per defect, not per request.`,children:(0,m.jsx)(Bl,{value:e,onChange:e=>n({search:t=>({...t,window:e}),replace:!0})})}),r.data?r.data.length===0?(0,m.jsxs)(Xc,{className:`items-center py-12 text-center`,"data-testid":`errors-empty`,children:[(0,m.jsxs)(`p`,{className:`font-medium`,children:[`No errors in the last `,e]}),(0,m.jsx)(`p`,{className:`text-sm text-muted-foreground`,children:`A defect shows up here as soon as a span fails.`})]}):(0,m.jsx)(`div`,{className:`space-y-4`,children:r.data.map(e=>(0,m.jsx)(au,{defect:e},e.id))}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:r.isError?`The observer is not reachable.`:`Loading…`})]})}function au({defect:e}){let t=Ui(),n=Math.max(1,...e.series),r=ul(e);return(0,m.jsxs)(Xc,{className:`gap-0 py-0`,"data-testid":`defect`,"data-new":e.isNew?`true`:void 0,children:[(0,m.jsxs)(`div`,{className:`grid gap-x-6 gap-y-4 px-5 py-4 lg:grid-cols-[minmax(0,1fr)_14rem]`,children:[(0,m.jsxs)(`div`,{className:`min-w-0 space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-2`,children:[e.isNew?(0,m.jsxs)(`span`,{className:`rounded-md bg-warning/15 px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-warning uppercase`,"data-testid":`defect-new`,children:[`new in `,e.firstSeenVersion]}):e.versions.length>0&&(0,m.jsxs)(`span`,{className:`rounded-md bg-muted px-1.5 py-0.5 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[`seen in `,e.versions.join(`, `)]}),(0,m.jsx)(`span`,{className:`rounded-md border px-1.5 py-0.5 font-mono text-[11px] tracking-wider uppercase ${e.source===`browser`?`border-signal/40 text-signal`:`text-muted-foreground`}`,"data-testid":`defect-source`,children:e.source}),e.type&&(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:e.type})]}),(0,m.jsx)(`p`,{className:`font-mono text-sm break-words whitespace-pre-wrap text-destructive`,"data-testid":`defect-message`,children:e.message}),(0,m.jsxs)(`p`,{className:`text-sm text-muted-foreground`,"data-testid":`defect-where`,children:[e.category===`code`?(0,m.jsxs)(m.Fragment,{children:[`in`,` `,(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground underline decoration-dotted underline-offset-4 hover:text-signal`,children:e.operation})]}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation}),e.pages.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· on`,` `,e.pages.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.path})]},e.path))]}),r.length>0&&(0,m.jsxs)(m.Fragment,{children:[` `,`· fails`,` `,r.map((e,t)=>(0,m.jsxs)(`span`,{children:[t>0&&`, `,e.spanName===e.operation?(0,m.jsx)(R,{to:`/operation`,search:{name:e.spanName,service:e.service},className:`font-mono text-foreground hover:text-signal`,children:e.operation}):(0,m.jsx)(`span`,{className:`font-mono text-foreground`,children:e.operation})]},`${e.service}:${e.spanName}:${e.operation}`))]})]})]}),(0,m.jsxs)(`div`,{className:`space-y-2`,children:[(0,m.jsxs)(`div`,{className:`flex items-baseline justify-between`,children:[(0,m.jsx)(`span`,{className:`font-mono text-2xl font-medium tabular-nums`,"data-testid":`defect-count`,children:e.count}),(0,m.jsx)(`span`,{className:`font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:e.count===1?`occurrence`:`occurrences`})]}),(0,m.jsx)(`div`,{className:`flex h-8 items-end gap-0.5`,"aria-hidden":!0,children:e.series.map((e,t)=>(0,m.jsx)(`span`,{className:`flex-1 rounded-[2px] ${e?`bg-destructive`:`bg-foreground/10`}`,style:{height:e?`${Math.max(e/n*100,12)}%`:`2px`}},t))})]})]}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-x-5 gap-y-2 border-t px-5 py-2.5 font-mono text-xs text-muted-foreground`,children:[(0,m.jsxs)(`span`,{children:[`first seen `,ru(e.firstSeenMs)]}),(0,m.jsxs)(`span`,{children:[`last seen `,ru(e.lastSeenMs)]}),(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[`traces`,e.exampleTraceIds.map(e=>(0,m.jsxs)(R,{to:`/traces/$traceId`,params:{traceId:e},className:`text-signal underline-offset-2 hover:underline`,children:[e.slice(0,6),`…`,e.slice(-4)]},e))]}),(0,m.jsx)(Yc,{build:()=>kl(e),className:`ml-auto font-sans`}),(0,m.jsx)(Mc,{type:`button`,size:`sm`,variant:`outline`,className:`font-sans`,"data-testid":`defect-investigate`,onClick:()=>void t({to:`/chat`,search:{ask:fl(e)}}),children:`Investigate`})]})]})}function W(e,t,n=.06){let r=[{label:`median`,ms:e.p50Ms},{label:`p95`,ms:e.p95Ms},{label:`p99`,ms:e.p99Ms}],i=[];for(let e of r)(i.length===0||(e.ms-i[i.length-1].ms)/t>n)&&i.push(e);return i}var ou=e=>`${Math.round(e*100)}%`;function su({histogram:e,speeds:t}){let n=e.bins[e.bins.length-1].toMs||1,r=Math.max(1,...e.bins.map(e=>e.count)),i=W(e,n);return(0,m.jsxs)(`div`,{"data-testid":`latency-histogram`,children:[(0,m.jsxs)(`div`,{className:`relative mt-6 h-40`,children:[i.map(e=>(0,m.jsx)(`div`,{className:`absolute -top-6 bottom-0 border-l border-dashed border-foreground/30`,style:{left:`${Math.min(e.ms/n*100,100)}%`},children:(0,m.jsxs)(`span`,{className:`absolute top-0 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/n>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`div`,{className:`flex h-full items-end gap-0.5`,role:`img`,"aria-label":`Latency distribution`,children:e.bins.map((t,n)=>(0,m.jsx)(`span`,{"data-testid":`histogram-bin`,title:`${H(t.fromMs)} – ${n===e.bins.length-1&&e.overflow?`and slower`:H(t.toMs)} · ${t.count} calls (${ou(t.count/e.total)})`,className:`flex-1 rounded-t-[2px] ${t.count?`bg-chart-1/70`:`bg-foreground/10`}`,style:{height:t.count?`${Math.max(t.count/r*100,2)}%`:`1px`}},n))})]}),(0,m.jsxs)(`div`,{className:`mt-2 flex justify-between font-mono text-[11px] text-muted-foreground`,children:[(0,m.jsx)(`span`,{children:`0`}),(0,m.jsx)(`span`,{children:H(n/2)}),(0,m.jsxs)(`span`,{children:[e.overflow?`≥ `:``,H(n)]})]}),t&&(0,m.jsxs)(`p`,{className:`mt-3 font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,"data-testid":`two-speeds`,children:[(0,m.jsx)(`span`,{className:`text-warning`,children:`Two speeds`}),` · `,H(t[0].medianMs),` (`,ou(t[0].share),`) and `,H(t[1].medianMs),` (`,ou(t[1].share),`) ·`,` `,Math.round(t[1].medianMs/t[0].medianMs),`× apart`]})]})}function cu({label:e,children:t}){return(0,m.jsxs)(`div`,{className:`flex items-baseline gap-2 py-1 text-xs`,children:[(0,m.jsxs)(`dt`,{className:`flex min-w-0 flex-1 items-baseline gap-2 text-muted-foreground`,children:[(0,m.jsx)(`span`,{className:`shrink-0`,children:e}),(0,m.jsx)(`span`,{"aria-hidden":!0,className:`min-w-4 flex-1 border-b border-dotted border-foreground/20`})]}),(0,m.jsx)(`dd`,{className:`min-w-0 max-w-[70%] break-all text-right font-mono`,children:t})]})}var lu=`The first request of this route after the server started. In next dev it includes compiling the route, so it is slower than the rest — the agents leave it out of latency statistics.`;function uu(){return(0,m.jsx)(Uc,{variant:`outline`,title:lu,className:`ml-2 cursor-help font-normal text-muted-foreground`,children:`cold start`})}function du({className:e,...t}){return(0,m.jsx)(`div`,{"data-slot":`table-container`,className:`relative w-full overflow-x-auto`,children:(0,m.jsx)(`table`,{"data-slot":`table`,className:ds(`w-full caption-bottom text-sm`,e),...t})})}function fu({className:e,...t}){return(0,m.jsx)(`thead`,{"data-slot":`table-header`,className:ds(`[&_tr]:border-b`,e),...t})}function pu({className:e,...t}){return(0,m.jsx)(`tbody`,{"data-slot":`table-body`,className:ds(`[&_tr:last-child]:border-0`,e),...t})}function mu({className:e,...t}){return(0,m.jsx)(`tr`,{"data-slot":`table-row`,className:ds(`border-b transition-colors hover:bg-muted/50 has-aria-expanded:bg-muted/50 data-[state=selected]:bg-muted`,e),...t})}function hu({className:e,...t}){return(0,m.jsx)(`th`,{"data-slot":`table-head`,className:ds(`h-10 px-2 text-left align-middle font-mono text-[11px] font-normal tracking-wider whitespace-nowrap text-muted-foreground uppercase [&:has([role=checkbox])]:pr-0`,e),...t})}function gu({className:e,...t}){return(0,m.jsx)(`td`,{"data-slot":`table-cell`,className:ds(`p-2 align-middle whitespace-nowrap [&:has([role=checkbox])]:pr-0`,e),...t})}function _u({traces:e,empty:t}){return(0,m.jsx)(Xc,{className:`py-0`,children:(0,m.jsxs)(du,{children:[(0,m.jsx)(fu,{children:(0,m.jsxs)(mu,{children:[(0,m.jsx)(hu,{className:`pl-4`,children:`Trace`}),(0,m.jsx)(hu,{children:`Services`}),(0,m.jsx)(hu,{className:`text-right`,children:`Duration`}),(0,m.jsx)(hu,{className:`text-right`,children:`Spans`}),(0,m.jsx)(hu,{className:`text-right`,children:`Errors`}),(0,m.jsx)(hu,{className:`pr-4 text-right`,children:`Started`})]})}),(0,m.jsxs)(pu,{children:[e?.map(e=>(0,m.jsxs)(mu,{"data-testid":`trace-row`,children:[(0,m.jsxs)(gu,{className:`pl-4`,children:[(0,m.jsx)(R,{to:`/traces/$traceId`,params:{traceId:e.traceId},className:`font-medium hover:underline`,children:e.rootName}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`div`,{className:`font-mono text-xs text-muted-foreground`,children:e.traceId.slice(0,16)})]}),(0,m.jsx)(gu,{className:`space-x-1`,children:e.services.map(e=>(0,m.jsx)(Uc,{variant:`secondary`,children:e},e))}),(0,m.jsx)(gu,{className:`text-right font-mono tabular-nums`,children:H(e.durationMs)}),(0,m.jsx)(gu,{className:`text-right font-mono text-muted-foreground tabular-nums`,children:e.spanCount}),(0,m.jsx)(gu,{className:`text-right`,children:e.errorCount>0?(0,m.jsx)(Uc,{variant:`destructive`,children:e.errorCount}):`—`}),(0,m.jsx)(gu,{className:`pr-4 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:new Date(e.startTimeMs).toLocaleTimeString()})]},e.traceId)),e?.length===0&&(0,m.jsx)(mu,{children:(0,m.jsx)(gu,{colSpan:6,className:`py-10 text-center text-muted-foreground`,children:t})})]})]})})}var vu=2e3,yu=oa(`/operation`),bu=e=>`${Math.round(e*100)}%`,G=e=>e==null?`—`:H(e);function xu(e){let t=Math.max(0,Math.round((Date.now()-e)/1e3));return t<60?`${t}s ago`:t<3600?`${Math.round(t/60)} min ago`:`${Math.round(t/3600)} h ago`}function Su(){let{name:e,service:t,window:n=`15m`}=yu.useSearch(),r=Ui({from:`/operation`}),i=nt({queryKey:[`operation`,e,t,n],queryFn:()=>Ba.operation(e,Rl[n],t),refetchInterval:vu,enabled:e!==``}),a=i.data,o=a?.overview.fromMs,s=nt({queryKey:[`operation-traces`,e,t,o],queryFn:()=>Ba.traces({operation:e,exactOperation:!0,service:t,fromMs:o,limit:50}),enabled:e!==``&&o!==void 0,placeholderData:e=>e});if(e===``)return(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`No operation selected — pick one on the Overview.`});let c=a?.overview;return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← overview`}),(0,m.jsx)(sl,{title:(0,m.jsx)(`span`,{className:`font-mono text-xl`,children:e}),subtitle:a?.service?`One operation of ${a.service} — its traffic, latency and every call.`:`One operation — its traffic, latency and every call.`,children:(0,m.jsx)(Bl,{value:n,onChange:e=>r({search:t=>({...t,window:e}),replace:!0})})})]}),!a||!c?(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:i.isError?`The observer is not reachable.`:`Loading…`}):c.requests.total===0?(0,m.jsxs)(`p`,{className:`text-muted-foreground`,"data-testid":`operation-empty`,children:[`No calls of this operation in the last `,n,`. Try a longer window.`]}):(0,m.jsxs)(m.Fragment,{children:[(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Details`,testId:`panel-details`,children:[(0,m.jsxs)(`dl`,{children:[(0,m.jsx)(cu,{label:`Calls`,children:c.requests.total}),(0,m.jsx)(cu,{label:`Avg duration`,children:G(c.duration.avgMs)}),(0,m.jsx)(cu,{label:`Median`,children:G(a.histogram?.p50Ms)}),(0,m.jsx)(cu,{label:`95th percentile`,children:G(c.duration.p95Ms)}),(0,m.jsx)(cu,{label:`Errors`,children:(0,m.jsxs)(`span`,{className:c.errors.count?`text-destructive`:``,children:[c.errors.count,` (`,bu(c.errors.rate),`)`]})}),a.coldStarts>0&&(0,m.jsx)(cu,{label:`Cold starts (not in latency)`,children:a.coldStarts}),(0,m.jsx)(cu,{label:`Last call`,children:a.lastSeenMs===null?`—`:xu(a.lastSeenMs)})]}),a.versions.length>1&&(0,m.jsxs)(`table`,{className:`mt-4 w-full font-mono text-xs`,"data-testid":`versions`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`py-1 font-normal`,children:`Version`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Calls`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Median`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`P95`}),(0,m.jsx)(`th`,{className:`py-1 text-right font-normal`,children:`Errors`})]})}),(0,m.jsx)(`tbody`,{children:a.versions.map(e=>(0,m.jsxs)(`tr`,{className:`border-t tabular-nums`,children:[(0,m.jsx)(`td`,{className:`py-1.5`,children:e.version}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:e.count}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p50Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right`,children:H(e.p95Ms)}),(0,m.jsx)(`td`,{className:`py-1.5 text-right ${e.errorRate>0?`text-destructive`:``}`,children:bu(e.errorRate)})]},e.version))})]})]}),(0,m.jsx)(Kl,{title:`Latency distribution`,testId:`panel-distribution`,aside:a.histogram?`${a.histogram.total} calls`:void 0,children:a.histogram?(0,m.jsx)(su,{histogram:a.histogram,speeds:a.speeds}):(0,m.jsx)(`p`,{className:`py-6 text-center text-sm text-muted-foreground`,children:`Only cold starts so far — no representative latency yet.`})})]}),(0,m.jsxs)(`div`,{className:`grid gap-4 lg:grid-cols-2`,children:[(0,m.jsxs)(Kl,{title:`Calls`,testId:`panel-requests`,count:c.requests.total,change:(0,m.jsx)(ql,{value:c.requests.change}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Jl,{tone:`bg-foreground/40`,children:`ok`}),(0,m.jsx)(Jl,{tone:`bg-warning`,children:`4xx`}),(0,m.jsx)(Jl,{tone:`bg-destructive`,children:`failed`})]}),children:[(0,m.jsx)(Hl,{series:c.requests.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]}),(0,m.jsxs)(Kl,{title:`Duration`,testId:`panel-duration`,change:(0,m.jsx)(ql,{value:c.duration.change,upIsBad:!0}),aside:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(Yl,{label:`AVG`,children:G(c.duration.avgMs)}),(0,m.jsx)(Yl,{label:`P95`,children:G(c.duration.p95Ms)})]}),children:[(0,m.jsx)(Wl,{series:c.duration.series}),(0,m.jsx)(Xl,{fromMs:c.fromMs,toMs:c.toMs})]})]}),(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(`h2`,{className:`font-medium`,children:`Traces with this operation`}),(0,m.jsx)(_u,{traces:s.data,empty:`No traces in this window.`})]})]})]})}var Cu=/^(GET|HEAD|POST|PUT|PATCH|DELETE|OPTIONS)$/,wu=e=>e.kind===`client`&&Cu.test(e.name);function Tu(e){if(!wu(e))return;let t=e.attributes[`url.full`]??e.attributes[`http.url`];if(typeof t==`string`)try{return{method:e.name,pathname:new URL(t).pathname}}catch{return}}function Eu(e){let t=Tu(e);return t?`${t.method} ${t.pathname}`:e.name}var Du=oa(`/traces/$traceId`),Ou=[`bg-chart-1`,`bg-chart-2`,`bg-chart-4`,`bg-chart-3`,`bg-chart-5`];function ku(e,t){return Ou[t.indexOf(e)%Ou.length]}function Au(){let{traceId:e}=Du.useParams(),t=nt({queryKey:[`trace`,e],queryFn:()=>Ba.trace(e)}),[n,r]=(0,p.useState)(null),i=(0,p.useMemo)(()=>Pc(t.data?.spans??[]),[t.data]),a=(0,p.useMemo)(()=>[...new Set(i.rows.map(e=>e.span.service))],[i]),o=i.rows.find(e=>e.span.spanId===n)?.span??i.rows[0]?.span,[s,c]=(0,p.useState)(!1),l=t.data?.spans,u=(0,p.useMemo)(()=>vl(l??[]),[l]),d=(0,p.useMemo)(()=>gl(l??[]),[l]),f=(0,p.useMemo)(()=>U(l??[]),[l]),h=(0,p.useMemo)(()=>_l(l??[]),[l]),g=nt({queryKey:[`trace-operation`,h?.service,h?.name,h?.startTimeMs],queryFn:()=>Ba.operation(h.name,Mu,h.service,h.startTimeMs+Mu/2),enabled:h!==void 0});return t.isError?(0,m.jsxs)(`p`,{className:`text-destructive`,children:[`Trace `,e,` not found.`]}):t.data?(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsxs)(`div`,{className:`space-y-3`,children:[(0,m.jsx)(R,{to:`/traces`,className:`font-mono text-xs text-muted-foreground hover:text-foreground`,children:`← traces`}),(0,m.jsx)(sl,{title:(0,m.jsxs)(m.Fragment,{children:[i.rows[0]?Eu(i.rows[0].span):``,t.data.spans.some(e=>e.coldStart)&&(0,m.jsx)(uu,{})]}),subtitle:(0,m.jsxs)(m.Fragment,{children:[(0,m.jsx)(`span`,{className:`text-foreground tabular-nums`,children:H(i.durationMs)}),` · `,i.rows.length,` spans · `,e]}),children:(0,m.jsx)(Yc,{build:()=>{let n=g.data?.histogram;return Ol({traceId:e,spans:t.data.spans,usual:n&&n.total>=ju?{p50Ms:n.p50Ms,p95Ms:n.p95Ms,calls:n.total}:void 0})}})})]}),h&&g.data?.histogram&&g.data.histogram.total>=ju&&(0,m.jsx)(Fu,{durationMs:h.durationMs,histogram:g.data.histogram,operation:h.name,service:h.service,coldStart:h.coldStart===!0}),(0,m.jsxs)(`div`,{className:`grid grid-cols-[1fr_380px] gap-4`,children:[(0,m.jsxs)(Xc,{className:`gap-0 self-start py-0`,children:[(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3 border-b px-4 py-2.5`,children:[(0,m.jsx)(`button`,{type:`button`,"aria-pressed":s,"data-testid":`critical-path-toggle`,onClick:()=>c(e=>!e),className:`rounded-full border px-3 py-1 font-mono text-[11px] tracking-wider text-muted-foreground uppercase hover:text-foreground aria-pressed:border-warning/60 aria-pressed:bg-warning/10 aria-pressed:text-warning`,children:`Critical path`}),(0,m.jsx)(`span`,{className:`font-mono text-xs text-muted-foreground`,children:s?`The spans that decided the duration — values show their own time.`:`Highlight the spans that decided the duration.`})]}),(0,m.jsx)(`div`,{role:`tree`,"aria-label":`Waterfall`,children:i.rows.map(({span:e,depth:t,offsetPct:n,widthPct:i})=>(0,m.jsxs)(`button`,{type:`button`,role:`treeitem`,"aria-level":t+1,"aria-selected":e.spanId===o?.spanId,"data-span-name":e.name,"data-critical":u.has(e.spanId)?`true`:void 0,onClick:()=>r(e.spanId),className:`grid w-full grid-cols-[minmax(0,2fr)_minmax(0,3fr)_4.5rem] items-center gap-3 border-b px-4 py-2 text-left text-sm last:border-b-0 hover:bg-muted/50 aria-selected:bg-muted ${s&&!u.has(e.spanId)?`opacity-30`:``}`,children:[(0,m.jsxs)(`span`,{className:`truncate`,style:{paddingLeft:t*14},children:[(0,m.jsx)(`span`,{className:e.status===`error`?`font-medium text-destructive`:``,children:Eu(e)}),e.coldStart&&(0,m.jsx)(uu,{}),(0,m.jsx)(`span`,{className:`ml-2 text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`span`,{className:`relative h-2.5`,children:(0,m.jsx)(`span`,{className:`absolute top-0 h-2.5 min-w-0.5 rounded-full opacity-80 ${e.status===`error`?`bg-destructive`:ku(e.service,a)}`,style:{left:`${n}%`,width:`${i}%`}})}),(0,m.jsx)(`span`,{className:`text-right font-mono text-xs tabular-nums ${s?`text-warning`:`text-muted-foreground`}`,children:H(s?d.get(e.spanId)??0:e.durationMs)})]},e.spanId))})]}),o&&(0,m.jsx)(Iu,{span:o,selfMs:d.get(o.spanId)})]}),(0,m.jsx)(Kl,{title:`Where the time went`,testId:`panel-self-time`,aside:`own time, without calls to others · % of all own time`,children:(0,m.jsxs)(`table`,{className:`w-full text-sm`,children:[(0,m.jsx)(`thead`,{children:(0,m.jsxs)(`tr`,{className:`text-left font-mono text-[11px] tracking-wider text-muted-foreground uppercase`,children:[(0,m.jsx)(`th`,{className:`pb-2 font-normal`,children:`Operation`}),(0,m.jsx)(`th`,{className:`w-1/4 pb-2 font-normal`,children:`Self %`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Self`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Total`}),(0,m.jsx)(`th`,{className:`pb-2 text-right font-normal`,children:`Calls`})]})}),(0,m.jsx)(`tbody`,{children:f.map(e=>(0,m.jsxs)(`tr`,{className:`border-t`,"data-testid":`self-time-row`,children:[(0,m.jsxs)(`td`,{className:`max-w-0 truncate py-2 pr-3 font-mono`,children:[(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`hover:text-signal`,children:e.name}),a.length>1&&(0,m.jsx)(`span`,{className:`ml-2 font-sans text-xs text-muted-foreground`,children:e.service})]}),(0,m.jsx)(`td`,{className:`py-2 pr-3`,children:(0,m.jsxs)(`span`,{className:`flex items-center gap-2`,children:[(0,m.jsx)(`span`,{className:`h-1.5 flex-1 rounded-full bg-muted`,children:(0,m.jsx)(`span`,{className:`block h-1.5 rounded-full bg-warning/80`,style:{width:`${e.selfShare*100}%`}})}),(0,m.jsxs)(`span`,{className:`w-10 text-right font-mono text-xs text-muted-foreground tabular-nums`,children:[Math.round(e.selfShare*100),`%`]})]})}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono tabular-nums`,children:H(e.selfMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:H(e.totalMs)}),(0,m.jsx)(`td`,{className:`py-2 text-right font-mono text-muted-foreground tabular-nums`,children:e.calls})]},`${e.service}:${e.name}`))})]})})]}):(0,m.jsx)(`p`,{className:`text-muted-foreground`,children:`Loading…`})}var ju=5,Mu=36e5,Nu={slow:{text:`slower than 95% of the calls`,tone:`text-warning`,dot:`bg-warning`},typical:{text:`a typical call`,tone:`text-signal`,dot:`bg-signal`},fast:{text:`faster than half of the calls`,tone:`text-signal`,dot:`bg-signal`}},Pu={text:`a cold start`,tone:`text-muted-foreground`,dot:`bg-muted-foreground`};function Fu({durationMs:e,histogram:t,operation:n,service:r,coldStart:i}){let a=i?Pu:Nu[yl(e,t)],o=Math.max(t.p99Ms,e)*1.05||1,s=e=>`${Math.min(e/o*100,100)}%`;return(0,m.jsxs)(Kl,{title:`Compared to other calls`,testId:`panel-compared`,aside:(0,m.jsxs)(R,{to:`/operation`,search:{name:n,service:r},className:`hover:text-signal`,children:[t.total,` calls · the hour around this one →`]}),children:[(0,m.jsxs)(`div`,{className:`relative mt-5 mb-9 h-1.5 rounded-full bg-muted`,children:[[{label:`median`,ms:t.p50Ms},{label:`p95`,ms:t.p95Ms}].map(e=>(0,m.jsx)(`span`,{className:`absolute -top-5 h-8 border-l border-dashed border-foreground/30`,style:{left:s(e.ms)},children:(0,m.jsxs)(`span`,{className:`absolute -top-0.5 font-mono text-[10px] tracking-wider whitespace-nowrap text-muted-foreground uppercase ${e.ms/o>.75?`right-1.5`:`left-1.5`}`,children:[e.label,` `,H(e.ms)]})},e.label)),(0,m.jsx)(`span`,{className:`absolute top-1/2 size-3 -translate-x-1/2 -translate-y-1/2 rounded-full ring-4 ring-background ${a.dot}`,style:{left:s(e)},"data-testid":`this-call`}),(0,m.jsxs)(`span`,{className:`absolute top-4 -translate-x-1/2 font-mono text-xs whitespace-nowrap ${a.tone}`,style:{left:`clamp(3rem, ${s(e)}, calc(100% - 3rem))`},children:[H(e),` · this call`]})]}),(0,m.jsxs)(`p`,{className:`text-sm`,"data-testid":`standing`,children:[(0,m.jsx)(`span`,{className:a.tone,children:a.text[0].toUpperCase()+a.text.slice(1)}),(0,m.jsxs)(`span`,{className:`text-muted-foreground`,children:[` `,`— `,i?`it includes compiling the route, so it is not judged against the warm calls.`:`${(e/(t.p50Ms||1)).toFixed(1)}× the median.`]})]})]})}function Iu({span:e,selfMs:t}){let n=[[`service`,e.serviceVersion?`${e.service}@${e.serviceVersion}`:e.service],[`kind`,e.kind],[`duration`,H(e.durationMs)],...t===void 0?[]:[[`own time`,H(t)]],[`status`,e.statusMessage?`${e.status}: ${e.statusMessage}`:e.status],...Object.entries(e.attributes)];return(0,m.jsxs)(Xc,{className:`self-start`,"data-testid":`span-details`,children:[(0,m.jsxs)(Zc,{children:[(0,m.jsxs)(Qc,{className:`flex items-center gap-2 text-base`,children:[Eu(e),e.status===`error`&&(0,m.jsx)(Uc,{variant:`destructive`,children:`error`})]}),(0,m.jsx)(R,{to:`/operation`,search:{name:e.name,service:e.service},className:`font-mono text-xs text-signal underline-offset-2 hover:underline`,"data-testid":`operation-link`,children:`all calls of this operation →`})]}),(0,m.jsxs)($c,{className:`space-y-3`,children:[(0,m.jsx)(`dl`,{children:n.map(([e,t])=>(0,m.jsx)(cu,{label:e,children:typeof t==`string`?t:JSON.stringify(t)},e))}),e.events.map((e,t)=>(0,m.jsxs)(`div`,{className:`rounded-md bg-muted p-2 text-xs`,children:[(0,m.jsx)(`div`,{className:`font-medium`,children:e.name}),(0,m.jsx)(`pre`,{className:`whitespace-pre-wrap break-all`,children:String(e.attributes[`exception.message`]??``)})]},t))]})]})}function Lu({className:e,size:t=`default`,...n}){return(0,m.jsx)(wc,{"data-slot":`switch`,"data-size":t,className:ds(`peer group/switch relative inline-flex shrink-0 items-center rounded-full border border-transparent transition-all outline-none group-has-[:focus-visible]/field-label:border-transparent group-has-[:focus-visible]/field-label:ring-0 after:absolute after:-inset-x-3 after:-inset-y-2 focus-visible:border-ring focus-visible:ring-3 focus-visible:ring-ring/50 aria-invalid:border-destructive aria-invalid:ring-3 aria-invalid:ring-destructive/20 data-[size=default]:h-[18.4px] data-[size=default]:w-[32px] data-[size=sm]:h-[14px] data-[size=sm]:w-[24px] dark:aria-invalid:border-destructive/50 dark:aria-invalid:ring-destructive/40 data-checked:bg-primary data-unchecked:bg-input dark:data-unchecked:bg-input/80 data-disabled:cursor-not-allowed data-disabled:opacity-50`,e),...n,children:(0,m.jsx)(Ec,{"data-slot":`switch-thumb`,className:`pointer-events-none block rounded-full bg-background ring-0 transition-transform group-data-[size=default]/switch:size-4 group-data-[size=sm]/switch:size-3 group-data-[size=default]/switch:data-checked:translate-x-[calc(100%-2px)] group-data-[size=sm]/switch:data-checked:translate-x-[calc(100%-2px)] dark:data-checked:bg-primary-foreground group-data-[size=default]/switch:data-unchecked:translate-x-0 group-data-[size=sm]/switch:data-unchecked:translate-x-0 dark:data-unchecked:bg-foreground`})})}var Ru=2e3,zu=oa(`/traces`);function Bu(){let e=zu.useSearch(),t=Ui({from:`/traces`}),n=e=>t({search:t=>({...t,...e}),replace:!0}),r=nt({queryKey:[`traces`,e],queryFn:()=>Ba.traces(e),refetchInterval:Ru}),i=nt({queryKey:[`services`],queryFn:Ba.services,refetchInterval:Ru});return(0,m.jsxs)(`div`,{className:`space-y-6`,children:[(0,m.jsx)(sl,{title:`Traces`,count:r.data?.length,subtitle:`Every request your app made — server and browser, live.`}),(0,m.jsxs)(`div`,{className:`flex flex-wrap items-center gap-3`,children:[(0,m.jsxs)(`select`,{"aria-label":`Service`,className:`h-9 rounded-md border bg-card px-2 text-sm`,value:e.service??``,onChange:e=>n({service:e.target.value||void 0}),children:[(0,m.jsx)(`option`,{value:``,children:`All services`}),i.data?.map(e=>(0,m.jsxs)(`option`,{value:e.name,children:[e.name,e.versions.length?` (${e.versions.join(`, `)})`:``]},e.name))]}),(0,m.jsx)(ol,{"aria-label":`Operation`,className:`w-64`,placeholder:`Operation contains…`,defaultValue:e.operation??``,onChange:e=>n({operation:e.target.value||void 0})}),(0,m.jsx)(ol,{"aria-label":`Min duration (ms)`,className:`w-40`,type:`number`,min:0,placeholder:`Min ms`,defaultValue:e.minDurationMs??``,onChange:e=>n({minDurationMs:Number(e.target.value)||void 0})}),(0,m.jsxs)(`label`,{className:`flex items-center gap-2 text-sm`,children:[(0,m.jsx)(Lu,{checked:e.hasError??!1,onCheckedChange:e=>n({hasError:e||void 0})}),`Errors only`]}),r.isError&&(0,m.jsx)(`span`,{className:`ml-auto font-mono text-xs text-destructive`,children:`collector unreachable`})]}),(0,m.jsx)(_u,{traces:r.data,empty:(0,m.jsxs)(m.Fragment,{children:[`No traces yet — open your app while `,(0,m.jsx)(`code`,{children:`next-observer dev`}),` is running.`]})})]})}function Vu({to:e,children:t}){return(0,m.jsx)(R,{to:e,activeOptions:{exact:e===`/`,includeSearch:!1},className:`rounded-md px-3 py-1.5 text-sm text-muted-foreground transition-colors hover:text-foreground [&.active]:bg-muted [&.active]:text-foreground`,children:t})}var Hu=da({component:()=>(0,m.jsxs)(`div`,{className:`min-h-screen text-foreground`,children:[(0,m.jsx)(`header`,{className:`sticky top-0 z-20 border-b bg-background/70 backdrop-blur-md`,children:(0,m.jsxs)(`div`,{className:`mx-auto flex h-14 max-w-7xl items-center gap-2 px-6`,children:[(0,m.jsxs)(R,{to:`/`,className:`mr-4 flex items-center gap-2 font-semibold tracking-tight`,children:[(0,m.jsx)(`span`,{"aria-hidden":!0,className:`size-2.5 rounded-sm bg-signal shadow-[0_0_12px_var(--signal)]`}),`next-observer`]}),(0,m.jsx)(Vu,{to:`/`,children:`Overview`}),(0,m.jsx)(Vu,{to:`/errors`,children:`Errors`}),(0,m.jsx)(Vu,{to:`/traces`,children:`Traces`}),(0,m.jsx)(Vu,{to:`/chat`,children:`Chat`}),(0,m.jsx)(`span`,{className:`ml-auto`,children:(0,m.jsx)(Va,{})})]})}),(0,m.jsx)(Ha,{}),(0,m.jsx)(`main`,{className:`mx-auto max-w-7xl px-6 py-8`,children:(0,m.jsx)(Sa,{})}),(0,m.jsx)(Vc,{})]})}),Uu=la({getParentRoute:()=>Hu,path:`/`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:eu});function Wu(e){let t=e=>typeof e==`string`&&e.trim()?e.trim():void 0,n=Number(e.minDurationMs);return{service:t(e.service),operation:t(e.operation),minDurationMs:Number.isFinite(n)&&n>0?n:void 0,hasError:e.hasError===!0||e.hasError===`true`||void 0}}var Gu=la({getParentRoute:()=>Hu,path:`/traces`,validateSearch:Wu,component:Bu}),Ku=la({getParentRoute:()=>Hu,path:`/traces/$traceId`,component:Au}),qu=la({getParentRoute:()=>Hu,path:`/errors`,validateSearch:e=>({window:zl(e.window),service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0}),component:iu}),Ju=la({getParentRoute:()=>Hu,path:`/operation`,validateSearch:e=>({name:typeof e.name==`string`?e.name:``,service:typeof e.service==`string`&&e.service.trim()?e.service.trim():void 0,window:zl(e.window)}),component:Su}),Yu=la({getParentRoute:()=>Hu,path:`/chat`,validateSearch:e=>({ask:typeof e.ask==`string`&&e.ask.trim()?e.ask.trim():void 0}),component:Il}),Xu=Oa({routeTree:Hu.addChildren([Uu,qu,Gu,Ku,Ju,Yu])}),Zu=new Ue;(0,La.createRoot)(document.getElementById(`root`)).render((0,m.jsx)(p.StrictMode,{children:(0,m.jsx)(_,{client:Zu,children:(0,m.jsx)(ja,{router:Xu})})}));
|
package/dist/ui/index.html
CHANGED
|
@@ -4,7 +4,7 @@
|
|
|
4
4
|
<meta charset="UTF-8" />
|
|
5
5
|
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
|
|
6
6
|
<title>next-observer</title>
|
|
7
|
-
<script type="module" crossorigin src="/assets/index-
|
|
7
|
+
<script type="module" crossorigin src="/assets/index-C8iza4mN.js"></script>
|
|
8
8
|
<link rel="stylesheet" crossorigin href="/assets/index-BYVdqpEo.css">
|
|
9
9
|
</head>
|
|
10
10
|
<body>
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "next-observer",
|
|
3
|
-
"version": "0.3.
|
|
3
|
+
"version": "0.3.22",
|
|
4
4
|
"description": "The observer for Next.js: a server with a UI and AI agents that receives your app's OpenTelemetry traces, shows them and investigates them. Run with npx next-observer dev. The APM agent that goes into the app is next-observe.",
|
|
5
5
|
"keywords": [
|
|
6
6
|
"nextjs",
|