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.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:Read Claude data in Squasher
- Requests: each
anthropic.messages.createspan, eachanthropic.model_request, and eachanthropic.compactionis 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 bygen_ai.conversation.id, which you set with the SDK’sconversation_idoption. - 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 asrate_limit_errororoverloaded_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
429response 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.