Skip to main content
The Claude API and the Claude SDKs emit OpenTelemetry spans for each Messages API request, model run, tool use, and Managed Agents session. Send them to Squasher to see their tokens, cost, latency, and status in AI observability, next to your own traces. You can use one source or both. Squasher counts the tokens and cost of a request once, also when both sources send spans for it.

What you need

  • The admin role in your Claude Console organization, to add a destination.
  • A Squasher ingest key in SQUASHER_API_KEY. See Create an ingest key.

Send Claude API spans

1

Add a destination

In the Claude Console, open the OpenTelemetry settings page and select Add destination.Do not add /v1/traces to the URL. The Claude API adds it.
2

Test the destination

Select Test in the destination’s More actions menu. Squasher stores an anthropic.test span. Select Logs in the sidebar, choose Traces, and filter on service.name:claude-platform.
To add the destination with the Admin API instead:
Full content adds prompts, responses, tool arguments, and tool results to the spans. Squasher shows them on the request page. The default content limit of 0.75 MB for each span is in the Squasher limit of 16 MiB for each request.

Send Claude SDK spans

The Claude SDK writes its spans to the tracer provider of your app. Export them over OTLP/HTTP with the variables from OpenTelemetry:
The SDK sends the trace context with each request. When the Claude API destination is also on, the API spans of a request appear under its SDK span in the same trace.

Read Claude data in Squasher

  • Requests: each anthropic.messages.create span, each anthropic.model_request, and each anthropic.compaction is a model call. The trace shows the SDK span over the API span over the model runs.
  • Tokens and cost: Squasher counts the deepest span that reports usage, so a request counts once. Cache reads and writes are part of the input tokens. Cache writes with a 1-hour lifetime use twice the input price.
  • Sessions: a Managed Agents session groups by anthropic.session.id, across all of its traces and threads. A Messages API conversation groups by gen_ai.conversation.id, which you set with the SDK’s conversation_id option.
  • Agents: turns show the agent from gen_ai.agent.id.
  • Needs attention: Squasher reads the stop reason (anthropic.message.stop_reason) and the error type, such as rate_limit_error or overloaded_error.

Limits

  • The Claude API delivers spans at least once. Squasher counts each span once by its trace ID and span ID.
  • Spans count toward the project limit of records per minute. A 429 response makes the Claude API retry the delivery later.
  • The Claude API does not trace requests on the OpenAI-compatible endpoint.

Next steps

AI observability

Find slow or failing calls and follow one agent run.

OpenTelemetry

Endpoint, headers, and limits for OTLP/HTTP.