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.
When Claude writes error messages, button labels, validation text, or onboarding flows, it defaults to generic developer-speak. Add a "Users" section to your CLAUDE.md describing who your actual users are — their technical level, industry jargon, and what they care about — so Claude writes copy that makes sense to THEM, not to developers.
Use the --agent flag with custom markdown files in .claude/agents/ to launch purpose-built Claude sessions with restricted tools and scoped system prompts.
Every project has traps — the billing module that silently fails if you forget to queue the job, the legacy table with column names that don't match the model, the config value that must be set before tests run. Document these gotchas in your CLAUDE.md so Claude avoids the same mistakes your team spent days debugging.