Stop debugging coding agents from their final answer
A coding agent says that it investigated a failing build, searched the repository, called a tool and produced a patch. The patch might be useful. But when the task takes too long, costs more than expected or fails halfway through, its final summary rarely tells an engineer where the time went. Repeating the prompt is an expensive substitute for diagnosing the execution path.
On October 14, 2026, Anthropic announced OpenTelemetry export in beta for Claude API requests and Claude Managed Agents sessions. This is worth a senior engineer's attention because it connects AI execution to an existing engineering practice: distributed tracing. Instead of treating the assistant as an opaque chat window, teams can inspect requests, model runs and tool calls in their observability platform.
The practical opportunity is not autonomous governance. It is faster investigation with better evidence. An engineer still defines acceptable behavior, reviews changes and authorizes releases. The traces help that engineer locate the bottleneck, not outsource the decision.
What the integration actually covers
OpenTelemetry describes a request's journey as a trace containing spans. A span records one operation, its timing, status and attributes. In an AI-assisted development service, the parent operation might be investigating a CI failure; child operations might include a Claude request, a repository search and a test runner. The hierarchy makes an important distinction visible: a slow model response and a slow tool are different problems.
Claude offers two complementary paths. SDK tracing runs in your application and captures SDK requests and tools executed by its tool runner. API tracing is configured in the Claude Console and captures operations executed by Anthropic, including individual model runs, server tools and Managed Agents turns. Enabling both can connect client and server activity in one trace, subject to platform limitations.
This article concerns the Claude API and Managed Agents integration, not a claim that every Claude Code terminal session automatically appears there. Claude Code, the Agent SDK and Cowork have separate monitoring documentation. Match the instrumentation to the product you actually operate before deploying it.
Start with a bounded engineering workflow
Choose one workflow with a clear owner: for example, an internal assistant that reads failed CI logs and proposes a diagnosis. Give it read-only access to build artifacts and repository metadata. Keep patch creation, dependency changes and deployment outside the first experiment. This produces a manageable execution path and avoids confusing an observability rollout with a permissions expansion.
Define success before changing anything. A useful diagnosis should identify the failing test, distinguish evidence from hypotheses and cite the relevant log location. Also record whether a human accepts the diagnosis and how much investigation remains. A fast answer that sends the reviewer in the wrong direction is not a productivity improvement.
Use a small collection of representative failures, including a flaky test, a dependency failure, an actual regression and an unavailable tool. These are proposed evaluation scenarios, not results from a benchmark performed for this article. Their purpose is to expose different failure modes before production traffic complicates the picture.
Install the SDK without accidentally migrating production
The official Python setup uses the anthropic package and opentelemetry-sdk. For an isolated trial, create a virtual environment with python3 -m venv .venv, activate it with source .venv/bin/activate, then install with python -m pip install anthropic opentelemetry-sdk. For TypeScript, the documented packages are @anthropic-ai/sdk and @opentelemetry/sdk-trace-node. Official instructions also cover C#, Go, Java, PHP and Ruby.
Resolve dependencies in that disposable environment, inspect the versions and commit a lockfile before integrating the change. The observability feature is in beta, so option names, span names and attributes may change. A floating dependency can silently invalidate dashboards even when the application still starts.
There is an additional timely trap: the October 21 SDK major releases adopt API version 2026-10-21 by default and introduce breaking changes. The migration guide documents removed sampling parameters and other compatibility changes. Do not combine an unreviewed major upgrade with an observability experiment in production. Review the guide, test existing requests and make the migration an explicit release decision.
First verify local spans, then configure export
The smallest documented Python setup registers an OpenTelemetry TracerProvider, attaches a SimpleSpanProcessor with a ConsoleSpanExporter and calls trace.set_tracer_provider before creating requests. The normal Anthropic client then emits spans. Start with a harmless synthetic request and metadata-only content. Verify that an anthropic.messages.create span appears, with usable timing and status information.
Add an application-level parent span around the complete engineering task, with a stable name such as ci_failure_investigation. Attach a repository identifier, commit SHA, workflow version and non-sensitive run identifier. Keep changing values out of span names. That convention makes comparisons possible without producing an unmanageable set of operation names.
The console exporter is a smoke test, not the production architecture. Replace it with an OTLP exporter for your existing backend and use appropriate buffering, shutdown and failure handling. Ensure short-lived workers flush telemetry before exiting. Keep observability credentials separate from model credentials, and never print either while diagnosing connectivity.
Add API-side tracing carefully
API export requires an administrator in the Claude Console organization. Open the telemetry destinations settings, add a provider or custom destination, configure its authentication headers and choose the workspaces it covers. Start with a selected development workspace rather than exporting every organization's workload by default. The destination determines where the data leaves Anthropic and which third party stores it.
A custom receiver must accept OTLP/HTTP with protobuf encoding at a public HTTPS hostname on port 443. A Collector listening only on its usual local port 4318 is not sufficient. Put an authenticated HTTPS endpoint or correctly configured reverse proxy in front of it. For the base endpoint field, do not append /v1/traces: the API adds that path unless a dedicated traces endpoint override is configured.
Use the destination's Test action, then confirm that the anthropic.test span actually arrives in the receiving platform. Afterward send a real synthetic Messages request in the selected workspace and inspect the resulting trace. A healthy Console indicator is helpful, but reading the received span proves more than trusting a saved configuration.
Connect traces without duplicating the story
The API can read W3C trace context from the traceparent header, allowing server spans to sit beneath the application request. The SDK uses the application's propagator. Configure context propagation explicitly where your language requires it, and check whether existing HTTP auto-instrumentation already injects the same headers. Duplicate propagation can break correlation rather than improve it.
Client and server spans can share the name anthropic.messages.create. They represent different perspectives on the same request, not necessarily duplicate requests. Inspect span kind and service.name before concluding that the agent called the model twice. Also avoid layering a second SDK instrumentation library on top without deciding which integration owns those spans.
Claude Platform on AWS has a documented limitation: API spans start their own traces rather than joining through traceparent. For Managed Agents, a session can span several traces and threads. Use anthropic.session.id for session-level investigation and gen_ai.conversation.id for a thread. A single waterfall is not automatically the complete task history.
Use case one: diagnose a slow CI assistant
Suppose an assistant spends most of its elapsed time retrieving artifacts, then only a small portion asking the model for a diagnosis. The right optimization may be artifact indexing, caching or narrowing the requested logs, not switching to a faster model. Trace the retrieval tool and attach a bounded artifact-size indicator, without copying sensitive log content into metadata.
Compare several similar runs before changing the architecture. Separate queueing, retries, tool execution and model latency wherever your instrumentation exposes them. A single unusually slow run can reflect an external service incident rather than a persistent defect in your agent.
Have the assistant propose an optimization and explain the spans supporting it. A human reviews the proposal, reruns the evaluation cases and checks diagnosis quality. The productivity gain comes from removing a demonstrated bottleneck while preserving useful output, not from optimizing whichever component has the most visible brand name.
Use case two: find wasteful repository exploration
A repository-navigation agent may repeatedly search the same directory, fetch the same file or issue broad queries before answering a narrow question. Tool spans can reveal this pattern even when the final answer looks concise. Group runs by workflow version and inspect repeated operations, their duration and their relationship to accepted diagnoses.
Try a tighter repository map, a deterministic file lookup before semantic search, or a clear stopping rule after sufficient evidence is found. These are application design choices, not features automatically supplied by tracing. Instrument custom tools so that work performed outside the SDK's runner does not remain invisible.
Do not simply ban repeated calls: a second read after a checkout change may be necessary. Review the actual sequence and distinguish redundant exploration from a valid verification step. Preserve tests that ensure the assistant still inspects the relevant code instead of answering from stale context.
Use case three: investigate tool and MCP failures
When a tool returns an authorization error or times out, the model can still produce a plausible explanation. The trace helps reviewers notice that the underlying evidence was never retrieved. Mark tool failure distinctly and require the assistant's final output to disclose missing evidence. A graceful sentence is not a successful engineering investigation.
For MCP integrations, verify context propagation end to end rather than assuming that every client forwards it. The SDK documentation describes differences between language implementations. Add server-side spans where supported, and use non-sensitive correlation identifiers where a direct parent-child relationship is unavailable.
Keep production permissions unchanged during debugging. A denied request should trigger a decision about the required capability, not an automatic escalation to an administrator credential. Observability explains what failed; authorization policy decides whether that operation should ever succeed.
Use case four: build regression evaluations from evidence
Useful traces can become evaluation cases: a tool result the agent misunderstood, an exception it concealed or an unnecessarily long investigation. Where content collection is permitted, select and sanitize examples deliberately. Store the expected outcome and a human-authored explanation separately from the model's original response.
Run those cases when changing a prompt, model, tool schema or SDK version. Check correctness, unsupported claims, unnecessary tool calls and reviewer effort. Keep a stable subset so that improvements on easy cases cannot hide a regression in the scenario that motivated the change.
A trace is an input to evaluation, not an oracle. Successful tool execution does not establish semantic correctness, and an HTTP success does not establish a valid patch. Continue to run deterministic tests, static analysis and review. Release approval remains a separate control.
Count usage once and measure useful outcomes
With both SDK and API tracing, adding every token attribute overcounts usage. Anthropic explicitly recommends selecting one source per request. For Messages API server spans, choose the request-level totals or the model-request totals, not both. Compaction has additional accounting rules, and cache tokens are already included in the documented input totals.
Deduplicate retransmitted spans by trace ID and span ID if your backend does not do so. For billing reconciliation or detecting usage outside your tracing sample, use the Usage API rather than assuming exported spans form a complete ledger. Delivery is best effort and sampling can exclude requests.
For productivity, track time to an accepted diagnosis, review effort, successful task completion and cost per accepted outcome. Segment by task type and difficulty. Do not publish a percentage improvement from a tiny pilot or use individual trace counts to rank engineers. The first measurable benefit may simply be less time spent guessing where an agent stalled.
Metadata-only is the starting point, not a privacy guarantee
The default metadata-only mode excludes model prompts and responses, but still includes identifiers and text such as tool descriptions, agent names and MCP server names. Treat those values as exported data. Never put secrets, customer names or confidential issue text in a convenient identifier and assume the content mode will remove it.
Full-content mode can expose repository code, prompts, tool arguments and results to the observability provider. Approve that destination's access controls, region and retention before enabling it. Restrict collection to the smallest useful scope. The documentation also describes content truncation, so an incomplete prompt in a trace is not necessarily the prompt the model actually saw.
Zero data retention arrangements with the model provider do not erase the receiving observability system's copy. Managed Agents has its own eligibility constraints. Review the exact product and contract rather than inferring a privacy property from an acronym. The human owner should be able to explain where every exported category of data ends up.
Operational limits and a sensible rollout
API export is best effort, not a compliance-grade audit trail or an enforcement mechanism. A missing span does not prove an action never happened. A trace cannot stop an unsafe command, roll back a deployment or replace branch protection. Keep authoritative records for approvals and consequential actions in the systems that perform them.
Monitor the telemetry pipeline itself. Incorrect authentication, a bad path or TLS failure can prevent delivery. Redirects and non-public destination addresses can disable a destination; sustained failures can also disable it. Document who owns recovery, how to re-enable export and how the application behaves when the observability backend is unavailable.
- First, validate one synthetic request locally and one test span at the destination.
- Next, instrument one read-only development workflow with metadata-only export and pinned dependencies.
- Then compare a representative evaluation set and review privacy, token accounting and trace correlation.
- Finally, expand only after an engineer can explain the evidence, limitations and rollback path.
The release is interesting precisely because it makes AI workflows more ordinary to operate. We already expect evidence when a database query slows down or a service retries. Coding agents deserve the same discipline. Let the agent accelerate implementation and investigation; keep humans responsible for interpreting the evidence and deciding what ships.