diff --git a/sentry_sdk/integrations/google_genai/streaming.py b/sentry_sdk/integrations/google_genai/streaming.py index 99e0a87b6e..86cdcf29ba 100644 --- a/sentry_sdk/integrations/google_genai/streaming.py +++ b/sentry_sdk/integrations/google_genai/streaming.py @@ -160,7 +160,7 @@ def set_span_data_for_streaming_response( if accumulated_response.get("tool_calls"): if has_data_collection_enabled(client.options): - if client.options["data_collection"]["gen_ai"]["inputs"]: + if client.options["data_collection"]["gen_ai"]["outputs"]: set_on_span( SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS, safe_serialize(accumulated_response["tool_calls"]), diff --git a/sentry_sdk/integrations/google_genai/utils.py b/sentry_sdk/integrations/google_genai/utils.py index cd2b2bc9a8..75ba30c199 100644 --- a/sentry_sdk/integrations/google_genai/utils.py +++ b/sentry_sdk/integrations/google_genai/utils.py @@ -1034,7 +1034,7 @@ def set_span_data_for_response( tool_calls = extract_tool_calls(response) if tool_calls: if has_data_collection_enabled(client.options): - if client.options["data_collection"]["gen_ai"]["inputs"]: + if client.options["data_collection"]["gen_ai"]["outputs"]: set_on_span( SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS, safe_serialize(tool_calls) ) diff --git a/tests/integrations/google_genai/test_google_genai.py b/tests/integrations/google_genai/test_google_genai.py index a31e983da0..9ea8431a7a 100644 --- a/tests/integrations/google_genai/test_google_genai.py +++ b/tests/integrations/google_genai/test_google_genai.py @@ -3841,21 +3841,15 @@ def test_generate_content_data_collection( ), pytest.param( {"gen_ai": {"inputs": True, "outputs": False}}, - [ - SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS, - SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS, - ], - [], - id="gen-ai-inputs-enabled-outputs-disabled-tools-collected", + [SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS], + [SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS], + id="gen-ai-inputs-enabled-outputs-disabled-drops-tool-calls-only", ), pytest.param( {"gen_ai": {"inputs": False, "outputs": True}}, - [], - [ - SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS, - SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS, - ], - id="gen-ai-inputs-disabled-outputs-enabled-tools-not-collected", + [SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS], + [SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS], + id="gen-ai-inputs-disabled-outputs-enabled-drops-available-tools-only", ), pytest.param( {"gen_ai": {}}, @@ -4201,21 +4195,15 @@ def test_streaming_generate_content_data_collection( ), pytest.param( {"gen_ai": {"inputs": True, "outputs": False}}, - [ - SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS, - SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS, - ], - [], - id="gen-ai-inputs-enabled-outputs-disabled-tools-collected", + [SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS], + [SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS], + id="gen-ai-inputs-enabled-outputs-disabled-drops-tool-calls-only", ), pytest.param( {"gen_ai": {"inputs": False, "outputs": True}}, - [], - [ - SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS, - SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS, - ], - id="gen-ai-inputs-disabled-outputs-enabled-tools-not-collected", + [SPANDATA.GEN_AI_RESPONSE_TOOL_CALLS], + [SPANDATA.GEN_AI_REQUEST_AVAILABLE_TOOLS], + id="gen-ai-inputs-disabled-outputs-enabled-drops-available-tools-only", ), pytest.param( {"gen_ai": {}},