Skip to content

Commit c2fdff7

Browse files
committed
Some fixes and changesets
1 parent f9c3573 commit c2fdff7

File tree

4 files changed

+21
-3
lines changed

4 files changed

+21
-3
lines changed

.changeset/mcp-get-span-details.md

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,11 @@
1+
---
2+
"@trigger.dev/core": patch
3+
"trigger.dev": patch
4+
---
5+
6+
Add `get_span_details` MCP tool for inspecting individual spans within a run trace.
7+
8+
- New `get_span_details` tool returns full span attributes, timing, events, and AI enrichment (model, tokens, cost, speed)
9+
- Span IDs now shown in `get_run_details` trace output for easy discovery
10+
- New API endpoint `GET /api/v1/runs/:runId/spans/:spanId`
11+
- New `retrieveSpan()` method on the API client
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,6 @@
1+
---
2+
area: webapp
3+
type: feature
4+
---
5+
6+
Add API endpoint `GET /api/v1/runs/:runId/spans/:spanId` that returns detailed span information including properties, events, AI enrichment (model, tokens, cost), and triggered child runs.

apps/webapp/app/routes/api.v1.runs.$runId.spans.$spanId.ts

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@ export const loader = createLoaderApiRoute(
5454
return json({ error: "Span not found" }, { status: 404 });
5555
}
5656

57-
const durationMs = span.duration / 1_000_000;
57+
// Postgres eventRepository returns duration in ms, ClickHouse returns nanoseconds
58+
const isClickhouse =
59+
run.taskEventStore === "clickhouse" || run.taskEventStore === "clickhouse_v2";
60+
const durationMs = isClickhouse ? span.duration / 1_000_000 : span.duration;
5861

5962
const aiData =
6063
span.properties && typeof span.properties === "object"
@@ -91,7 +94,6 @@ export const loader = createLoaderApiRoute(
9194
isCancelled: span.isCancelled,
9295
level: span.level,
9396
startTime: span.startTime,
94-
duration: span.duration,
9597
durationMs,
9698
properties,
9799
events: span.events?.length ? span.events : undefined,

packages/core/src/v3/schemas/api.ts

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1634,7 +1634,6 @@ export const RetrieveSpanDetailResponseBody = z.object({
16341634
isCancelled: z.boolean(),
16351635
level: z.string(),
16361636
startTime: z.coerce.date(),
1637-
duration: z.number(),
16381637
durationMs: z.number(),
16391638
properties: z.record(z.any()).optional(),
16401639
events: z.array(z.any()).optional(),

0 commit comments

Comments
 (0)