From 1b6d0392fe1269f6158c1f00d13999f6e64359e2 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Tue, 17 Nov 2026 09:53:27 +0100 Subject: [PATCH] fix(bedrock): Use non-deprecated token attributes --- sentry_sdk/integrations/boto3/_services/bedrock.py | 10 ++++++---- tests/integrations/boto3/test_bedrock.py | 8 ++++---- 2 files changed, 10 insertions(+), 8 deletions(-) diff --git a/sentry_sdk/integrations/boto3/_services/bedrock.py b/sentry_sdk/integrations/boto3/_services/bedrock.py index 8c73c20232..3efaf1a9a7 100644 --- a/sentry_sdk/integrations/boto3/_services/bedrock.py +++ b/sentry_sdk/integrations/boto3/_services/bedrock.py @@ -107,14 +107,15 @@ def sentry_patched_iter( if cache_read_tokens is not None: input_tokens += cache_read_tokens span.set_attribute( - SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHED, cache_read_tokens + SPANDATA.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, + cache_read_tokens, ) cache_write_tokens = usage.get("cacheWriteInputTokens") if cache_write_tokens is not None: input_tokens += cache_write_tokens span.set_attribute( - SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE, + SPANDATA.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, cache_write_tokens, ) @@ -693,14 +694,15 @@ def on_success_response( if cache_read_tokens is not None: input_tokens += cache_read_tokens span.set_attribute( - SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHED, cache_read_tokens + SPANDATA.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS, cache_read_tokens ) cache_write_tokens = usage.get("cacheWriteInputTokens") if cache_write_tokens is not None: input_tokens += cache_write_tokens span.set_attribute( - SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE, cache_write_tokens + SPANDATA.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS, + cache_write_tokens, ) span.set_attribute(SPANDATA.GEN_AI_USAGE_INPUT_TOKENS, input_tokens) diff --git a/tests/integrations/boto3/test_bedrock.py b/tests/integrations/boto3/test_bedrock.py index 370d8706de..8ccb8803a2 100644 --- a/tests/integrations/boto3/test_bedrock.py +++ b/tests/integrations/boto3/test_bedrock.py @@ -476,8 +476,8 @@ def test_converse( assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS] == 10 return assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS] == 110 - assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHED] == 80 - assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE] == 20 + assert span["attributes"][SPANDATA.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] == 80 + assert span["attributes"][SPANDATA.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS] == 20 def test_converse_error( @@ -782,8 +782,8 @@ def test_converse_stream( assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS] == 10 return assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS] == 110 - assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHED] == 80 - assert span["attributes"][SPANDATA.GEN_AI_USAGE_INPUT_TOKENS_CACHE_WRITE] == 20 + assert span["attributes"][SPANDATA.GEN_AI_USAGE_CACHE_READ_INPUT_TOKENS] == 80 + assert span["attributes"][SPANDATA.GEN_AI_USAGE_CACHE_CREATION_INPUT_TOKENS] == 20 def test_converse_stream_error_during_iteration(