[DOCS] OpenTelemetry monitoring docs do not document numeric `api_request` / `api_error` attribute types

Open 💬 4 comments Opened Apr 28, 2026 by coygeek

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_request cost_usd: Estimated cost in USD duration_ms: Request duration in milliseconds input_tokens: Number of input tokens output_tokens: Number of output tokens cache_read_tokens: Number of tokens read from cache cache_creation_tokens: Number of tokens used for cache creation

And for errors:

Event Name: claude_code.api_error status_code: HTTP status code as a string, or "undefined" for non-HTTP errors duration_ms: Request duration in milliseconds * attempt: Total number of attempts made, including the initial request (1 means 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_code from "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, and attempt as numbers
  • add a brief version note that as of v2.1.122, numeric api_request / api_error attributes 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.

View original on GitHub ↗

This issue has 4 comments on GitHub. Read the full discussion on GitHub ↗