[DOCS] OpenTelemetry monitoring docs do not document numeric `api_request` / `api_error` attribute types
Documentation Type
Incorrect/outdated documentation
Documentation Location
https://code.claude.com/docs/en/monitoring-usage
Section/Topic
"API request event" and "API error event" under "Available metrics and events"
Current Documentation
The docs currently say:
Event Name:claude_code.api_requestcost_usd: Estimated cost in USDduration_ms: Request duration in millisecondsinput_tokens: Number of input tokensoutput_tokens: Number of output tokenscache_read_tokens: Number of tokens read from cachecache_creation_tokens: Number of tokens used for cache creation
And for errors:
Event Name:claude_code.api_errorstatus_code: HTTP status code as a string, or"undefined"for non-HTTP errorsduration_ms: Request duration in milliseconds *attempt: Total number of attempts made, including the initial request (1means no retries occurred)
What's Wrong or Missing?
Claude Code v2.1.122 changed numeric attributes on api_request / api_error log events to be emitted as numbers rather than strings, but the monitoring page does not document that type change.
The clearest contradiction is api_error.status_code, which is still documented as "HTTP status code as a string". The page also does not explicitly tell readers that the numeric scalar fields on these two events are numeric values in the emitted telemetry payload.
That leaves telemetry consumers without a reliable schema for parsing these fields correctly.
Suggested Improvement
Update the api_request and api_error event attribute lists to document the emitted value types explicitly.
At minimum:
- change
status_codefrom "as a string" to the current numeric behavior when the value is numeric - explicitly mark numeric fields such as
cost_usd,duration_ms,input_tokens,output_tokens,cache_read_tokens,cache_creation_tokens, andattemptas numbers - add a brief version note that as of v2.1.122, numeric
api_request/api_errorattributes are emitted as numbers rather than strings
If non-HTTP failures still use a non-numeric sentinel such as "undefined" or omit status_code, document that separately so the schema is unambiguous.
Impact
Medium - Makes feature difficult to understand
Additional Context
Affected Pages:
| Page | Line(s) | Context |
|------|---------|---------|
| https://code.claude.com/docs/en/monitoring-usage | 538-582 | claude_code.api_request and claude_code.api_error event attribute tables |
Total scope: 1 page affected
Version context: Claude Code v2.1.122 changed numeric attributes on api_request / api_error log events to emit numbers instead of strings.
This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗