From e175a115a5018056da4b09086a749e3a1f41b2a8 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 25 Jun 2026 08:53:49 +0200 Subject: [PATCH 1/5] ref: Make stream_gen_ai_spans opt out --- sentry_sdk/consts.py | 2 +- sentry_sdk/tracing.py | 2 +- sentry_sdk/tracing_utils.py | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index b85b179223..bac2bc70a5 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -1328,7 +1328,7 @@ def __init__( before_send_metric: "Optional[Callable[[Metric, Hint], Optional[Metric]]]" = None, org_id: "Optional[str]" = None, strict_trace_continuation: bool = False, - stream_gen_ai_spans: bool = False, + stream_gen_ai_spans: bool = True, ) -> None: """Initialize the Sentry SDK with the given parameters. All parameters described here can be used in a call to `sentry_sdk.init()`. diff --git a/sentry_sdk/tracing.py b/sentry_sdk/tracing.py index 6cf2527fe3..1790e13fbf 100644 --- a/sentry_sdk/tracing.py +++ b/sentry_sdk/tracing.py @@ -1042,7 +1042,7 @@ def finish( finished_spans = [] has_gen_ai_span = False - if client.options.get("stream_gen_ai_spans", False): + if client.options.get("stream_gen_ai_spans", True): for span in self._span_recorder.spans: if span.timestamp is None: continue diff --git a/sentry_sdk/tracing_utils.py b/sentry_sdk/tracing_utils.py index 0803564b8c..c3917fc31e 100644 --- a/sentry_sdk/tracing_utils.py +++ b/sentry_sdk/tracing_utils.py @@ -121,7 +121,7 @@ def should_truncate_gen_ai_input(options: "Optional[dict[str, Any]]") -> bool: return True return not options.get( - "stream_gen_ai_spans", False + "stream_gen_ai_spans", True ) and not has_span_streaming_enabled(options) From a629fe2c0afde5c1fc741239acf518a9f5d14786 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 25 Jun 2026 09:05:23 +0200 Subject: [PATCH 2/5] google-genai tests --- tests/integrations/google_genai/test_google_genai.py | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tests/integrations/google_genai/test_google_genai.py b/tests/integrations/google_genai/test_google_genai.py index fffbdcee5b..2ce458b587 100644 --- a/tests/integrations/google_genai/test_google_genai.py +++ b/tests/integrations/google_genai/test_google_genai.py @@ -1503,6 +1503,7 @@ def test_google_genai_message_truncation( integrations=[GoogleGenAIIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() @@ -2672,6 +2673,7 @@ def test_generate_content_with_function_response( integrations=[GoogleGenAIIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() @@ -2727,6 +2729,7 @@ def test_generate_content_with_mixed_string_and_content( integrations=[GoogleGenAIIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() @@ -2837,6 +2840,7 @@ def test_generate_content_with_list_of_dicts( integrations=[GoogleGenAIIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() From 07d85df3717e8f33ab8e3a0f096edcdf5bd5c0e4 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 25 Jun 2026 09:10:32 +0200 Subject: [PATCH 3/5] anthropic and openai-agents tests --- tests/integrations/anthropic/test_anthropic.py | 6 ++++++ tests/integrations/openai_agents/test_openai_agents.py | 1 + 2 files changed, 7 insertions(+) diff --git a/tests/integrations/anthropic/test_anthropic.py b/tests/integrations/anthropic/test_anthropic.py index af8657e041..b39a683e7d 100644 --- a/tests/integrations/anthropic/test_anthropic.py +++ b/tests/integrations/anthropic/test_anthropic.py @@ -3817,6 +3817,7 @@ def test_anthropic_message_truncation(sentry_init, capture_events): integrations=[AnthropicIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() @@ -3869,6 +3870,7 @@ async def test_anthropic_message_truncation_async(sentry_init, capture_events): integrations=[AnthropicIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() @@ -5337,6 +5339,7 @@ def test_message_with_base64_image(sentry_init, capture_events): integrations=[AnthropicIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() client = Anthropic(api_key="z") @@ -5531,6 +5534,7 @@ def test_message_with_base64_pdf(sentry_init, capture_events): integrations=[AnthropicIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() client = Anthropic(api_key="z") @@ -5719,6 +5723,7 @@ def test_message_with_mixed_content(sentry_init, capture_events): integrations=[AnthropicIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() client = Anthropic(api_key="z") @@ -5802,6 +5807,7 @@ def test_message_with_multiple_images_different_formats(sentry_init, capture_eve integrations=[AnthropicIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() client = Anthropic(api_key="z") diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index cb3a18582f..a68cb96b74 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -4734,6 +4734,7 @@ def test_openai_agents_message_truncation(sentry_init, capture_items): integrations=[OpenAIAgentsIntegration()], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) test_messages = [ From 93d8d7d234dad1afecceeee9e031c0995e7bab13 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 25 Jun 2026 09:14:22 +0200 Subject: [PATCH 4/5] langchain and openai tests --- tests/integrations/langchain/test_langchain.py | 1 + tests/integrations/openai/test_openai.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index 7de1c48b4c..f46cec9652 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -3018,6 +3018,7 @@ def test_langchain_message_truncation(sentry_init, capture_events): integrations=[LangchainIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index df9e7079de..1acd33374a 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -5658,6 +5658,7 @@ def test_openai_message_truncation( integrations=[OpenAIIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) client = OpenAI(api_key="z") From 6287ce29688336ba309e9821aac2bf061ea2c239 Mon Sep 17 00:00:00 2001 From: Alexander Alderman Webb Date: Thu, 25 Jun 2026 09:19:19 +0200 Subject: [PATCH 5/5] . --- tests/integrations/langgraph/test_langgraph.py | 1 + tests/integrations/litellm/test_litellm.py | 1 + 2 files changed, 2 insertions(+) diff --git a/tests/integrations/langgraph/test_langgraph.py b/tests/integrations/langgraph/test_langgraph.py index 200bd58838..fa90a89efe 100644 --- a/tests/integrations/langgraph/test_langgraph.py +++ b/tests/integrations/langgraph/test_langgraph.py @@ -2071,6 +2071,7 @@ def test_langgraph_message_truncation(sentry_init, capture_events): integrations=[LanggraphIntegration(include_prompts=True)], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events() diff --git a/tests/integrations/litellm/test_litellm.py b/tests/integrations/litellm/test_litellm.py index 39e173049b..8d0a75d834 100644 --- a/tests/integrations/litellm/test_litellm.py +++ b/tests/integrations/litellm/test_litellm.py @@ -2539,6 +2539,7 @@ def test_litellm_message_truncation(sentry_init, capture_events): disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, send_default_pii=True, + stream_gen_ai_spans=False, ) events = capture_events()