Skip to content

Trace & Span Schema ​

Every trace inspected in Blackspool or exported as JSON follows a consistent, typed schema.

ts
type TraceStatus = "healthy" | "error" | "timeout" | "loop" | "slow" | "token_spike";

interface Trace {
  id: string;
  agent: string;
  status: TraceStatus;
  startedAt: string;   // ISO-8601 timestamp
  durationMs: number;
  tokensIn: number;
  tokensOut: number;
  costUsd: number;
  spans: Span[];
}

interface Span {
  id: string;
  parentId?: string;   // omitted for root spans
  name: string;        // e.g. "llm.plan", "tool.search"
  kind: "agent" | "llm" | "tool";
  startMs: number;     // offset from the trace start
  durationMs: number;
  status: "ok" | "error";
  tokensIn?: number;
  tokensOut?: number;
  costUsd?: number;
  attributes?: Record<string, string | number | boolean>;
}

Conventions ​

  • Timing: startMs is relative to the start of the trace, so waterfalls remain aligned across distributed services.
  • Trace totals: trace-level tokensIn, tokensOut, and costUsd aggregate across all spans in the run. Span-level fields record per-call usage.
  • Cost accounting: explicit producer-reported costs are preserved verbatim. When a span reports token counts and a recognized model name without an explicit cost, Blackspool computes deterministic USD estimates automatically.
  • Statuses: anomalous runs (error, timeout, loop, slow, token_spike) are retained in full alongside their span payloads and attributes.

JSON export format ​

Trace JSON exports wrap traces in a versioned envelope:

json
{
  "format": "blackspool.traces.v1",
  "exportedAt": "2026-12-02T09:00:00.000Z",
  "traces": [ /* Trace[] */ ]
}

© Blackspool. All rights reserved.