genai: define cached tokens attributes #3163
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #1959
Changes
This PR adds two new GenAI attributes to represent provider-level prompt caching:
gen_ai.usage.cache_read_input_tokensgen_ai.usage.cache_creation_input_tokensIt also updates the description of gen_ai.usage.input_tokens to state that it must include cached tokens. OpenAI and Vertex AI already count cached tokens in input_tokens, while Anthropic excludes them. Without clarification, instrumentation would produce incompatible values. Requiring input_tokens to always include cached tokens ensures a consistent, cross-provider definition of total input tokens, with the new attributes exposing the cached breakdown.
Merge requirement checklist
[chore]