Describe your environment
opentelemetry-instrumentation-botocore: 0.61b0 (gap also present on main)
- Python 3.11; Amazon Bedrock
ConverseStream
What happened?
When invoking Amazon Bedrock with prompt caching
enabled, the spans drop the cache token usage. Bedrock returns
cacheReadInputTokens and cacheWriteInputTokens in the response usage,
but the instrumentation reads only inputTokens / outputTokens in
_converse_on_success (extensions/bedrock.py) — so
gen_ai.usage.cache_read.input_tokens and
gen_ai.usage.cache_creation.input_tokens are never emitted.
Net effect: any cost/usage analysis built on these spans is incomplete for
cached requests.
Expected behavior
When the Bedrock response usage includes cacheReadInputTokens /
cacheWriteInputTokens, the span should carry the corresponding OTel GenAI
semconv attributes gen_ai.usage.cache_read.input_tokens /
gen_ai.usage.cache_creation.input_tokens (both already defined in
opentelemetry-semantic-conventions).
Additional context
I have a fix ready and will open a PR.
Describe your environment
opentelemetry-instrumentation-botocore: 0.61b0 (gap also present onmain)ConverseStreamWhat happened?
When invoking Amazon Bedrock with prompt caching
enabled, the spans drop the cache token usage. Bedrock returns
cacheReadInputTokensandcacheWriteInputTokensin the responseusage,but the instrumentation reads only
inputTokens/outputTokensin_converse_on_success(extensions/bedrock.py) — sogen_ai.usage.cache_read.input_tokensandgen_ai.usage.cache_creation.input_tokensare never emitted.Net effect: any cost/usage analysis built on these spans is incomplete for
cached requests.
Expected behavior
When the Bedrock response
usageincludescacheReadInputTokens/cacheWriteInputTokens, the span should carry the corresponding OTel GenAIsemconv attributes
gen_ai.usage.cache_read.input_tokens/gen_ai.usage.cache_creation.input_tokens(both already defined inopentelemetry-semantic-conventions).Additional context
I have a fix ready and will open a PR.