| Span | One unit of work: a model call, tool call or retrieval step. |
| Trace | The full tree of spans for one request or agent run. |
| Replay | Reconstructing a past run from recorded inputs and versions. |
| Ship gate | A pre-merge check on cost, behaviour and exposure before a change goes live. |
- Agents act on production systems.
- You must explain or audit a decision.
- Costs and latency need step-level attribution.
- 01Emit a span for every model call, retrieval and tool execution.
- 02Record prompt/model versions, tool arguments, outputs and latency.
- 03Link spans with a run ID across agents and hand-offs.
- 04Score traces for quality and gate changes on cost and behaviour deltas.
Explaining an agent's decision
- Context
- A customer disputes why an order was refunded.
- Problem
- Plain logs cannot reconstruct the agent's reasoning path.
- Approach
- Trace every model and tool span with prompt and model versions, then replay by run ID.
- Outcome
- Support can show exactly what happened and why.
Cost spike after a release
- Context
- A deploy doubles inference spend.
- Problem
- There is no way to tell which step became expensive.
- Approach
- Attribute spans by step and compare cost and latency deltas in a ship gate.
- Outcome
- The offending step is found and future regressions are blocked.
Span record for a tool call
{
"run_id": "run-8821",
"span": "tool.lookup_order",
"prompt_version": "v7",
"model_version": "pinned-small@3",
"args_redacted": { "order_id": "ORD-104200" },
"latency_ms": 180,
"outcome": "ok"
}Redact secrets and personal data before storage, but keep versions so a past decision can be replayed.
Replay a run by ID
SELECT span, prompt_version, model_version, args_redacted, outcome, latency_ms
FROM agent_spans
WHERE run_id = :id
ORDER BY started_at;Query traces by run, feature and customer. A trace with missing versions cannot be reproduced.
Full capture
Up: Complete replay and audit
Down: Storage cost and privacy handling
Metadata only
Up: Lower risk and cost
Down: Cannot reconstruct past decisions
Sampling
Up: Cheaper at scale
Down: Misses rare failures
| Option | Upside | Cost |
|---|---|---|
| Full capture | Complete replay and audit | Storage cost and privacy handling |
| Metadata only | Lower risk and cost | Cannot reconstruct past decisions |
| Sampling | Cheaper at scale | Misses rare failures |
- Redact secrets and personal data before storage.
- Keep prompt and model versions with every span.
- Record failed and retried calls, not just successes.
- Make traces queryable by run, customer and feature.
| Key | Typical value | Note |
|---|---|---|
| capture_text | policy-driven | Off by default where data is sensitive. |
| retention | documented | Align with your policy. |
| ship_gates | cost + behaviour | Run before merge. |
| Symptom | Cause | Fix |
|---|---|---|
| Trace has gaps | Spans emitted after process exit | Flush before shutdown. |
| Cannot reproduce a decision | Missing prompt/model versions | Record versions with each span. |
Is observability the same as logging?
No. Logs are flat; traces reconstruct the full decision path across models, tools and agents.
What should a ship gate check?
At minimum: cost and latency deltas, behaviour changes on the golden set, and new tool permissions or exposure.
More in Evaluation & safety