Skip to main content
Claude Code has built-in OpenTelemetry. It emits log-events (not spans): api_request, tool_result, user_prompt, api_error, and tool_decision. RunAgain accepts these at its OTLP logs endpoint (/v1/logs) and turns each event into a span, grouping every session.id into a single trace.
This captures Claude Code running in your terminal — every session becomes one trace with its prompts, tool calls, API requests, token usage and cost.

1. Generate an API key

In your project: Overview → onboarding → Claude Code (CLI) → Generate API key (or Settings → Create API key). Copy the sk_… value.

2. Enable telemetry

Add these to your shell profile, or to ~/.claude/settings.json under "env":
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=http/json
export OTEL_EXPORTER_OTLP_LOGS_ENDPOINT=https://ingest.runagain.ai/v1/logs
export OTEL_EXPORTER_OTLP_LOGS_HEADERS="x-runagain-key=<your key>"

# optional: flush every 5s while testing, and capture prompt text
export OTEL_LOGS_EXPORT_INTERVAL=5000
export OTEL_LOG_USER_PROMPTS=1
The endpoint decodes OTLP/JSON only, so OTEL_EXPORTER_OTLP_PROTOCOL=http/json is required. Use the logs-specific endpoint (/v1/logs) and header variables so metrics export (if you enable it elsewhere) isn’t affected.

3. Run Claude Code

claude   # use Claude Code normally — each session shows up as a trace

What you’ll see

Each session becomes one trace on your Traces page:
  • claude_code.api_request → a generation span with provider anthropic, the model, input/output/cache tokens, and cost.
  • claude_code.tool_result / tool_decisiontool spans (failures are marked as errors).
  • claude_code.user_prompt → the prompt (when OTEL_LOG_USER_PROMPTS=1).
Cost comes from Claude Code’s own cost_usd, so it’s accurate regardless of RunAgain’s pricing table.