claude-code - 💡(How to fix) Fix [DOCS] Monitoring usage missing v2.1.121 `llm_request` span attributes [1 participants]

Official PRs (…)
ON THIS PAGE

Recommended Tools

×6

Utilities matched from this issue’s tags and category — try them while you read without losing context.

GitHub issue graph ai analysis

Paste a GitHub issue URL. We fetch that issue, discover linked issues from bodies/comments/timeline, collect linked pull requests, and produce a structured English report.

The report is written in English Markdown for sharing and archival.

Helpful · Quick feedback

Loading…
GitHub stats
anthropics/claude-code#54172Fetched 2026-04-29 06:34:21
View on GitHub
Comments
0
Participants
1
Timeline
2
Reactions
0
Author
Participants
Timeline (top)
labeled ×2

Error Message

| error | Error message when the request failed | |

RAW_BUFFERClick to expand / collapse

Documentation Type

Incorrect/outdated documentation

Documentation Location

https://code.claude.com/docs/en/monitoring-usage

Section/Topic

Traces (beta)Span attributes for claude_code.llm_request, plus the OTEL_LOG_USER_PROMPTS gating notes for trace content

Current Documentation

The claude_code.llm_request table currently lists these attributes:

| model | Model identifier | | | gen_ai.system | Always anthropic. OpenTelemetry GenAI semantic convention | | | gen_ai.request.model | Same value as model. OpenTelemetry GenAI semantic convention | | | query_source | Subsystem that issued the request, such as repl_main_thread or a subagent name | | | speed | fast or normal | | | llm_request.context | interaction, tool, or standalone depending on the parent span | | | duration_ms | Wall-clock duration including retries | | | ttft_ms | Time to first token in milliseconds | | | input_tokens | Input token count from the API usage block | | | output_tokens | Output token count | | | cache_read_tokens | Tokens read from prompt cache | | | cache_creation_tokens | Tokens written to prompt cache | | | request_id | Anthropic API request ID from the request-id response header | | | gen_ai.response.id | Same value as request_id. OpenTelemetry GenAI semantic convention | | | client_request_id | Client-generated x-client-request-id of the final attempt | | | attempt | Total attempts made for this request | | | success | true or false | | | status_code | HTTP status code when the request failed | | | error | Error message when the request failed | | | response.has_tool_call | true when the response contained tool-use blocks | |

The same page also describes the prompt-content gate this way:

| OTEL_LOG_USER_PROMPTS | Enable logging of user prompt content (default: disabled) |

and later:

  • User prompt content is not collected by default. Only prompt length is recorded. To include prompt content, set OTEL_LOG_USER_PROMPTS=1

The v2.1.121 changelog says:

OpenTelemetry: added stop_reason, gen_ai.response.finish_reasons, and user_system_prompt (gated behind OTEL_LOG_USER_PROMPTS) to LLM request spans

What's Wrong or Missing?

The tracing reference is out of date for v2.1.121.

A. claude_code.llm_request is missing newly added span attributes

The claude_code.llm_request attribute table does not include stop_reason, gen_ai.response.finish_reasons, or user_system_prompt, even though the changelog says they were added to LLM request spans in v2.1.121.

B. The OTEL_LOG_USER_PROMPTS notes do not mention user_system_prompt

Current gating text only describes user prompt content. It does not tell telemetry users that enabling OTEL_LOG_USER_PROMPTS=1 also exposes user_system_prompt on claude_code.llm_request spans.

Suggested Improvement

Update https://code.claude.com/docs/en/monitoring-usage to reflect the v2.1.121 tracing schema:

  1. Add stop_reason, gen_ai.response.finish_reasons, and user_system_prompt to the claude_code.llm_request attribute table.
  2. Mark user_system_prompt as gated by OTEL_LOG_USER_PROMPTS.
  3. Update the OTEL_LOG_USER_PROMPTS variable description and the Security and privacy section so they explain that this flag can expose both user prompt text and user_system_prompt in traces/logs.
  4. If useful, add a short note that these fields were added in v2.1.121 so observability users can reconcile schema changes in their dashboards and pipelines.

Impact

Medium - Makes feature difficult to understand

Additional Context

Affected Pages:

PageContext
https://code.claude.com/docs/en/monitoring-usagePrimary OpenTelemetry reference; claude_code.llm_request span attribute table omits the v2.1.121 fields and the OTEL_LOG_USER_PROMPTS notes do not mention user_system_prompt
https://code.claude.com/docs/en/env-varsOTEL_LOG_USER_PROMPTS is listed here, so this page may also need a wording update if Anthropic wants env-var docs to reflect the broader gating behavior
https://code.claude.com/docs/en/agent-sdk/observabilityAgent SDK observability page sends readers to Monitoring for the full attribute list, so it is a useful cross-reference for the same telemetry surface

Total scope: 3 pages affected

Source: Changelog v2.1.121

Exact changelog entry: OpenTelemetry: added stop_reason, gen_ai.response.finish_reasons, and user_system_prompt (gated behind OTEL_LOG_USER_PROMPTS) to LLM request spans

extent analysis

TL;DR

Update the claude_code.llm_request attribute table and OTEL_LOG_USER_PROMPTS notes in the monitoring-usage documentation to reflect the changes introduced in v2.1.121.

Guidance

  • Add stop_reason, gen_ai.response.finish_reasons, and user_system_prompt to the claude_code.llm_request attribute table.
  • Mark user_system_prompt as gated by OTEL_LOG_USER_PROMPTS in the attribute table.
  • Update the OTEL_LOG_USER_PROMPTS variable description to explain that it exposes both user prompt text and user_system_prompt in traces/logs.
  • Consider adding a note about the version in which these fields were added to help users reconcile schema changes.

Example

No code snippet is necessary for this documentation update.

Notes

The changes should be applied to the primary OpenTelemetry reference page (https://code.claude.com/docs/en/monitoring-usage) and potentially to the env-vars page (https://code.claude.com/docs/en/env-vars) and the agent-sdk observability page (https://code.claude.com/docs/en/agent-sdk/observability).

Recommendation

Apply the suggested improvements to update the documentation and ensure it accurately reflects the current tracing schema.

Vote matrix · Quick signals

Works
Did the solution work? Tap to confirm.
Easy Fix
Was it a quick fix?
Time Saver
Did it save you time?
Blocking
Was it severely blocking?
Common Issue
Are others likely hitting this too?
Flaky / Intermittent
Is it intermittent?
Verified / Reproducible
Can you reproduce it reliably?
Loading…

Still need to ship something?

×6

Another batch ranked right after the header list — different links, same matching logic.

Back to top recommendations

TRENDING