Export Claude Code Events with OpenTelemetry Logs
Most people know Claude Code can export OTel metrics, but it also exports detailed events via the logs protocol. This gives you a full audit trail of every tool call, API request, and user prompt.
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_PROTOCOL=grpc
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
You get four event types out of the box: claude_code.user_prompt (when a user submits input), claude_code.tool_result (when a tool finishes), claude_code.api_request (for each API call with cost and token counts), and claude_code.api_error (when requests fail).
Each event includes duration_ms, success status, and tool-specific attributes. Want to see which tools fail most? Filter by success: "false". Want to audit file changes? Look at tool_result events where tool_name is Edit or Write.
For sensitive environments, prompt content is redacted by default. Enable it explicitly with OTEL_LOG_USER_PROMPTS=1 if you need full audit logging.
Metrics tell you how much. Events tell you exactly what happened.
Log in to leave a comment.
The autoUpdatesChannel setting pins Claude Code to a stable release track that skips versions with major regressions.
The language setting makes Claude respond in your preferred language by default, across every session and project.
The attribution setting lets you customize or completely remove Claude's Co-Authored-By trailer from git commits and pull requests.