OpenTelemetry architecture¶
How telemetry hooks into a run, what each part does, and what connectors must do (almost nothing). User documentation: Observability. Design decisions: 0003.
Where it hooks in¶
- The CLI resolves
TelemetryConfig(telemetry/config.py) and, when enabled, callstelemetry.start, which imports OpenTelemetry, builds the tracer provider and exporter (tracer.py) and makes theTelemetryhub active (hub.py). It always callstelemetry.stopin afinally. run_to_bundleopens the run span (RunSpans.start).run_episodeopens the scenario span (RunSpans.episode) and runs the connector insideEpisodeSpans.invoke_agent, which opens theinvoke_agentspan, registerson_eventonenv.listeners, and (innestmode) attaches the span as the current context.- Every
Environment.recordcall reacheson_event:tool_callopens anexecute_toolspan andtool_resultcloses it;model_callbecomes achatspan;fault,control_signal,approval_*andhandoffbecome events. - When the connector returns,
end_agentcloses the agent span and records the episode's measures (tool calls, halt time, post-signal actions, errors). - After Inspect has graded every epoch,
run_packscallsRunSpans.grade(results): finding events, the grade span and result attributes are added, and each scenario span ends with its episode's end time. run_to_bundlefinishes the run span and passesRunSpans.ids()towrite_bundle, which writesotel/ids.jsonbefore the report (the report reads it for links).
connectors check traces its first pass the same way and checks the result with
telemetry.validate.check_episode. mcp serve traces the session as one scenario span.
Connectors' responsibilities¶
None beyond what conformance already requires: record tool calls through
Environment.call, model calls as model_call events (with meta.model and, when the
framework reports it, meta.usage with input_tokens and output_tokens), approvals
through Environment.review, and handoffs as handoff events. Two optional extras:
- A connector that sends requests to an outside agent adds
telemetry.propagation_headers()to them (the HTTP connector does). - A connector that launches a process adds
telemetry.propagation_env()to its environment (the MCP connector does, and also writestrace_contextinto the task file).
Both return {} when telemetry is off or not in nest mode.
Threads and context¶
Inspect runs each episode in a worker thread. Spans are created with explicit parents (the scenario or agent span), so tool calls made from framework threads still land in the right place. Only framework spans rely on the attached context; a framework that starts its own threads without copying the context produces separate traces.
Privacy¶
EpisodeSpans._content is the only place content is set: it returns immediately when
capture is off or the scenario is confidential, and otherwise passes the value through
redaction.clean (secrets, emails, the local denylist, the size cap). Fault parameters,
finding rule ids and step references are omitted for confidential scenarios, and their ids
appear as confidential:<hash>; control-signal
reasons are never emitted.
Tests¶
tests/unit/test_otel.py: settings, the span tree, events, status rules, granularity, sampling, exporter failures, the disabled path, privacy (against real pack texts, planted markers and the confidential fixture pack), the bundle sidecar and report links, propagation, framework nesting, and the CLI.tests/unit/test_otel_golden.pywithscripts/gen_otel_golden.py: normalised span trees per connector.tests/integration/test_otel_collector.py: a real Collector over HTTP and gRPC (Docker; CI jobotel-integration).- The conformance kit's
otelcheck, for every connector.
Semantic-convention validation with OTel Weaver was not set up: Weaver ships as a
container or a release binary, neither available in this build's offline environment. The
golden files and check_episode are the safeguard (see the build log).