diff --git a/tests/integrations/launchdarkly/test_launchdarkly.py b/tests/integrations/launchdarkly/test_launchdarkly.py index 6f7c11b6de..ceb8451a8d 100644 --- a/tests/integrations/launchdarkly/test_launchdarkly.py +++ b/tests/integrations/launchdarkly/test_launchdarkly.py @@ -7,10 +7,8 @@ from ldclient.integrations.test_data import TestData import sentry_sdk -from sentry_sdk import start_span, start_transaction from sentry_sdk.integrations import DidNotEnable from sentry_sdk.integrations.launchdarkly import LaunchDarklyIntegration -from tests.conftest import ApproxDict def test_launchdarkly_integration(sentry_init, capture_events, uninstall_integration): @@ -188,16 +186,11 @@ def test_launchdarkly_integration_did_not_enable(uninstall_integration): ) -@pytest.mark.parametrize( - "span_streaming", - [True, False], -) def test_launchdarkly_span_integration( sentry_init, capture_events, capture_items, uninstall_integration, - span_streaming, ): td = TestData.data_source() td.update(td.flag("hello").variation_for_all(True)) @@ -210,37 +203,19 @@ def test_launchdarkly_span_integration( sentry_init( traces_sample_rate=1.0, integrations=[LaunchDarklyIntegration()], - trace_lifecycle="stream" if span_streaming else "static", + trace_lifecycle="stream", ) client = ldclient.get() - if span_streaming: - items = capture_items("span") + items = capture_items("span") - with sentry_sdk.traces.start_span(name="bar"): - client.variation("hello", Context.create("my-org", "organization"), False) - client.variation("other", Context.create("my-org", "organization"), False) + with sentry_sdk.traces.start_span(name="bar"): + client.variation("hello", Context.create("my-org", "organization"), False) + client.variation("other", Context.create("my-org", "organization"), False) - sentry_sdk.flush() + sentry_sdk.flush() - assert len(items) == 1 - span = items[0].payload - assert span["attributes"]["flag.evaluation.hello"] is True - assert span["attributes"]["flag.evaluation.other"] is False - - else: - events = capture_events() - - with start_transaction(name="hi"): - with start_span(op="foo", name="bar"): - client.variation( - "hello", Context.create("my-org", "organization"), False - ) - client.variation( - "other", Context.create("my-org", "organization"), False - ) - - (event,) = events - assert event["spans"][0]["data"] == ApproxDict( - {"flag.evaluation.hello": True, "flag.evaluation.other": False} - ) + assert len(items) == 1 + span = items[0].payload + assert span["attributes"]["flag.evaluation.hello"] is True + assert span["attributes"]["flag.evaluation.other"] is False diff --git a/tests/integrations/openfeature/test_openfeature.py b/tests/integrations/openfeature/test_openfeature.py index d1c58926a8..81a4f8b610 100644 --- a/tests/integrations/openfeature/test_openfeature.py +++ b/tests/integrations/openfeature/test_openfeature.py @@ -6,9 +6,7 @@ from openfeature.provider.in_memory_provider import InMemoryFlag, InMemoryProvider import sentry_sdk -from sentry_sdk import start_span, start_transaction from sentry_sdk.integrations.openfeature import OpenFeatureIntegration -from tests.conftest import ApproxDict def test_openfeature_integration(sentry_init, capture_events, uninstall_integration): @@ -154,22 +152,17 @@ async def runner(): } -@pytest.mark.parametrize( - "span_streaming", - [True, False], -) def test_openfeature_span_integration( sentry_init, capture_events, capture_items, uninstall_integration, - span_streaming, ): uninstall_integration(OpenFeatureIntegration.identifier) sentry_init( traces_sample_rate=1.0, integrations=[OpenFeatureIntegration()], - trace_lifecycle="stream" if span_streaming else "static", + trace_lifecycle="stream", ) api.set_provider( @@ -177,28 +170,14 @@ def test_openfeature_span_integration( ) client = api.get_client() - if span_streaming: - items = capture_items("span") - with sentry_sdk.traces.start_span(name="bar"): - client.get_boolean_value("hello", default_value=False) - client.get_boolean_value("world", default_value=False) + items = capture_items("span") + with sentry_sdk.traces.start_span(name="bar"): + client.get_boolean_value("hello", default_value=False) + client.get_boolean_value("world", default_value=False) - sentry_sdk.flush() + sentry_sdk.flush() - assert len(items) == 1 - span = items[0].payload - assert span["attributes"]["flag.evaluation.hello"] is True - assert span["attributes"]["flag.evaluation.world"] is False - - else: - events = capture_events() - - with start_transaction(name="hi"): - with start_span(op="foo", name="bar"): - client.get_boolean_value("hello", default_value=False) - client.get_boolean_value("world", default_value=False) - - (event,) = events - assert event["spans"][0]["data"] == ApproxDict( - {"flag.evaluation.hello": True, "flag.evaluation.world": False} - ) + assert len(items) == 1 + span = items[0].payload + assert span["attributes"]["flag.evaluation.hello"] is True + assert span["attributes"]["flag.evaluation.world"] is False diff --git a/tests/integrations/requests/test_requests.py b/tests/integrations/requests/test_requests.py index 9cd7cadf11..506fa57ad5 100644 --- a/tests/integrations/requests/test_requests.py +++ b/tests/integrations/requests/test_requests.py @@ -108,35 +108,6 @@ def test_crumb_capture_client_error( @pytest.mark.tests_internal_exceptions def test_omit_url_data_if_parsing_fails(sentry_init, capture_events): - sentry_init(integrations=[StdlibIntegration()]) - - events = capture_events() - - url = f"http://localhost:{PORT}/ok" # noqa:E231 - - with mock.patch( - "sentry_sdk.integrations.stdlib.parse_url", - side_effect=ValueError, - ): - response = requests.get(url) - - capture_message("Testing!") - - (event,) = events - assert event["breadcrumbs"]["values"][0]["data"] == ApproxDict( - { - SPANDATA.HTTP_REQUEST_METHOD: "GET", - SPANDATA.HTTP_STATUS_CODE: response.status_code, - # no url related data - } - ) - assert "url" not in event["breadcrumbs"]["values"][0]["data"] - assert SPANDATA.HTTP_FRAGMENT not in event["breadcrumbs"]["values"][0]["data"] - assert SPANDATA.HTTP_QUERY not in event["breadcrumbs"]["values"][0]["data"] - - -@pytest.mark.tests_internal_exceptions -def test_omit_url_data_if_parsing_fails_span_streaming(sentry_init, capture_events): sentry_init( integrations=[StdlibIntegration()], trace_lifecycle="stream", diff --git a/tests/integrations/statsig/test_statsig.py b/tests/integrations/statsig/test_statsig.py index d2b09126dd..313d78d9f3 100644 --- a/tests/integrations/statsig/test_statsig.py +++ b/tests/integrations/statsig/test_statsig.py @@ -8,9 +8,7 @@ from statsig.statsig_user import StatsigUser import sentry_sdk -from sentry_sdk import start_span, start_transaction from sentry_sdk.integrations.statsig import StatsigIntegration -from tests.conftest import ApproxDict @contextmanager @@ -183,12 +181,11 @@ def test_wrapper_attributes(sentry_init, uninstall_integration): statsig.check_gate = original_check_gate -@pytest.mark.parametrize( - "span_streaming", - [True, False], -) def test_statsig_span_integration( - sentry_init, capture_events, capture_items, uninstall_integration, span_streaming + sentry_init, + capture_events, + capture_items, + uninstall_integration, ): uninstall_integration(StatsigIntegration.identifier) @@ -196,31 +193,18 @@ def test_statsig_span_integration( sentry_init( traces_sample_rate=1.0, integrations=[StatsigIntegration()], - trace_lifecycle="stream" if span_streaming else "static", + trace_lifecycle="stream", ) user = StatsigUser(user_id="user-id") - if span_streaming: - items = capture_items("span") - with sentry_sdk.traces.start_span(name="hi"): - statsig.check_gate(user, "hello") - statsig.check_gate(user, "world") - - sentry_sdk.flush() - - assert len(items) == 1 - span = items[0].payload - assert span["attributes"]["flag.evaluation.hello"] is True - assert span["attributes"]["flag.evaluation.world"] is False - - else: - events = capture_events() - with start_transaction(name="hi"): - with start_span(op="foo", name="bar"): - statsig.check_gate(user, "hello") - statsig.check_gate(user, "world") - - (event,) = events - assert event["spans"][0]["data"] == ApproxDict( - {"flag.evaluation.hello": True, "flag.evaluation.world": False} - ) + items = capture_items("span") + with sentry_sdk.traces.start_span(name="hi"): + statsig.check_gate(user, "hello") + statsig.check_gate(user, "world") + + sentry_sdk.flush() + + assert len(items) == 1 + span = items[0].payload + assert span["attributes"]["flag.evaluation.hello"] is True + assert span["attributes"]["flag.evaluation.world"] is False diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index 48a4e5be28..be8bf13e8c 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -418,7 +418,7 @@ def getresponse(self, *args, **kwargs): assert request_headers["baggage"] == expected_outgoing_baggage -def test_outgoing_trace_headers_span_streaming_no_current_span(sentry_init): +def test_outgoing_trace_headers_no_current_span(sentry_init): """ With span streaming enabled and no active span, trace propagation headers should still be attached to outgoing requests, propagated from the scope's diff --git a/tests/integrations/tornado/test_tornado.py b/tests/integrations/tornado/test_tornado.py index ed22b052ee..dc42c296d9 100644 --- a/tests/integrations/tornado/test_tornado.py +++ b/tests/integrations/tornado/test_tornado.py @@ -438,51 +438,6 @@ def test_oversized_request_body_not_annotated_data_collection( assert "http.request.body.data" not in server_span["attributes"] -@pytest.mark.parametrize( - "data_collection, expect_body", - [ - pytest.param({}, True, id="data_collection_http_bodies_default"), - pytest.param( - {"http_bodies": ["incoming_request"]}, - True, - id="data_collection_http_bodies_incoming_request", - ), - pytest.param( - {"http_bodies": ["outgoing_request"]}, - False, - id="data_collection_http_bodies_outgoing_request_only", - ), - pytest.param( - {"http_bodies": []}, False, id="data_collection_http_bodies_empty" - ), - ], -) -def test_request_body_data_collection_span_streaming( - tornado_testcase, sentry_init, capture_items, data_collection, expect_body -): - sentry_init( - integrations=[TornadoIntegration()], - traces_sample_rate=1.0, - trace_lifecycle="stream", - _experiments={"data_collection": data_collection}, - ) - - items = capture_items("span") - - client = tornado_testcase(Application([(r"/hi", HelloHandler)])) - response = client.fetch("/hi", method="POST", body=b"heyoo") - assert response.code == 200 - - sentry_sdk.flush() - - (server_span,) = [item.payload for item in items] - - if expect_body: - assert server_span["attributes"]["http.request.body.data"] == "heyoo" - else: - assert "http.request.body.data" not in server_span["attributes"] - - @pytest.mark.parametrize( "data_collection, expect_body", [ @@ -533,34 +488,6 @@ def test_request_body_data_collection_event_processor( assert "data" not in event["request"] -def test_oversized_request_body_not_annotated_data_collection_span_streaming( - tornado_testcase, sentry_init, capture_items -): - """ - The gating happens before the size check, so an oversized body is dropped - outright instead of being reported as removed because of the size limit. - """ - sentry_init( - integrations=[TornadoIntegration()], - traces_sample_rate=1.0, - trace_lifecycle="stream", - max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, - ) - - items = capture_items("span") - - client = tornado_testcase(Application([(r"/hi", HelloHandler)])) - response = client.fetch("/hi", method="POST", body=b"a" * 2000) - assert response.code == 200 - - sentry_sdk.flush() - - (server_span,) = [item.payload for item in items] - - assert "http.request.body.data" not in server_span["attributes"] - - @pytest.mark.parametrize("send_pii", [True, False]) @pytest.mark.parametrize( "handler,code", diff --git a/tests/integrations/unleash/test_unleash.py b/tests/integrations/unleash/test_unleash.py index 42532e157a..ca8ecca994 100644 --- a/tests/integrations/unleash/test_unleash.py +++ b/tests/integrations/unleash/test_unleash.py @@ -6,9 +6,7 @@ from UnleashClient import UnleashClient import sentry_sdk -from sentry_sdk import start_span, start_transaction from sentry_sdk.integrations.unleash import UnleashIntegration -from tests.conftest import ApproxDict from tests.integrations.unleash.testutils import mock_unleash_client @@ -166,12 +164,11 @@ def test_wrapper_attributes(sentry_init, uninstall_integration): assert client.is_enabled.__qualname__ == original_is_enabled.__qualname__ -@pytest.mark.parametrize( - "span_streaming", - [True, False], -) def test_unleash_span_integration( - sentry_init, capture_events, capture_items, uninstall_integration, span_streaming + sentry_init, + capture_events, + capture_items, + uninstall_integration, ): uninstall_integration(UnleashIntegration.identifier) @@ -179,32 +176,19 @@ def test_unleash_span_integration( sentry_init( traces_sample_rate=1.0, integrations=[UnleashIntegration()], - trace_lifecycle="stream" if span_streaming else "static", + trace_lifecycle="stream", ) client = UnleashClient() # type: ignore[arg-type] - if span_streaming: - items = capture_items("span") - with sentry_sdk.traces.start_span(name="bar"): - client.is_enabled("hello") - client.is_enabled("other") - - sentry_sdk.flush() - - assert len(items) == 1 - span = items[0].payload - assert span["attributes"]["flag.evaluation.hello"] is True - assert span["attributes"]["flag.evaluation.other"] is False - - else: - events = capture_events() - with start_transaction(name="hi"): - with start_span(op="foo", name="bar"): - client.is_enabled("hello") - client.is_enabled("other") - - (event,) = events - assert event["spans"][0]["data"] == ApproxDict( - {"flag.evaluation.hello": True, "flag.evaluation.other": False} - ) + items = capture_items("span") + with sentry_sdk.traces.start_span(name="bar"): + client.is_enabled("hello") + client.is_enabled("other") + + sentry_sdk.flush() + + assert len(items) == 1 + span = items[0].payload + assert span["attributes"]["flag.evaluation.hello"] is True + assert span["attributes"]["flag.evaluation.other"] is False