Skip to content

Commit d1c32a9

Browse files
betegonclaude
andcommitted
fix(trace): show span IDs in trace view and fix event_id mapping
The trace detail API returns `event_id` instead of `span_id` on each span, so all span IDs rendered as `undefined` in the span tree and `span view` lookups always failed. Normalize the response in `getDetailedTrace` by copying `event_id` → `span_id`, and append the span ID to each tree line so users can copy it into `span view`. Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
1 parent 4304ab8 commit d1c32a9

File tree

2 files changed

+20
-1
lines changed

2 files changed

+20
-1
lines changed

src/lib/api-client.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,24 @@ export async function getDetailedTrace(
15031503
},
15041504
}
15051505
);
1506-
return data;
1506+
return data.map(normalizeTraceSpan);
1507+
}
1508+
1509+
/**
1510+
* The trace detail API (`/trace/{id}/`) returns each span's unique identifier
1511+
* as `event_id` rather than `span_id`. The value is the same 16-hex-char span
1512+
* ID that `parent_span_id` references on child spans. We copy it to `span_id`
1513+
* so the rest of the codebase can use a single, predictable field name.
1514+
*/
1515+
function normalizeTraceSpan(span: TraceSpan): TraceSpan {
1516+
const normalized = { ...span };
1517+
if (!normalized.span_id && normalized.event_id) {
1518+
normalized.span_id = normalized.event_id;
1519+
}
1520+
if (normalized.children) {
1521+
normalized.children = normalized.children.map(normalizeTraceSpan);
1522+
}
1523+
return normalized;
15071524
}
15081525

15091526
/** Fields to request from the transactions API */

src/lib/formatters/human.ts

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1122,6 +1122,8 @@ function formatSpanSimple(span: TraceSpan, opts: FormatSpanOptions): void {
11221122
line += ` ${muted(`(${prettyMs(durationMs)})`)}`;
11231123
}
11241124

1125+
line += ` ${muted(span.span_id)}`;
1126+
11251127
lines.push(line);
11261128

11271129
if (currentDepth < maxDepth) {

0 commit comments

Comments
 (0)