Skip to main content

Install

Instrument

What gets captured

Every call to messages.create (sync and streaming, async and sync) becomes an llm span with:
  • input — the full messages array and system prompt
  • output — the response content blocks (text + tool_use)
  • model
  • prompt_tokens → Anthropic’s input_tokens
  • completion_tokens → Anthropic’s output_tokens
  • cache_creation_input_tokens, cache_read_input_tokens → attached as metadata when prompt caching is in use
  • stop_reason — attached as metadata (end_turn, tool_use, max_tokens)
  • latency_ms

Streaming

Tool use

Claude’s tool calls appear in the span output under content[].tool_use. To trace tool execution as its own span:
Then feed the result back to Claude with a follow-up messages.create call — that becomes a second llm span, and the two-turn conversation appears as a clear waterfall in the dashboard.

Prompt caching

Anthropic’s prompt caching works transparently — the SDK records cache_creation_input_tokens and cache_read_input_tokens as span metadata so you can see cache hit rates in the dashboard’s Metrics view. Filter by metadata.cache_hit_rate or query via the API:

Disabling

Known gotchas

  • Extended thinking — thinking content is captured as part of the span output (content[].thinking). It’ll show up in trace detail views alongside the visible response.
  • Batch API (messages.batches) — not auto-instrumented. Wrap batch submissions manually with trace() if you want observability.
  • Vertex and Bedrock — use the respective Anthropic SDK client (AnthropicVertex, AnthropicBedrock) and the same instrument_anthropic() call.