Skip to main content
Applies to:
  • Plan -
  • Deployment -

Issue

You want to send Claude Code traces to Braintrust using Claude Code’s native OpenTelemetry (OTEL) integration.

Cause

Claude Code supports OpenTelemetry-based monitoring and tracing. By default, telemetry export is disabled and must be explicitly enabled through environment variables. Braintrust exposes an OTLP-compatible ingestion endpoint that can receive Claude Code traces directly.

Resolution

Enable Claude Code Telemetry

Set the following environment variables before launching Claude Code:
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1

export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.braintrust.dev/otel"

export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer <BRAINTRUST_API_KEY>, x-bt-parent=project_id:<PROJECT_ID>"

Optional: Capture Prompt and Tool Content

To include prompts, tool invocations, and tool outputs in traces, also configure:
export OTEL_LOG_USER_PROMPTS=1
export OTEL_LOG_TOOL_DETAILS=1
export OTEL_LOG_TOOL_CONTENT=1

Launch Claude Code

Once the environment variables are configured, start Claude Code normally:
claude

Example Configuration

export CLAUDE_CODE_ENABLE_TELEMETRY=1
export CLAUDE_CODE_ENHANCED_TELEMETRY_BETA=1

export OTEL_TRACES_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/protobuf
export OTEL_EXPORTER_OTLP_ENDPOINT="https://api.braintrust.dev/otel"

export OTEL_EXPORTER_OTLP_HEADERS="Authorization=Bearer sk-my-api-key,x-bt-parent=project_id:4fd09578-7394-41d3-9ce2-917ce24c1fec"

export OTEL_LOG_USER_PROMPTS=1
export OTEL_LOG_TOOL_DETAILS=1
export OTEL_LOG_TOOL_CONTENT=1

Notes

Enabling the following options may cause sensitive data to be included in traces:
  • OTEL_LOG_USER_PROMPTS
  • OTEL_LOG_TOOL_DETAILS
  • OTEL_LOG_TOOL_CONTENT
Review your organization’s data handling policies before enabling them in production environments. The x-bt-parent header determines where traces are logged in Braintrust. Replace <PROJECT_ID> with the Braintrust project that should receive the traces.

Additional Resources

If you are able to install Claude Code plugins, we recommend using the trace-claude-code plugin from braintrust-claude-plugin instead of configuring OpenTelemetry manually. The plugin provides native Braintrust tracing for Claude Code and automatically captures sessions, conversation turns, and tool calls as hierarchical traces in Braintrust with minimal setup. :contentReference[oaicite:0] For setup instructions, see: https://www.braintrust.dev/docs/integrations/developer-tools/claude-code#plugin-trace-claude-code The OpenTelemetry configuration described in this article is most useful when:
  • You cannot install Claude Code plugins.
  • You already have an OTEL-based observability pipeline.
  • You want to route Claude Code telemetry through a custom OpenTelemetry configuration.