Use prompt.id to Trace All Activity from a Single User Prompt
When a user submits a prompt, Claude might make multiple API calls and run several tools. Debugging gets messy fast. The prompt.id attribute links every event back to the prompt that triggered it.
# Enable event export
export CLAUDE_CODE_ENABLE_TELEMETRY=1
export OTEL_LOGS_EXPORTER=otlp
export OTEL_EXPORTER_OTLP_ENDPOINT=http://localhost:4317
Every event emitted while processing a single prompt shares the same UUID v4 prompt.id. Filter your logs backend by a specific prompt.id and you'll get the complete chain: the user_prompt event, every api_request, and all tool_result events in sequence.
This is especially useful for debugging slow prompts. You can see exactly which tool calls took the longest, how many API roundtrips were needed, and where errors occurred. The event.sequence attribute gives you ordering within the session.
Note that prompt.id is intentionally excluded from metrics (it would create unbounded cardinality). Use it for event-level analysis and audit trails only.
One prompt, one ID, a complete trace of everything Claude did.
Log in to leave a comment.
When a page takes five seconds to load or an API endpoint times out under load, tell Claude which route is slow and it traces the entire code path — controller, services, queries, loops — identifying N+1 queries, redundant computations, missing indexes, and cacheable operations, then fixes each bottleneck.
Flaky tests are maddening — they pass locally, fail in CI, pass again when you retry. Tell Claude to read the test, identify the source of non-determinism — timing issues, shared state, date dependencies, or order-dependent setup — and fix the root cause so the test is reliably green or reliably red.
When your app throws an error, don't just Google the message — paste the full stack trace into Claude Code. It reads the trace, opens the referenced files in your codebase, follows the call chain, and pinpoints the actual root cause instead of just explaining the symptom.