Track 08 · Deployment & opsLesson 07 of 11

Tracing agents with OpenTelemetry

Instrument every step so a multi-agent failure can be debugged.

What you'll be able to do

What you'll be able to do

01
  • Explain the trace data model (traces, spans, attributes, events, links, status) and the roles of the OpenTelemetry API, SDK, Collector and OTLP.
  • Implement context propagation in process, across HTTP and across a message queue using W3C Trace Context, so one agent run produces one connected trace.
  • Design a span tree for an agent loop (agent run, model calls, tool calls, retrieval, subagents, queue hops) using the OpenTelemetry GenAI semantic conventions, and know how stable they are.
  • Choose a content-capture, redaction and sampling policy that a privacy officer will sign, and place each control at the right layer.
  • Diagnose broken or misleading traces: orphaned spans after a queue, missing token counts, PII in attributes, sampled-away failures.
Before you start

Before you start

The short version

The short version

A trace is the record of one unit of work as it moves through your system: one tree of timed spans, each with a name, a parent, a status and attributes. For an agent, the root span is the agent run, and its children are the model calls, tool calls, retrievals, subagent runs and queue hops that made it up. OpenTelemetry gives you a vendor-neutral way to produce this: an API your code calls, an SDK that samples, processes and exports spans, the OTLP protocol, and a Collector that redacts, samples and routes before anything reaches a backend. W3C Trace Context carries the trace across process boundaries; if one hop drops it, the trace breaks there and the slow part becomes invisible. The OpenTelemetry GenAI semantic conventions name the spans and attributes (invoke_agent, chat, execute_tool, gen_ai.usage.input_tokens), but they are still in Development status, so pin and verify. Prompts and completions are sensitive: leave content capture off by default, redact at source, redact again in the Collector, and keep traces joinable to evals and business outcomes through IDs rather than content.

  • One unit of work, one connected trace. Propagate context across every hop, including queues.
  • Span names are low-cardinality; attributes carry the detail. chat <model>, not chat for case 118734.
  • The GenAI conventions are useful and unstable. Status Development as of September 2026; check before you build dashboards on attribute names.
  • Content capture is opt-in, and redaction happens twice. At source, and in the Collector.
  • Sample at the tail for agents. Keep every error, handoff and slow run; sample the healthy majority.

Practise this in the lab

Pro lesson

The rest of this lesson is in Pro.

The mental model, worked example, field note, failure table, exercise and self-check, with the voice tutor.

Pro opens this stage

Stage 6 · Ship, run and hand over
  • 8 lessons, with the voice tutor
  • Lab · Check a trace export before you trust the dashboard, graded here
  • Halden week 7 · The champion moves
  • Halden week 8 · The portal goes down before cut-off
  • Halden week 9 · Prices up, and a new rule
  • Halden week 10 · A second site, and handover
  • The lab kit, to run Halden weeks on your machine

Also in Pro

  • Every stage and specialisation, in full
  • Every lab and every role project
  • Halden weeks 2–10, on your record
  • Every drill, live in the playground
  • All solutions, plus the server judge
  • Lab Assistant and every Teach with AI