Source Intelligence

DisclaimerUnofficial, and not affiliated with Anthropic. Nearly all of this is read straight out of what ships: npm bundles, captured prompts, published docs. Anthropic's own notes go in verbatim, marked as theirs. The rest is my reading, and every entry carries the strings behind it. If one looks wrong, vote it down and say why.

All of v2.0.18 Home All releases olderv2.0.17 v2.0.19newer
Claude Code v2.0.18

OpenTelemetry Tracing Support (Opt-In)

What: Comprehensive distributed tracing infrastructure for monitoring Claude Code's internal operations, API calls, and performance metrics. This feature is disabled by default and requires explicit opt-in.

How to use:

# Enable telemetry
export CLAUDE_CODE_ENABLE_TELEMETRY=true

# Configure where traces are exported (optional)
export OTEL_TRACES_EXPORTER=console  # or "otlp" for OpenTelemetry collectors

# Privacy controls (optional - both default to redacted)
export OTEL_LOG_USER_PROMPTS=true     # Log user prompts in traces
export OTEL_LOG_MODEL_RESPONSE=true   # Log model responses in traces

Details:

  • Tracks user interactions, LLM API requests/responses, and tool executions
  • Privacy-conscious by default: User prompts and model responses are redacted unless explicitly enabled via OTEL_LOG_USER_PROMPTS and OTEL_LOG_MODEL_RESPONSE
  • Supports multiple export formats:
  • console - Output traces to console for debugging
  • otlp - Export to OpenTelemetry Protocol collectors (supports gRPC, HTTP/JSON, HTTP/Protobuf)
  • Records detailed metrics: token counts (input, output, cache read, cache creation), latency, success/failure rates
  • Full OpenTelemetry specification compliance with 15+ configuration environment variables
  • Configurable sampling strategies via OTEL_TRACES_SAMPLER (defaults to parentbased_always_on)
  • Batch span processor with tunable performance parameters
  • Evidence: DiB() at line 2314, JiB() at line 2048, Jb0() at line 2087, cL5() at line 2277

Supported Environment Variables:

Telemetry Control:

  • CLAUDE_CODE_ENABLE_TELEMETRY - Master switch (default: disabled)
  • OTEL_LOG_USER_PROMPTS - Include user prompts in traces (default: redacted)
  • OTEL_LOG_MODEL_RESPONSE - Include model responses in traces (default: redacted)

Export Configuration:

  • OTEL_TRACES_EXPORTER - Exporters: "console", "otlp" (comma-separated)
  • OTEL_EXPORTER_OTLP_TRACES_PROTOCOL - Protocol: "grpc", "http/json", "http/protobuf"
  • OTEL_EXPORTER_OTLP_PROTOCOL - Default protocol for all signals

Sampling:

  • OTEL_TRACES_SAMPLER - Sampler type (default: "parentbased_always_on")
  • OTEL_TRACES_SAMPLER_ARG - Sampler configuration (e.g., ratio for TraceIdRatioBased)

Span Limits:

  • OTEL_ATTRIBUTE_VALUE_LENGTH_LIMIT - Max attribute value length (unlimited by default)
  • OTEL_ATTRIBUTE_COUNT_LIMIT - Max attributes per span (default: 128)
  • OTEL_SPAN_ATTRIBUTE_VALUE_LENGTH_LIMIT - Span-specific attribute value limit
  • OTEL_SPAN_ATTRIBUTE_COUNT_LIMIT - Span-specific attribute count (default: 128)
  • OTEL_SPAN_LINK_COUNT_LIMIT - Max links per span (default: 128)
  • OTEL_SPAN_EVENT_COUNT_LIMIT - Max events per span (default: 128)
  • OTEL_SPAN_ATTRIBUTE_PER_EVENT_COUNT_LIMIT - Max attributes per event (default: 128)
  • OTEL_SPAN_ATTRIBUTE_PER_LINK_COUNT_LIMIT - Max attributes per link (default: 128)

Batch Processor:

  • OTEL_BSP_MAX_EXPORT_BATCH_SIZE - Batch size (default: 512)
  • OTEL_BSP_MAX_QUEUE_SIZE - Queue size (default: 2048)
  • OTEL_BSP_SCHEDULE_DELAY - Export delay in ms (default: 5000)
  • OTEL_BSP_EXPORT_TIMEOUT - Timeout in ms (default: 30000)

See this entry in the whole of v2.0.18 →