Skip to content

Commit 6dd9fc1

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 6dd9fc1

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/lib/api-client.ts

Lines changed: 17 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1503,7 +1503,23 @@ export async function getDetailedTrace(
15031503
},
15041504
}
15051505
);
1506-
return data;
1506+
return data.map(normalizeTraceSpan);
1507+
}
1508+
1509+
/**
1510+
* Normalize a TraceSpan from the API response.
1511+
* The trace detail API returns `event_id` instead of `span_id` —
1512+
* copy it to `span_id` so downstream code has a consistent field.
1513+
*/
1514+
function normalizeTraceSpan(span: TraceSpan): TraceSpan {
1515+
const normalized = { ...span };
1516+
if (!normalized.span_id && normalized.event_id) {
1517+
normalized.span_id = normalized.event_id;
1518+
}
1519+
if (normalized.children) {
1520+
normalized.children = normalized.children.map(normalizeTraceSpan);
1521+
}
1522+
return normalized;
15071523
}
15081524

15091525
/** 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)