From afb6041e941da27c5d37896ffe54d3aee279d069 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Sep 2026 16:25:32 +0200 Subject: [PATCH 1/4] chore(flags): Remove transaction-based tracing --- sentry_sdk/feature_flags.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/sentry_sdk/feature_flags.py b/sentry_sdk/feature_flags.py index 5eaa5e440b..6f6ab41b43 100644 --- a/sentry_sdk/feature_flags.py +++ b/sentry_sdk/feature_flags.py @@ -4,8 +4,6 @@ import sentry_sdk from sentry_sdk._lru_cache import LRUCache -from sentry_sdk.tracing import Span -from sentry_sdk.tracing_utils import has_span_streaming_enabled if TYPE_CHECKING: from typing import TypedDict @@ -59,17 +57,10 @@ def add_feature_flag(flag: str, result: bool) -> None: Records a flag and its value to be sent on subsequent error events. We recommend you do this on flag evaluations. Flags are buffered per Sentry scope. """ - client = sentry_sdk.get_client() flags = sentry_sdk.get_isolation_scope().flags flags.set(flag, result) - if has_span_streaming_enabled(client.options): - span = sentry_sdk.traces.get_current_span() - if span and isinstance(span, sentry_sdk.traces.StreamedSpan): - span.set_attribute(f"flag.evaluation.{flag}", result) - - else: - span = sentry_sdk.get_current_span() - if span and isinstance(span, Span): - span.set_flag(f"flag.evaluation.{flag}", result) + span = sentry_sdk.traces.get_current_span() + if span is not None: + span.set_attribute(f"flag.evaluation.{flag}", result) From 936e6327d5f732d580f92d14143ba865be4cf17f Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Sep 2026 16:29:52 +0200 Subject: [PATCH 2/4] tests --- tests/test_feature_flags.py | 36 +++++++++++++----------------------- 1 file changed, 13 insertions(+), 23 deletions(-) diff --git a/tests/test_feature_flags.py b/tests/test_feature_flags.py index b2f1f900d1..b25ba46eff 100644 --- a/tests/test_feature_flags.py +++ b/tests/test_feature_flags.py @@ -5,9 +5,7 @@ import pytest import sentry_sdk -from sentry_sdk import start_span, start_transaction from sentry_sdk.feature_flags import FlagBuffer, add_feature_flag -from tests.conftest import ApproxDict def test_featureflags_integration(sentry_init, capture_events, uninstall_integration): @@ -34,6 +32,7 @@ def test_featureflags_integration(sentry_init, capture_events, uninstall_integra async def test_featureflags_integration_spans_async(sentry_init, capture_events): sentry_init( traces_sample_rate=1.0, + trace_lifecycle="stream", ) events = capture_events() @@ -62,6 +61,7 @@ async def test_featureflags_integration_spans_async(sentry_init, capture_events) def test_featureflags_integration_spans_sync(sentry_init, capture_events): sentry_init( traces_sample_rate=1.0, + trace_lifecycle="stream", ) events = capture_events() @@ -279,13 +279,13 @@ def reader(): assert error_occurred is False -def test_flag_limit(sentry_init, capture_events): - sentry_init(traces_sample_rate=1.0) +def test_flag_limit(sentry_init, capture_items): + sentry_init(traces_sample_rate=1.0, trace_lifecycle="stream") - events = capture_events() + items = capture_items("span") - with start_transaction(name="hi"): - with start_span(op="foo", name="bar"): + with sentry_sdk.start_span(name="hi"): + with sentry_sdk.start_span(op="foo", name="bar"): add_feature_flag("0", True) add_feature_flag("1", True) add_feature_flag("2", True) @@ -298,19 +298,9 @@ def test_flag_limit(sentry_init, capture_events): add_feature_flag("9", True) add_feature_flag("10", True) - (event,) = events - assert event["spans"][0]["data"] == ApproxDict( - { - "flag.evaluation.0": True, - "flag.evaluation.1": True, - "flag.evaluation.2": True, - "flag.evaluation.3": True, - "flag.evaluation.4": True, - "flag.evaluation.5": True, - "flag.evaluation.6": True, - "flag.evaluation.7": True, - "flag.evaluation.8": True, - "flag.evaluation.9": True, - } - ) - assert "flag.evaluation.10" not in event["spans"][0]["data"] + sentry_sdk.flush() + + span = next(item.payload for item in items if item.payload.get("op") == "foo") + for i in range(10): + assert span["attributes"][f"flag.evaluation.{i}"] is True + assert "flag.evaluation.10" not in span["attributes"] From 8cce14efe453aa59b6c70307073b7f2896fc053a Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Sep 2026 16:43:01 +0200 Subject: [PATCH 3/4] wtf --- sentry_sdk/traces.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/sentry_sdk/traces.py b/sentry_sdk/traces.py index 0799f7cba0..1f96f4a383 100644 --- a/sentry_sdk/traces.py +++ b/sentry_sdk/traces.py @@ -20,7 +20,6 @@ try_autostart_continuous_profiler, try_profile_lifecycle_trace_start, ) -from sentry_sdk.tracing_utils import Baggage from sentry_sdk.utils import ( capture_internal_exceptions, deprecation_warning, @@ -885,3 +884,7 @@ def get_current_span( scope = scope or sentry_sdk.get_current_scope() current_span = scope.streamed_span return current_span + + +# Circular import +from sentry_sdk.tracing_utils import Baggage # noqa: E402, F401, I001 From 4f461286c021fb348bbd71116596545cfe003da9 Mon Sep 17 00:00:00 2001 From: Ivana Kellyer Date: Tue, 8 Sep 2026 16:49:06 +0200 Subject: [PATCH 4/4] remove limit test --- tests/test_feature_flags.py | 27 --------------------------- 1 file changed, 27 deletions(-) diff --git a/tests/test_feature_flags.py b/tests/test_feature_flags.py index b25ba46eff..292d7f61c5 100644 --- a/tests/test_feature_flags.py +++ b/tests/test_feature_flags.py @@ -277,30 +277,3 @@ def reader(): # shared resource. When deepcopying we should have exclusive access to the underlying # memory. assert error_occurred is False - - -def test_flag_limit(sentry_init, capture_items): - sentry_init(traces_sample_rate=1.0, trace_lifecycle="stream") - - items = capture_items("span") - - with sentry_sdk.start_span(name="hi"): - with sentry_sdk.start_span(op="foo", name="bar"): - add_feature_flag("0", True) - add_feature_flag("1", True) - add_feature_flag("2", True) - add_feature_flag("3", True) - add_feature_flag("4", True) - add_feature_flag("5", True) - add_feature_flag("6", True) - add_feature_flag("7", True) - add_feature_flag("8", True) - add_feature_flag("9", True) - add_feature_flag("10", True) - - sentry_sdk.flush() - - span = next(item.payload for item in items if item.payload.get("op") == "foo") - for i in range(10): - assert span["attributes"][f"flag.evaluation.{i}"] is True - assert "flag.evaluation.10" not in span["attributes"]