Trace your Claude agent: the setup guide
The short version
On 14 October 2026, Anthropic launched OpenTelemetry export for the Claude API, in beta. The API now reports every model request, tool use and Managed Agents session on its own, straight to the observability platform you already use, such as Sentry or PostHog. API tracing needs no code: an admin adds a destination in the Claude Console. The Claude SDK can add spans from inside your app too, in Python, TypeScript, C#, Go, Java, PHP and Ruby.
Think of parcel tracking. You used to tape your own tracker to every box. Now the courier does it, and every stop gets a timestamp, so you can see where a run broke or got stuck.
The catch: prompts are off by default. You see where a run broke, not what it said. Turn them on and your users' words sit in that dashboard, so check who has access first.
| Wired up by hand | Built into the Claude API | |
|---|---|---|
| Setup | SDK integrations plus your own capture code | A destination in the Claude Console (admin role), no code |
| What it covers | Any provider you instrument | Claude: each request, each model run, server tools and Managed Agents turns |
| Where it goes | Your platform | The same platform: any OTLP endpoint. Sentry and PostHog are listed partners |
| Prompts and replies | Your choice | Off by default (Metadata only) |
Sources: Claude Platform release notes, 14 Oct 2026 · OpenTelemetry for the Claude API · API tracing setup
The three words you need
| Word | What it means | Parcel version |
|---|---|---|
| Trace | The full record of one request, start to finish | The tracking page |
| Span | One step in that trace, such as a model request or a tool use, with its timing and status (OK or ERROR) | One stop on the route |
| OpenTelemetry | The open standard most observability platforms read, so the spans show up without extra setup | The barcode every courier can scan |
Copy these prompts
Paste them into Claude Code (or any AI that can see your project).
1. Find the tracking you wired up by hand
Find every place in my project where I log or trace AI model calls myself: SDK integrations (Sentry, PostHog, Langfuse, Datadog), custom wrappers that record model, tokens, latency or cost, and anything that sends prompts or replies to a third party. List each one with its file, what it records, and whether it records the prompt or the reply. Then tell me which of these only cover Claude calls (the built-in Claude API tracing could replace them) and which cover other providers (they have to stay).
2. Check what my dashboards can see
For each observability or analytics tool my app sends data to, tell me whether it can receive my users' words: prompts, replies, transcripts, uploaded files or form text. Show the exact setting or line of code that decides it. Then list who would need access to that tool to read them, and suggest the smallest change that keeps the words out by default.
3. Wrap each agent run in one span
Add OpenTelemetry tracing around my agent. Register a tracer provider before the first Claude call, start with a console exporter so I can see the spans, and wrap each agent run in one parent span named after what it does (for example answer_question). Do not record prompts or replies. If another library already traces the Claude SDK, tell me and turn off one of the two so each request is not counted twice.
Until now: wiring it up yourself (how my app does it)
Settl, my expense-splitting app, sends its AI calls to several model providers, and I wired its tracking in by hand with two tools.
- Sentry draws each request as a timeline. The server registers Sentry's Anthropic and Google AI integrations with
recordInputs: falseandrecordOutputs: false, so they never ship the words. The voice route tags each request with its model, token counts and cost. - PostHog logs each AI call. A module of about a hundred lines sends one
$ai_generationevent per model call: the model, the provider, input and output tokens, cache reads, latency and status. Never the prompt or the reply. - The phone app sends PostHog event names only, with the signed-in user ID. No payloads, and session replay stays off.
- The rule, from Settl's privacy page: PostHog "never receives what you said, typed or photographed, or what the model replied."
Call more than one model provider? The built-in tracing covers Claude only, so keep your own capture for the others. That's why Settl keeps its code.
The catch: pick your content mode on purpose
| Content mode | What the spans include | Use it for |
|---|---|---|
| Metadata only (the default) | IDs, timing, status, token counts, and names you choose (your agents, tools and MCP servers) | Finding which step broke or was slow, cost, latency |
| Full content | All of the above, plus the prompts and the responses | Reading why a run failed, full conversations, evals |
With full content, your observability platform stores your users' words under its own access and retention settings. Check who can open that dashboard, and how long it keeps data, before you switch it on.
Turn it on
- Pick where the traces go. Any platform that accepts OTLP works. Anthropic lists Arize AI, Braintrust, Databricks, Datadog, Grafana Cloud, Honeycomb, Langfuse, LangSmith, New Relic, PostHog, Sentry and Splunk.
- API tracing, no code. In the Claude Console, as an admin, open your organization's OpenTelemetry settings and click Add destination. Choose your platform as the Provider, or Custom with your OTLP/HTTP endpoint. Leave Content mode on Metadata only, pick the workspaces, and save.
- Test it. Click Test in the destination's More actions menu, then look for the
anthropic.testspan in your platform. - Send one real request. Within about a minute the Delivery column should say Healthy. In your platform, filter on
service.name = claude-platform. - SDK tracing, in your code. Upgrade the Claude SDK, install the OpenTelemetry SDK, and register a tracer provider before your first Claude call.
- Switch to full content only after you've checked the dashboard's access and retention settings.
- Pin the SDK version. It's a beta: span names, attributes and options can change.
If you are building the agent
- Run your tools through the SDK's tool runner, or wrap your own tool code in a span. Your custom tools only get a span when a tool runner runs them.
- Count tokens once. For a Messages API request, sum its API spans, not the SDK span too.
- Never put personal data in
conversation_id. It's exported in both content modes. - Close streams you stop reading early, or the request's span never ends.
- Traces aren't your bill. Delivery is best effort, so a span can be lost or arrive twice. To track spend per API key, use the Usage API.
- On Bedrock, Vertex AI or Foundry, use SDK tracing; API tracing runs on the Claude Platform.
Run this on your codebase
I want to trace my Claude agent with the Claude API's built-in OpenTelemetry export. Look at my project and give me a short plan: which platform my traces should go to (prefer one I already use), which of my hand-written AI logging I can delete and which must stay, where to add one parent span per agent run, and every place my users' words could end up in a dashboard. Keep prompts off. Do not change any code until I approve the plan.