One read of Claude Code CLIclaude-code-20261002T050702Z
1 pages moved out of 220 read.
Pages moved
1
significant first
Pages read
220
in this capture
Captured
05:07 UTC
Corpus hash
342ea35bfafc
corpus-hash
What this read moved
1-1 of 1monitoring-usage Changed · +21 / -4 lines
### Map input tokens to OpenTelemetry GenAI semantic conventions
from line 231
231231| `duration_ms` | Wall-clock duration including retries | |
232232| `ttft_ms` | Time to first token in milliseconds | |
233233| `first_content_ms` | Time from request start to the first content block of the successful attempt, in milliseconds. Absent on requests that fell back to the non-streaming path. Requires Claude Code v2.1.268 or later | |
234| `input_tokens` | Input token count from the API usage block | |
234| `input_tokens` | Input token count from the API usage block. Excludes tokens read from or written to the prompt cache, which are reported in `cache_read_tokens` and `cache_creation_tokens` | |
235235| `output_tokens` | Output token count | |
236236| `cache_read_tokens` | Tokens read from prompt cache | |
237237| `cache_creation_tokens` | Tokens written to prompt cache | |
from line 657
657657**Attributes**:
658658
659659* All [standard attributes](#standard-attributes)
660* `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`)
660* `type`: (`"input"`, `"output"`, `"cacheRead"`, `"cacheCreation"`). The `"input"` type excludes tokens read from or written to the prompt cache, which are counted under `"cacheRead"` and `"cacheCreation"`
661661* `model`: Model identifier (for example, "claude-sonnet-5")
662662* `query_source`: Category of the subsystem that issued the request. One of `"main"`, `"subagent"`, or `"auxiliary"`
663663* `speed`: `"fast"` when the request used fast mode. Absent otherwise
from line 796
796796* `cost_usd`: Estimated cost in USD
797797* `cost_usd_micros`: Estimated cost in millionths of a US dollar, emitted as an integer
798798* `duration_ms`: Request duration in milliseconds
799* `input_tokens`: Number of input tokens
799* `input_tokens`: Number of input tokens, excluding tokens read from or written to the prompt cache
800800* `output_tokens`: Number of output tokens
801801* `cache_read_tokens`: Number of tokens read from cache
802802* `cache_creation_tokens`: Number of tokens used for cache creation
from line 1345
13451345
13461346| Metric | Analysis Opportunity |
13471347| - | - |
1348| `claude_code.token.usage` | Break down by `type` (input/output), user, team, model, `skill.name`, `plugin.name`, or `agent.name` |
1348| `claude_code.token.usage` | Break down by token [`type`](#token-counter), user, team, model, `skill.name`, `plugin.name`, or `agent.name` |
13491349| `claude_code.session.count` | Track adoption and engagement over time |
13501350| `claude_code.lines_of_code.count` | Measure productivity by tracking code additions and removals, broken down by model |
13511351| `claude_code.commit.count` & `claude_code.pull_request.count` | Understand impact on development workflows |
from line 1398
13981398* Error patterns by tool type
13991399
14001400**Performance monitoring**: track API request durations and tool execution times to identify performance bottlenecks.
1401
1402### Map input tokens to OpenTelemetry GenAI semantic conventions
1403
1404Claude Code exports input token counts as they appear in the API response's usage block, so these values exclude tokens read from or written to the [prompt cache](/docs/en/prompt-caching):
1405
1406* `input_tokens` on the [`claude_code.llm_request`](#span-attributes) span and the [`api_request`](#api-request-event) event
1407* The `"input"` type of the [`claude_code.token.usage`](#token-counter) metric
1408
1409Claude Code doesn't set `gen_ai.usage.*` attributes. The [OpenTelemetry GenAI semantic conventions](https://github.com/open-telemetry/semantic-conventions-genai) say `gen_ai.usage.input_tokens` should include tokens read from and written to the cache. To compute that total:
1410
1411* From the span or event: add `input_tokens`, `cache_read_tokens`, and `cache_creation_tokens`
1412* From the `claude_code.token.usage` metric: add its `"input"`, `"cacheRead"`, and `"cacheCreation"` types
1413
1414The conventions also define separate attributes for cache reads and cache writes:
1415
1416* `cache_read_tokens` maps to `gen_ai.usage.cache_read.input_tokens`
1417* `cache_creation_tokens` maps to `gen_ai.usage.cache_write.input_tokens`. Older versions of the conventions name the cache write attribute `gen_ai.usage.cache_creation.input_tokens`, so use the name your backend expects.
14011418
14021419## Audit security events
14031420