In short.
This guide explains agent monitoring for developers operating Claude Agent SDK applications, but tracing is in beta and successful agent execution does not establish successful telemetry delivery. It documents three independently configured signals, environment handling in Python and TypeScript, trace correlation, user attribution and controls for exporting sensitive content. The operational details are useful, particularly the warnings about silent exporter failures, buffered data loss and the console exporter conflicting with SDK communication. Runtime reliability, performance overhead, backend compatibility and costs are not assessed.
Researched and written by an AI model and checked by a second AI model. How it works
Coverage is the complete selected page at [https://code.claude.com/docs/en/agent-sdk/observability.md], including its examples, beta notices, version requirements, delivery warnings and sensitive-content controls. Linked pages and the documentation index are excluded; their detailed instructions and referenced redaction rules are not assessed. No code was executed. Actual telemetry delivery, backend compatibility, performance overhead, production behavior and costs remain unassessed or unknown.
The overview
Identity
Observability with OpenTelemetry is a documentation guide for the Claude Agent SDK at [https://code.claude.com/docs/en/agent-sdk/observability.md]. It explains how to export information about agent activity to hosted observability services or self-hosted collectors that accept the OpenTelemetry Protocol, abbreviated OTLP.
The resource is a guide to an SDK feature. Its examples use the Python claude_agent_sdk package and the TypeScript @anthropic-ai/claude-agent-sdk package.
Assessment
The guide is useful when an application needs visibility into tool calls, model latency, token consumption and failures. It connects configuration to operational problems, including missing exports, incomplete short-lived traces and identifying which application user requested an action.
Its main limitation is that enabling telemetry does not establish complete delivery. Export errors are silent by default, shutdown flushing has a timeout and abrupt termination loses buffered data. These constraints matter when interpreting traces or treating events as an audit trail.
Users
The intended readers are developers integrating the Agent SDK and operators responsible for monitoring deployed agents. The Python and TypeScript examples support readers who need concrete configuration, while trace nesting, environment inheritance and version-specific behavior provide detail for experienced developers.
Teams serving multiple users can use the attribution examples to distinguish their service credential from the person requesting an action. Readers needing only token and cost information may prefer the response-stream approach mentioned by the page.
Capabilities
The guide covers metrics for tokens, cost, sessions, lines of code and tool decisions; structured log events about prompts, API requests, errors and tool results; and beta traces for interactions, model requests, tools and hooks. These signals have separate exporters and can be enabled independently.
Trace spans distinguish model requests, permission waits and tool execution. Subagent model and tool spans nest beneath the parent agent's tool span, allowing a tracing backend to show the delegation chain. Session identifiers can connect multiple query() calls into a timeline; setting OTEL_METRICS_INCLUDE_SESSION_ID to a falsy value removes that attribute.
Service names and resource attributes support filtering by deployment or agent. Per-request enduser.id and tenant.id attributes can support user attribution for tool decisions, tool results, MCP connections and permission-mode changes. The default identity attributes identify the credential used to call Anthropic, which may represent the service rather than its end user.
Using it
Requirements
The documented approach requires an Agent SDK application, the Claude Code CLI subprocess it launches and a reachable OTLP collector or compatible backend. The deployment must supply the receiver endpoint and any required authentication headers.
Telemetry requires CLAUDE_CODE_ENABLE_TELEMETRY=1 and at least one configured exporter. Traces additionally require CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1. Hook spans require ENABLE_BETA_TRACING_DETAILED=1 and BETA_TRACING_ENDPOINT; the page warns that this pair also changes where logs and traces are sent.
The page does not establish supported Python or Node.js versions, installation procedures, account requirements or backend-specific collector configuration. Some diagnostic and content-export features require particular Claude Code versions.
Mechanism
The SDK launches Claude Code as a child process and communicates through a local pipe. The CLI contains the instrumentation and exports directly to the collector; the SDK passes configuration through environment variables and does not generate its own telemetry.
When query() is called with an active application OpenTelemetry span, the SDK injects W3C TRACEPARENT and TRACESTATE values into the child environment. The CLI interaction span can then appear beneath the application span, and exported event records can carry the corresponding trace context. An explicit TRACEPARENT in options.env skips automatic injection.
With trace-context propagation enabled, the CLI forwards TRACEPARENT to Bash and PowerShell commands. Instrumented commands can contribute spans beneath tool execution. Inbound TRACEPARENT is honored by Agent SDK and claude -p runs; interactive CLI sessions ignore it.
Setup
The example enables telemetry, sets OTEL_TRACES_EXPORTER, OTEL_METRICS_EXPORTER and OTEL_LOGS_EXPORTER to otlp, and selects http/protobuf through OTEL_EXPORTER_OTLP_PROTOCOL. OTEL_EXPORTER_OTLP_ENDPOINT identifies the receiver, while OTEL_EXPORTER_OTLP_HEADERS supplies authentication when needed. The page recommends process-level environment configuration for production deployments.
Per-call configuration uses ClaudeAgentOptions.env in Python or options.env in TypeScript. Python merges these values with the inherited environment. TypeScript replaces the inherited environment, so the example spreads process.env first to retain PATH, credentials and other settings.
The console exporter writes to standard output, which is the SDK message channel, so the guide says to use an OTLP receiver for local inspection. To investigate delivery failures, it recommends checking collector logs and enabling CLAUDE_CODE_OTEL_DIAG_STDERR=1, with diagnostics read through the SDK stderr callback or option. This diagnostic feature requires Claude Code v2.1.179 or later.
Example
The main Python and TypeScript examples ask an agent to list directory files while the application consumes its response stream and the CLI exports telemetry. The receiver address and bearer token are placeholders requiring deployment-specific values. The examples contain no demonstrated collector output or delivery results.
A tagging example changes OTEL_SERVICE_NAME from its default claude-code value to support-triage-agent and attaches deployment metadata through OTEL_RESOURCE_ATTRIBUTES. Another example adds enduser.id and tenant.id for each request. Attribute values must be percent-encoded because commas, spaces and equals signs have special meaning in that configuration.
Assessment & evidence
Limitations
Metrics export every 60 seconds by default; traces and logs export every 5 seconds. Clean shutdown attempts a bounded flush, so a slow collector can still cause loss. Abrupt termination loses buffered telemetry. The guide shows reducing all three export intervals to 1000 milliseconds to reduce these windows, without promising complete delivery.
Failed or aborted model requests may lack token counts because those attributes depend on usage data returned by the API. Beta span names and attributes may change between releases. Detailed hook tracing also has additional configuration and routing implications.
Content export is off by default. OTEL_LOG_USER_PROMPTS adds prompt text; OTEL_LOG_TOOL_DETAILS adds tool arguments and additional identifying details; OTEL_LOG_TOOL_CONTENT adds tool-output span events when tracing is enabled. Tool output is truncated at 60 KB by default. These options can expose paths, commands, file contents and returned data to the telemetry backend.
OTEL_LOG_RAW_API_BODIES can export full Messages API request and response JSON, including conversation history, with extended-thinking content redacted. A value of 1 exports inline bodies with a default 60 KB limit; file:<dir> writes untruncated bodies to disk and includes a body_ref path in events. The page states that enabling raw bodies implies consent to the disclosures covered by the other three content options. The full attribute and redaction reference is on an excluded linked page.
Reasoning
The documented design fits teams that need agent activity inside an existing application monitoring system: it supports an OTLP receiver, parent trace context and shared deployment attributes. This is an assessment of the documented architecture; interoperability and runtime behavior are not independently assessed.
The delivery and attribution caveats limit stronger conclusions. A successful agent response can accompany lost telemetry, and credential identity alone cannot identify an application's end user. Consequently, the documented events can support an audit trail, but the page does not establish an exhaustive or lossless audit record.
Alternatives
For token and cost information without an external backend, the page identifies reading usage directly from the SDK response stream and points to [https://code.claude.com/docs/en/agent-sdk/cost-tracking.md]. That linked guide's detailed behavior is outside the selected scope.
For the Claude API or Managed Agents, the page directs readers to separate documentation at [https://platform.claude.com/docs/en/manage-claude/opentelemetry]. It does not compare third-party monitoring products, backend prices or alternative SDKs.
Evidence
The evidence is the complete selected documentation page at [https://code.claude.com/docs/en/agent-sdk/observability.md]. It includes architecture explanations, Python and TypeScript examples, configuration variables, version requirements and operational warnings.
The technical behavior described is documented behavior. The page supplies no measured performance overhead, benchmark results, actual collector receipts or independently demonstrated backend compatibility. The examples were not executed.
Access & freshness
Costs
The page describes token and cost counters but provides no prices for SDK access, model usage, hosted observability or self-hosted infrastructure. Total operating cost is unknown.
Export overhead, storage volume and retention costs are not quantified. The presence of model cost counters does not establish the cost of running the telemetry pipeline.
Rights
The selected page does not state a documentation license, a code-example license or redistribution terms. Permission to redistribute the page or reuse its examples is unknown from this evidence.
Freshness
The available snapshot was captured on 2026-11-14 at 19:30:23.010 UTC. The page states no publication or last-update date and pins no SDK package version. Its version thresholds do not identify the latest available release.
The page requires Claude Code v2.1.179 or later for exporter diagnostics and v2.1.214 or later for the configurable content-length limit. Capturing MCP, WebFetch and WebSearch results through OTEL_LOG_TOOL_CONTENT requires v2.1.283 or later. It also notes that before v2.1.212, event records emitted outside an active span lacked trace_id and span_id. Tracing remains explicitly beta.
Actions
Before adopting this configuration, identify the OTLP receiver, installed Claude Code version and required signals. Preserve the inherited environment in TypeScript, add service attributes for filtering and supply per-request user attributes when end-user attribution is needed.
After configuring a small task, check collector receipt and exporter diagnostics; an agent response alone does not demonstrate export success. For short-lived calls, consider the documented shorter intervals and verify delivery. Decide which content-export options, if any, are appropriate for the data the receiving system is permitted to store.
