diff --git a/sentry_sdk/consts.py b/sentry_sdk/consts.py index 856a18f39a..b6c546d19a 100644 --- a/sentry_sdk/consts.py +++ b/sentry_sdk/consts.py @@ -1316,6 +1316,7 @@ def __init__( transport_queue_size: int = DEFAULT_QUEUE_SIZE, sample_rate: float = 1.0, send_default_pii: "Optional[bool]" = None, + data_collection: "Optional[DataCollectionUserOptions]" = None, http_proxy: "Optional[str]" = None, https_proxy: "Optional[str]" = None, ignore_errors: "Sequence[Union[type, str]]" = [], # noqa: B006 @@ -1472,6 +1473,23 @@ def __init__( If you enable this option, be sure to manually remove what you don't want to send using our features for managing `Sensitive Data `_. + :param data_collection: Structured configuration controlling what data integrations collect + automatically, superseding `send_default_pii`. Passing a dict opts into the feature; omitted + fields use their defaults (most categories are collected, with the sensitive denylist + scrubbing values). When it is not set, the SDK derives behaviour from `send_default_pii` so + that upgrading changes nothing. Restrict collection per category (user identity, cookies, + HTTP headers/bodies, query params, generative AI inputs/outputs, stack frame variables, + source context). If `send_default_pii` is also set, `data_collection` takes precedence. + + Example:: + + sentry_sdk.init( + dsn="...", + data_collection={"user_info": False, "http_bodies": []}, + ) + + See https://docs.sentry.io/platforms/python/configuration/options/#data_collection for more details. + :param event_scrubber: Scrubs the event payload for sensitive information such as cookies, sessions, and passwords from a `denylist`. @@ -1807,24 +1825,6 @@ def __init__( `trace_lifecycle="stream"` is enabled. :param _experiments: Dictionary of experimental, opt-in features that are not yet stable. - - ``data_collection`` (EXPERIMENTAL): structured configuration controlling what data integrations - collect automatically, superseding `send_default_pii`. Passing a dict under - `_experiments={"data_collection": {...}}` opts into the feature; omitted fields use their - defaults (most categories are collected, with the sensitive denylist scrubbing values). - When it is not set, the SDK derives behaviour from `send_default_pii` so that upgrading - changes nothing. Restrict collection per category (user identity, cookies, HTTP - headers/bodies, query params, generative AI inputs/outputs, stack frame variables, source - context). If `send_default_pii` is also set, `data_collection` takes precedence. - - Example:: - - sentry_sdk.init( - dsn="...", - _experiments={"data_collection": {"user_info": False, "http_bodies": []}}, - ) - - See https://docs.sentry.io/platforms/python/configuration/options/#data_collection for more details. """ pass diff --git a/sentry_sdk/data_collection.py b/sentry_sdk/data_collection.py index 9d83e19819..2491e55623 100644 --- a/sentry_sdk/data_collection.py +++ b/sentry_sdk/data_collection.py @@ -293,8 +293,15 @@ def _resolve_data_collection(options: "Dict[str, Any]") -> "DataCollection": concrete values for every field. ``data_collection`` must be a plain ``dict``. + + Must be called exactly once per options dict, before ``client._get_options`` + overwrites ``options["data_collection"]`` with the resolved result. Feeding an + already-resolved dict back in would flip ``provided_by_user`` to ``True``. """ - user_dc = options.get("_experiments", {}).get("data_collection") + user_dc = options.get("data_collection") + if user_dc is None: + user_dc = options.get("_experiments", {}).get("data_collection") + send_default_pii = options.get("send_default_pii") include_local_variables = ( diff --git a/sentry_sdk/utils.py b/sentry_sdk/utils.py index 60a3eec957..2e20a789b8 100644 --- a/sentry_sdk/utils.py +++ b/sentry_sdk/utils.py @@ -64,6 +64,7 @@ from sentry_sdk._types import ( AttributeValue, + DataCollection, Event, ExcInfo, Hint, @@ -2109,7 +2110,13 @@ def has_data_collection_enabled(options: "Optional[dict[str, Any]]") -> bool: if options is None: return False - return "data_collection" in options.get("_experiments", {}) + data_collection: "Optional[DataCollection]" = options.get("data_collection") + # Client options are resolved as part of client initialization, so `data_collection` + # being None could be that the user just didn't provide it. + # `provided_by_user` is what actually records whether the user actually configured it. + return data_collection is not None and data_collection.get( + "provided_by_user", False + ) def get_before_send_log( diff --git a/tests/integrations/aiohttp/test_aiohttp.py b/tests/integrations/aiohttp/test_aiohttp.py index 434cee80f2..1c3166de64 100644 --- a/tests/integrations/aiohttp/test_aiohttp.py +++ b/tests/integrations/aiohttp/test_aiohttp.py @@ -155,7 +155,7 @@ async def test_aiohttp_request_body_data_collection( ): sentry_init( integrations=[AioHttpIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) body = {"some": "value"} @@ -207,7 +207,7 @@ async def test_aiohttp_oversized_request_body_data_collection( sentry_init( integrations=[AioHttpIntegration()], max_request_body_size="small", - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) body = "a" * 2000 @@ -643,10 +643,8 @@ async def handler(request): ({"send_default_pii": False}, False, False), ( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": []} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": []} } }, True, @@ -654,10 +652,8 @@ async def handler(request): ), ( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": []} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": []} } }, True, @@ -794,10 +790,8 @@ async def handler(request): ({"send_default_pii": False}, False, False), ( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": []} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": []} } }, True, @@ -805,10 +799,8 @@ async def handler(request): ), ( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": []} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": []} } }, True, @@ -1678,7 +1670,7 @@ async def hello(request): pytest.param( { "send_default_pii": True, - "data_collection": None, + "data_collection": {}, }, { "authorization": "[Filtered]", @@ -1690,7 +1682,7 @@ async def hello(request): pytest.param( { "send_default_pii": False, - "data_collection": None, + "data_collection": {}, }, { "authorization": "[Filtered]", @@ -1794,9 +1786,7 @@ async def test_sensitive_header_passthrough_with_pii_span_streaming( traces_sample_rate=1.0, send_default_pii=options["send_default_pii"], trace_lifecycle="stream", - _experiments={ - "data_collection": options["data_collection"], - }, + data_collection=options["data_collection"], ) async def hello(request): @@ -2256,16 +2246,14 @@ async def hello(request): id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -2273,10 +2261,8 @@ async def hello(request): ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -2284,24 +2270,22 @@ async def hello(request): ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - {"_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}}, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -2422,7 +2406,7 @@ async def hello(request): assert event["request"]["url"] == "http://{host}/".format(host=host) assert event["request"]["method"] == "GET" - if "data_collection" not in init_kwargs.get("_experiments", {}): + if "data_collection" not in init_kwargs: assert ( event["request"]["query_string"] == "toy=tennisball&color=red&auth=secret" ) diff --git a/tests/integrations/aiomysql/test_aiomysql.py b/tests/integrations/aiomysql/test_aiomysql.py index 32f2a22538..28f24c27a4 100644 --- a/tests/integrations/aiomysql/test_aiomysql.py +++ b/tests/integrations/aiomysql/test_aiomysql.py @@ -218,7 +218,7 @@ async def test_execute_many_record_params_with_data_collection_enabled( ) -> None: sentry_init( integrations=[AioMySQLIntegration()], - _experiments={"data_collection": {"database_query_data": True}}, + data_collection={"database_query_data": True}, ) events = capture_events() @@ -266,7 +266,7 @@ async def test_execute_many_record_params_with_data_collection_disabled( ) -> None: sentry_init( integrations=[AioMySQLIntegration(record_params=True)], - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -307,7 +307,7 @@ async def test_execute_many_record_params_with_data_collection_default( ) -> None: sentry_init( integrations=[AioMySQLIntegration()], - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -444,7 +444,7 @@ async def test_execute_record_params_with_data_collection_enabled( ) -> None: sentry_init( integrations=[AioMySQLIntegration()], - _experiments={"data_collection": {"database_query_data": True}}, + data_collection={"database_query_data": True}, ) events = capture_events() @@ -485,7 +485,7 @@ async def test_execute_record_params_with_data_collection_disabled( ) -> None: sentry_init( integrations=[AioMySQLIntegration(record_params=True)], - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -523,7 +523,7 @@ async def test_execute_record_params_with_data_collection_default( ) -> None: sentry_init( integrations=[AioMySQLIntegration()], - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() diff --git a/tests/integrations/anthropic/test_anthropic.py b/tests/integrations/anthropic/test_anthropic.py index 9711beb3d5..b3835c4b72 100644 --- a/tests/integrations/anthropic/test_anthropic.py +++ b/tests/integrations/anthropic/test_anthropic.py @@ -403,7 +403,7 @@ def test_nonstreaming_create_message_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = Anthropic(api_key="z") @@ -492,7 +492,7 @@ def test_nonstreaming_create_message_data_collection_tools( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = Anthropic(api_key="z") @@ -587,7 +587,7 @@ async def test_nonstreaming_create_message_data_collection_async( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = AsyncAnthropic(api_key="z") @@ -705,7 +705,7 @@ def test_nonstreaming_create_message_data_collection_outputs( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = Anthropic(api_key="z") @@ -833,7 +833,7 @@ async def test_nonstreaming_create_message_data_collection_outputs_async( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = AsyncAnthropic(api_key="z") @@ -1390,7 +1390,7 @@ def test_streaming_create_message_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = Anthropic(api_key="z") @@ -1539,7 +1539,7 @@ def test_streaming_create_message_data_collection_outputs( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = Anthropic(api_key="z") @@ -2346,7 +2346,7 @@ def test_stream_messages_data_collection_outputs( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = Anthropic(api_key="z") @@ -3175,7 +3175,7 @@ async def test_streaming_create_message_data_collection_outputs_async( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = AsyncAnthropic(api_key="z") @@ -3992,7 +3992,7 @@ async def test_stream_messages_data_collection_outputs_async( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) client = AsyncAnthropic(api_key="z") diff --git a/tests/integrations/ariadne/test_ariadne.py b/tests/integrations/ariadne/test_ariadne.py index 616a3b9746..6f8b3b5199 100644 --- a/tests/integrations/ariadne/test_ariadne.py +++ b/tests/integrations/ariadne/test_ariadne.py @@ -326,43 +326,31 @@ def _init_all_integrations(sentry_init, **kwargs): "init_kwargs,expect_query,expect_variables", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, True, id="data_collection_defaults", ), pytest.param( - { - "_experiments": { - "data_collection": { - "graphql": {"document": True, "variables": True} - } - } - }, + {"data_collection": {"graphql": {"document": True, "variables": True}}}, True, True, id="document_on_variables_on", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"document": False}}}}, + {"data_collection": {"graphql": {"document": False}}}, False, True, id="document_off_variables_on", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"variables": False}}}}, + {"data_collection": {"graphql": {"variables": False}}}, True, False, id="document_on_variables_off", ), pytest.param( - { - "_experiments": { - "data_collection": { - "graphql": {"document": False, "variables": False} - } - } - }, + {"data_collection": {"graphql": {"document": False, "variables": False}}}, None, None, id="document_off_variables_off", @@ -370,7 +358,7 @@ def _init_all_integrations(sentry_init, **kwargs): pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"graphql": {"document": False}}}, + "data_collection": {"graphql": {"document": False}}, }, False, True, @@ -379,7 +367,7 @@ def _init_all_integrations(sentry_init, **kwargs): pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"graphql": {"document": True}}}, + "data_collection": {"graphql": {"document": True}}, }, True, True, @@ -426,7 +414,7 @@ def test_request_data_collection_body_out_of_bounds_still_collects_variables( _init_all_integrations( sentry_init, max_request_body_size="small", - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -456,9 +444,7 @@ def test_response_data_collection( sentry_init, capture_events, graphql_client, http_bodies, expect_response ): data_collection = {} if http_bodies is None else {"http_bodies": http_bodies} - _init_all_integrations( - sentry_init, _experiments={"data_collection": data_collection} - ) + _init_all_integrations(sentry_init, data_collection=data_collection) events = capture_events() graphql_client().post("/graphql", json={"query": "query ErrorQuery {error}"}) diff --git a/tests/integrations/asgi/test_asgi.py b/tests/integrations/asgi/test_asgi.py index 7f1924128e..2de17ab15a 100644 --- a/tests/integrations/asgi/test_asgi.py +++ b/tests/integrations/asgi/test_asgi.py @@ -831,10 +831,8 @@ async def test_get_request_data_url_with_filtered_host( # substituted "[Filtered]" value. sentry_init( traces_sample_rate=1.0, - _experiments={ - "data_collection": { - "http_headers": {"request": {"mode": "allowlist", "terms": []}} - } + data_collection={ + "http_headers": {"request": {"mode": "allowlist", "terms": []}} }, ) app = SentryAsgiMiddleware(asgi3_app) @@ -863,10 +861,8 @@ async def test_get_request_attributes_url_with_filtered_host( send_default_pii=True, traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={ - "data_collection": { - "http_headers": {"request": {"mode": "allowlist", "terms": []}} - }, + data_collection={ + "http_headers": {"request": {"mode": "allowlist", "terms": []}} }, ) app = SentryAsgiMiddleware(asgi3_app) @@ -895,9 +891,7 @@ async def test_get_request_attributes_url_with_headers_off( send_default_pii=True, traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={ - "data_collection": {"http_headers": {"request": {"mode": "off"}}}, - }, + data_collection={"http_headers": {"request": {"mode": "off"}}}, ) app = SentryAsgiMiddleware(asgi3_app) @@ -942,16 +936,14 @@ def _http_scope(): id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "token=%5BFiltered%5D&theme=dark&lang=en&session=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["theme"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["theme"]} } }, "token=%5BFiltered%5D&theme=%5BFiltered%5D&lang=en&session=%5BFiltered%5D", @@ -959,10 +951,8 @@ def _http_scope(): ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["theme"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["theme"]} } }, "token=%5BFiltered%5D&theme=dark&lang=%5BFiltered%5D&session=%5BFiltered%5D", @@ -970,21 +960,15 @@ def _http_scope(): ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["token"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["token"]} } }, "token=%5BFiltered%5D&theme=%5BFiltered%5D&lang=%5BFiltered%5D&session=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -992,9 +976,7 @@ def _http_scope(): pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -1044,7 +1026,7 @@ async def test_get_request_data_query_string_empty_legacy_is_none( async def test_get_request_data_empty_query_string_dropped_with_data_collection( sentry_init, capture_events, asgi3_app ): - sentry_init(traces_sample_rate=1.0, _experiments={"data_collection": {}}) + sentry_init(traces_sample_rate=1.0, data_collection={}) app = SentryAsgiMiddleware(asgi3_app) events = capture_events() @@ -1080,17 +1062,15 @@ async def test_get_request_data_empty_query_string_dropped_with_data_collection( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "token=%5BFiltered%5D&theme=dark&lang=en&session=%5BFiltered%5D", "http://example.com/foo?token=%5BFiltered%5D&theme=dark&lang=en&session=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["theme"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["theme"]} } }, "token=%5BFiltered%5D&theme=dark&lang=%5BFiltered%5D&session=%5BFiltered%5D", @@ -1098,11 +1078,7 @@ async def test_get_request_data_empty_query_string_dropped_with_data_collection( id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, "http://example.com/foo", id="data_collection_off", @@ -1110,9 +1086,7 @@ async def test_get_request_data_empty_query_string_dropped_with_data_collection( pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, "http://example.com/foo", @@ -1159,13 +1133,13 @@ async def test_get_request_attributes_query_data_collection( USER_INFO_CASES = [ pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, True, False, id="dc_user_info_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, True, id="dc_default_user_info", @@ -1173,7 +1147,7 @@ async def test_get_request_attributes_query_data_collection( pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, True, False, @@ -1192,7 +1166,7 @@ async def test_get_request_attributes_query_data_collection( id="legacy_pii_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, False, False, id="no_client", @@ -1438,24 +1412,24 @@ async def test_custom_transaction_name( pytest.param({"send_default_pii": True}, True, id="legacy_pii_true"), pytest.param({"send_default_pii": False}, False, id="legacy_pii_false"), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="dc_default_user_info", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": True}}}, + {"data_collection": {"user_info": True}}, True, id="dc_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, False, id="dc_user_info_false", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, False, id="dc_wins_over_pii", diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionAllowlist/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionAllowlist/index.py index a79e1a03a7..582ba1ed57 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionAllowlist/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionAllowlist/index.py @@ -7,16 +7,14 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "http_headers": { - "request": { - "mode": "allowlist", - # "authorization" is allowlisted on purpose to show that an - # allowlist entry cannot override the built-in sensitive - # denylist. - "terms": ["user-agent", "x-allow-me", "authorization"], - } + data_collection={ + "http_headers": { + "request": { + "mode": "allowlist", + # "authorization" is allowlisted on purpose to show that an + # allowlist entry cannot override the built-in sensitive + # denylist. + "terms": ["user-agent", "x-allow-me", "authorization"], } } }, diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionDenylist/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionDenylist/index.py index 4c59de9cb4..cc4f7529b8 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionDenylist/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionDenylist/index.py @@ -7,15 +7,13 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "http_headers": { - "request": { - "mode": "denylist", - # Custom terms deny otherwise non-sensitive headers on top - # of the built-in sensitive denylist. - "terms": ["x-forwarded", "user-agent"], - } + data_collection={ + "http_headers": { + "request": { + "mode": "denylist", + # Custom terms deny otherwise non-sensitive headers on top + # of the built-in sensitive denylist. + "terms": ["x-forwarded", "user-agent"], } } }, diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionOff/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionOff/index.py index 6f3a7a8126..9aa8560643 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionOff/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionOff/index.py @@ -7,11 +7,9 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "http_headers": { - "request": {"mode": "off"}, - } + data_collection={ + "http_headers": { + "request": {"mode": "off"}, } }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryAllowlist/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryAllowlist/index.py index 67ed8be6e3..1eb286a89a 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryAllowlist/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryAllowlist/index.py @@ -7,14 +7,12 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "url_query_params": { - "mode": "allowlist", - # "token" is allowlisted on purpose to show that an allowlist - # entry cannot override the built-in sensitive denylist. - "terms": ["page", "token"], - } + data_collection={ + "url_query_params": { + "mode": "allowlist", + # "token" is allowlisted on purpose to show that an allowlist + # entry cannot override the built-in sensitive denylist. + "terms": ["page", "token"], } }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryDenylist/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryDenylist/index.py index 389d7890ea..0aeb919ae8 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryDenylist/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryDenylist/index.py @@ -7,14 +7,12 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "url_query_params": { - "mode": "denylist", - # Custom terms deny otherwise non-sensitive query params on top - # of the built-in sensitive denylist. - "terms": ["tracking"], - } + data_collection={ + "url_query_params": { + "mode": "denylist", + # Custom terms deny otherwise non-sensitive query params on top + # of the built-in sensitive denylist. + "terms": ["tracking"], } }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryOff/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryOff/index.py index 02446562d9..5c9d6b7724 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryOff/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUrlQueryOff/index.py @@ -7,10 +7,8 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "url_query_params": {"mode": "off"}, - } + data_collection={ + "url_query_params": {"mode": "off"}, }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOff/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOff/index.py index 18c5450196..4cfe3abbeb 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOff/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOff/index.py @@ -7,10 +7,8 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "user_info": False, - } + data_collection={ + "user_info": False, }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOn/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOn/index.py index 07527dad4a..bcb0d66575 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOn/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkDataCollectionUserInfoOn/index.py @@ -7,10 +7,8 @@ dsn=os.environ.get("SENTRY_DSN"), traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], - _experiments={ - "data_collection": { - "user_info": True, - } + data_collection={ + "user_info": True, }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollection/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollection/index.py index b1ee2ec8a6..add84cc9c2 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollection/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollection/index.py @@ -8,13 +8,11 @@ traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], trace_lifecycle="stream", - _experiments={ - "data_collection": { - "url_query_params": { - "mode": "denylist", - "terms": ["tracking"], - } - }, + data_collection={ + "url_query_params": { + "mode": "denylist", + "terms": ["tracking"], + } }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOff/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOff/index.py index 941a5578a7..ef00b0fce4 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOff/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOff/index.py @@ -8,10 +8,8 @@ traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], trace_lifecycle="stream", - _experiments={ - "data_collection": { - "user_info": False, - } + data_collection={ + "user_info": False, }, ) diff --git a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOn/index.py b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOn/index.py index d5e9590979..4cec57ed71 100644 --- a/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOn/index.py +++ b/tests/integrations/aws_lambda/lambda_functions_with_embedded_sdk/BasicOkSpanStreamingDataCollectionUserInfoOn/index.py @@ -8,10 +8,8 @@ traces_sample_rate=1.0, integrations=[AwsLambdaIntegration()], trace_lifecycle="stream", - _experiments={ - "data_collection": { - "user_info": True, - } + data_collection={ + "user_info": True, }, ) diff --git a/tests/integrations/boto3/test_s3.py b/tests/integrations/boto3/test_s3.py index 9e6b296596..888e44ee4c 100644 --- a/tests/integrations/boto3/test_s3.py +++ b/tests/integrations/boto3/test_s3.py @@ -460,16 +460,14 @@ def test_breadcrumb_span_streaming(sentry_init, capture_events, send_default_pii id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "list-type=2&prefix=foo&continuation-token=%5BFiltered%5D&encoding-type=url", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["prefix"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["prefix"]} } }, "list-type=2&prefix=%5BFiltered%5D&continuation-token=%5BFiltered%5D&encoding-type=url", @@ -477,10 +475,8 @@ def test_breadcrumb_span_streaming(sentry_init, capture_events, send_default_pii ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["prefix"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["prefix"]} } }, "list-type=%5BFiltered%5D&prefix=foo&continuation-token=%5BFiltered%5D&encoding-type=%5BFiltered%5D", @@ -488,12 +484,10 @@ def test_breadcrumb_span_streaming(sentry_init, capture_events, send_default_pii ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": { - "mode": "allowlist", - "terms": ["continuation-token"], - } + "data_collection": { + "url_query_params": { + "mode": "allowlist", + "terms": ["continuation-token"], } } }, @@ -501,14 +495,14 @@ def test_breadcrumb_span_streaming(sentry_init, capture_events, send_default_pii id="data_collection_allowlist_sensitive_term", ), pytest.param( - {"_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}}, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "", id="data_collection_wins_over_send_default_pii", diff --git a/tests/integrations/bottle/test_bottle.py b/tests/integrations/bottle/test_bottle.py index a4e23789ea..7f8ad7fa3f 100644 --- a/tests/integrations/bottle/test_bottle.py +++ b/tests/integrations/bottle/test_bottle.py @@ -893,7 +893,7 @@ def test_request_body_data_collection( ): sentry_init( integrations=[BottleIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) data = {"foo": "bar"} @@ -922,7 +922,7 @@ def test_request_body_dropped_with_form_and_files_data_collection( sentry_init( integrations=[BottleIntegration()], max_request_body_size="always", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) data = { @@ -956,7 +956,7 @@ def test_transaction_request_body_data_collection( sentry_init( integrations=[BottleIntegration()], traces_sample_rate=1.0, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) data = {"username": "sentry-user", "age": "26"} @@ -987,7 +987,7 @@ def test_oversized_request_body_not_annotated_data_collection( sentry_init( integrations=[BottleIntegration()], max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) data = "a" * 2000 diff --git a/tests/integrations/celery/test_celery.py b/tests/integrations/celery/test_celery.py index 0bc22d9509..56c7e9b781 100644 --- a/tests/integrations/celery/test_celery.py +++ b/tests/integrations/celery/test_celery.py @@ -236,19 +236,19 @@ def dummy_task(x, y): "init_kwargs,expected_args,expected_kwargs", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "included", "included", id="data_collection_default", ), pytest.param( - {"_experiments": {"data_collection": {"queues": True}}}, + {"data_collection": {"queues": True}}, "included", "included", id="data_collection_queues_on", ), pytest.param( - {"_experiments": {"data_collection": {"queues": False}}}, + {"data_collection": {"queues": False}}, None, None, id="data_collection_queues_off", @@ -261,7 +261,7 @@ def dummy_task(x, y): ), pytest.param( { - "_experiments": {"data_collection": {"queues": False}}, + "data_collection": {"queues": False}, "send_default_pii": False, }, None, @@ -270,7 +270,7 @@ def dummy_task(x, y): ), pytest.param( { - "_experiments": {"data_collection": {"queues": True}}, + "data_collection": {"queues": True}, "send_default_pii": False, }, "included", diff --git a/tests/integrations/clickhouse_driver/test_clickhouse_driver.py b/tests/integrations/clickhouse_driver/test_clickhouse_driver.py index 8a82f903c1..d333f2a6c9 100644 --- a/tests/integrations/clickhouse_driver/test_clickhouse_driver.py +++ b/tests/integrations/clickhouse_driver/test_clickhouse_driver.py @@ -448,7 +448,7 @@ def test_clickhouse_client_breadcrumbs_with_data_collection( ) -> None: sentry_init( integrations=[ClickhouseDriverIntegration()], - _experiments={"data_collection": {"database_query_data": True}}, + data_collection={"database_query_data": True}, ) events = capture_events() @@ -552,7 +552,7 @@ def test_clickhouse_client_breadcrumbs_with_data_collection_span_streaming( sentry_init( integrations=[ClickhouseDriverIntegration()], trace_lifecycle="stream", - _experiments={"data_collection": {"database_query_data": True}}, + data_collection={"database_query_data": True}, ) events = capture_events() @@ -654,7 +654,7 @@ def test_clickhouse_client_breadcrumbs_with_data_collection_disabled( ) -> None: sentry_init( integrations=[ClickhouseDriverIntegration()], - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -754,7 +754,7 @@ def test_clickhouse_client_breadcrumbs_with_data_collection_disabled_span_stream sentry_init( integrations=[ClickhouseDriverIntegration()], trace_lifecycle="stream", - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -854,7 +854,7 @@ def test_clickhouse_client_breadcrumbs_data_collection_overrides_pii( sentry_init( integrations=[ClickhouseDriverIntegration()], send_default_pii=True, - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -955,7 +955,7 @@ def test_clickhouse_client_breadcrumbs_data_collection_overrides_pii_span_stream integrations=[ClickhouseDriverIntegration()], send_default_pii=True, trace_lifecycle="stream", - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -1054,7 +1054,7 @@ def test_clickhouse_client_breadcrumbs_with_data_collection_default( ) -> None: sentry_init( integrations=[ClickhouseDriverIntegration()], - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -1158,7 +1158,7 @@ def test_clickhouse_client_breadcrumbs_with_data_collection_default_span_streami sentry_init( integrations=[ClickhouseDriverIntegration()], trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -1264,9 +1264,7 @@ def test_clickhouse_client_span_streaming_with_data_collection( integrations=[ClickhouseDriverIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={ - "data_collection": {"database_query_data": True}, - }, + data_collection={"database_query_data": True}, ) items = capture_items("span") @@ -1299,7 +1297,7 @@ def test_clickhouse_client_send_data_generator_with_data_collection( ) -> None: sentry_init( integrations=[ClickhouseDriverIntegration()], - _experiments={"data_collection": {"database_query_data": True}}, + data_collection={"database_query_data": True}, ) events = capture_events() @@ -1329,7 +1327,7 @@ def test_clickhouse_client_send_data_generator_with_data_collection_disabled( ) -> None: sentry_init( integrations=[ClickhouseDriverIntegration()], - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() @@ -1360,7 +1358,7 @@ def test_clickhouse_client_send_data_generator_span_streaming_with_data_collecti sentry_init( integrations=[ClickhouseDriverIntegration()], trace_lifecycle="stream", - _experiments={"data_collection": {"database_query_data": True}}, + data_collection={"database_query_data": True}, ) events = capture_events() @@ -1391,7 +1389,7 @@ def test_clickhouse_client_send_data_generator_span_streaming_with_data_collecti sentry_init( integrations=[ClickhouseDriverIntegration()], trace_lifecycle="stream", - _experiments={"data_collection": {"database_query_data": False}}, + data_collection={"database_query_data": False}, ) events = capture_events() diff --git a/tests/integrations/cohere/test_cohere.py b/tests/integrations/cohere/test_cohere.py index db13e39ade..9cb9fac75d 100644 --- a/tests/integrations/cohere/test_cohere.py +++ b/tests/integrations/cohere/test_cohere.py @@ -614,7 +614,7 @@ def _init_with_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - kwargs["_experiments"] = {"data_collection": data_collection} + kwargs["data_collection"] = data_collection sentry_init(**kwargs) diff --git a/tests/integrations/django/asgi/test_asgi.py b/tests/integrations/django/asgi/test_asgi.py index 5556dc7638..42489d690c 100644 --- a/tests/integrations/django/asgi/test_asgi.py +++ b/tests/integrations/django/asgi/test_asgi.py @@ -875,7 +875,7 @@ async def test_asgi_request_body_data_collection( ): sentry_init( integrations=[DjangoIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) events = capture_events() @@ -911,7 +911,7 @@ async def test_asgi_request_body_dropped_with_form_and_files_data_collection( sentry_init( integrations=[DjangoIntegration()], max_request_body_size="always", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) events = capture_events() @@ -947,7 +947,7 @@ async def test_asgi_transaction_request_body_data_collection( sentry_init( integrations=[DjangoIntegration()], traces_sample_rate=1.0, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) events = capture_events() @@ -984,7 +984,7 @@ async def test_asgi_oversized_request_body_not_annotated_data_collection( sentry_init( integrations=[DjangoIntegration()], max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) events = capture_events() diff --git a/tests/integrations/django/test_basic.py b/tests/integrations/django/test_basic.py index cc61635dec..59afe9be6b 100644 --- a/tests/integrations/django/test_basic.py +++ b/tests/integrations/django/test_basic.py @@ -1236,7 +1236,7 @@ def test_request_body_data_collection( ): sentry_init( integrations=[DjangoIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) items = capture_items("event") @@ -1264,7 +1264,7 @@ def test_request_body_dropped_with_form_and_files_data_collection( sentry_init( integrations=[DjangoIntegration()], max_request_body_size="always", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) items = capture_items("event") @@ -1286,7 +1286,7 @@ def test_transaction_request_body_data_collection(sentry_init, client, capture_e sentry_init( integrations=[DjangoIntegration()], traces_sample_rate=1.0, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) events = capture_events() @@ -1315,7 +1315,7 @@ def test_oversized_request_body_not_annotated_data_collection( sentry_init( integrations=[DjangoIntegration()], max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) items = capture_items("event") diff --git a/tests/integrations/django/test_data_scrubbing.py b/tests/integrations/django/test_data_scrubbing.py index fa60302850..a660341fea 100644 --- a/tests/integrations/django/test_data_scrubbing.py +++ b/tests/integrations/django/test_data_scrubbing.py @@ -170,7 +170,7 @@ def test_data_collection_cookies( ): sentry_init( integrations=[DjangoIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) items = capture_items("event") for name, value in cookies_to_set.items(): @@ -194,7 +194,7 @@ def test_data_collection_cookies_precedence_over_send_default_pii( sentry_init( integrations=[DjangoIntegration()], send_default_pii=False, - _experiments={"data_collection": {"cookies": {"mode": "denylist"}}}, + data_collection={"cookies": {"mode": "denylist"}}, ) items = capture_items("event") werkzeug_set_cookie(client, "localhost", "sessionid", "123") @@ -231,27 +231,21 @@ def test_data_collection_cookies_precedence_over_send_default_pii( id="legacy_send_default_pii_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -293,27 +287,21 @@ def test_query_string_data_collection( id="legacy_send_default_pii_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -371,7 +359,7 @@ def test_empty_query_string_is_dropped_with_data_collection( # reduce envelope size, so the ``query_string`` key is absent. sentry_init( integrations=[DjangoIntegration()], - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -387,14 +375,10 @@ def test_empty_query_string_is_dropped_with_data_collection( def test_user_info_span_attributes_data_collection( sentry_init, client, capture_items, init_kwargs, expect_ip ): - init_kwargs = dict(init_kwargs) # shallow copy so we can mutate - experiments = init_kwargs.pop("_experiments", {}) - sentry_init( integrations=[DjangoIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=experiments, **init_kwargs, ) @@ -423,14 +407,10 @@ def test_user_info_span_attributes_data_collection( def test_user_identity_span_attributes_data_collection( sentry_init, client, capture_items, init_kwargs, expect_user ): - init_kwargs = dict(init_kwargs) # shallow copy so we can mutate - experiments = init_kwargs.pop("_experiments", {}) - sentry_init( integrations=[DjangoIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=experiments, **init_kwargs, ) @@ -505,7 +485,7 @@ def test_error_event_no_user_ip_address_without_remote_addr( ): sentry_init( integrations=[DjangoIntegration()], - _experiments={"data_collection": {"user_info": True}}, + data_collection={"user_info": True}, ) events = capture_events() diff --git a/tests/integrations/dramatiq/test_dramatiq.py b/tests/integrations/dramatiq/test_dramatiq.py index b5812ef247..6f889e5d9b 100644 --- a/tests/integrations/dramatiq/test_dramatiq.py +++ b/tests/integrations/dramatiq/test_dramatiq.py @@ -460,16 +460,12 @@ def dummy_actor(x, y): [ pytest.param({}, True, id="data_collection_not_enabled"), pytest.param( - { - "_experiments": { - "data_collection": {"http_bodies": ["incoming_request"]} - } - }, + {"data_collection": {"http_bodies": ["incoming_request"]}}, True, id="data_collection_http_bodies_incoming_request", ), pytest.param( - {"_experiments": {"data_collection": {"http_bodies": []}}}, + {"data_collection": {"http_bodies": []}}, False, id="data_collection_http_bodies_empty", ), @@ -501,7 +497,7 @@ def dummy_actor(x, y): @pytest.mark.parametrize( "broker", - [{"_experiments": {"data_collection": {"http_bodies": []}}}], + [{"data_collection": {"http_bodies": []}}], indirect=True, ) def test_that_dramatiq_context_type_is_set_regardless_of_data_collection( diff --git a/tests/integrations/fastapi/test_fastapi.py b/tests/integrations/fastapi/test_fastapi.py index 7bf319d9f6..a79b915eef 100644 --- a/tests/integrations/fastapi/test_fastapi.py +++ b/tests/integrations/fastapi/test_fastapi.py @@ -358,7 +358,7 @@ async def test_formdata_request_body_data_collection_http_bodies_empty( max_request_body_size="always", integrations=[StarletteIntegration()], trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) app = fastapi_app_factory() @@ -418,9 +418,7 @@ async def test_request_body_data_collection( traces_sample_rate=1.0, integrations=[StarletteIntegration()], trace_lifecycle="stream" if span_streaming else "static", - _experiments=( - {} if data_collection is None else {"data_collection": data_collection} - ), + data_collection=data_collection, ) app = fastapi_app_factory() diff --git a/tests/integrations/flask/test_flask.py b/tests/integrations/flask/test_flask.py index 8b8fe141bf..fa84780fd9 100644 --- a/tests/integrations/flask/test_flask.py +++ b/tests/integrations/flask/test_flask.py @@ -1274,27 +1274,21 @@ def test_transaction_or_segment_http_method_custom( id="legacy_send_default_pii_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -1340,27 +1334,21 @@ def test_query_string_data_collection( id="legacy_send_default_pii_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -1417,7 +1405,7 @@ def test_empty_query_string_is_dropped_with_data_collection( ): sentry_init( integrations=[flask_sentry.FlaskIntegration()], - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -1432,14 +1420,10 @@ def test_empty_query_string_is_dropped_with_data_collection( def test_user_info_span_attributes_data_collection( sentry_init, app, capture_items, monkeypatch, init_kwargs, expect_ip ): - init_kwargs = dict(init_kwargs) # shallow copy so we can mutate - experiments = init_kwargs.pop("_experiments", {}) - sentry_init( integrations=[flask_sentry.FlaskIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=experiments, **init_kwargs, ) # This test is about user IP collection, not flask_login. Disable @@ -1496,7 +1480,7 @@ def test_error_event_no_user_ip_address_without_remote_addr( ): sentry_init( integrations=[flask_sentry.FlaskIntegration()], - _experiments={"data_collection": {"user_info": True}}, + data_collection={"user_info": True}, ) monkeypatch.setattr(flask_sentry, "flask_login", None) @@ -1567,14 +1551,10 @@ def crash(): def test_flask_login_user_identity_span_attributes_data_collection( sentry_init, app, capture_items, init_kwargs, expect_user ): - init_kwargs = dict(init_kwargs) - experiments = init_kwargs.pop("_experiments", {}) - sentry_init( integrations=[flask_sentry.FlaskIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=experiments, **init_kwargs, ) @@ -1641,7 +1621,7 @@ def test_flask_request_body_data_collection( ): sentry_init( integrations=[flask_sentry.FlaskIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) # This test is about request body gating, not user data. monkeypatch.setattr(flask_sentry, "flask_login", None) @@ -1672,7 +1652,7 @@ def test_flask_request_body_dropped_with_form_and_files_data_collection( sentry_init( integrations=[flask_sentry.FlaskIntegration()], max_request_body_size="always", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) monkeypatch.setattr(flask_sentry, "flask_login", None) @@ -1705,7 +1685,7 @@ def test_flask_transaction_request_body_data_collection( sentry_init( integrations=[flask_sentry.FlaskIntegration()], traces_sample_rate=1.0, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) monkeypatch.setattr(flask_sentry, "flask_login", None) @@ -1737,7 +1717,7 @@ def test_flask_oversized_request_body_not_annotated_data_collection( sentry_init( integrations=[flask_sentry.FlaskIntegration()], max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) monkeypatch.setattr(flask_sentry, "flask_login", None) diff --git a/tests/integrations/gcp/test_gcp.py b/tests/integrations/gcp/test_gcp.py index a2b310b318..d779295cc1 100644 --- a/tests/integrations/gcp/test_gcp.py +++ b/tests/integrations/gcp/test_gcp.py @@ -857,7 +857,7 @@ def _build_init_kwargs(send_default_pii, data_collection): if send_default_pii is not None: kwargs.append("send_default_pii=%r" % send_default_pii) if data_collection is not None: - kwargs.append("_experiments=%r" % {"data_collection": data_collection}) + kwargs.append("data_collection=%r" % (data_collection,)) return ", ".join(kwargs) diff --git a/tests/integrations/google_genai/test_google_genai.py b/tests/integrations/google_genai/test_google_genai.py index 9ea8431a7a..444333e45f 100644 --- a/tests/integrations/google_genai/test_google_genai.py +++ b/tests/integrations/google_genai/test_google_genai.py @@ -3764,7 +3764,7 @@ def test_generate_content_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -3891,7 +3891,7 @@ def test_generate_content_data_collection_tools( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -4087,7 +4087,7 @@ def test_streaming_generate_content_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -4245,7 +4245,7 @@ def test_streaming_generate_content_data_collection_tools( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -4430,7 +4430,7 @@ def test_embed_content_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -4584,7 +4584,7 @@ async def test_async_generate_content_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -4725,7 +4725,7 @@ async def test_async_embed_content_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) diff --git a/tests/integrations/gql/test_gql.py b/tests/integrations/gql/test_gql.py index 77787e696d..dcaee5be10 100644 --- a/tests/integrations/gql/test_gql.py +++ b/tests/integrations/gql/test_gql.py @@ -180,24 +180,24 @@ def test_real_gql_request_with_error_with_pii( pytest.param({}, False, id="no_pii_no_data_collection"), pytest.param({"send_default_pii": True}, True, id="legacy_pii_on"), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="data_collection_defaults", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"document": True}}}}, + {"data_collection": {"graphql": {"document": True}}}, True, id="data_collection_document_on", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"document": False}}}}, + {"data_collection": {"graphql": {"document": False}}}, False, id="data_collection_document_off", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"graphql": {"document": False}}}, + "data_collection": {"graphql": {"document": False}}, }, False, id="data_collection_takes_precedence_over_send_default_pii_on", @@ -205,7 +205,7 @@ def test_real_gql_request_with_error_with_pii( pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"graphql": {"document": True}}}, + "data_collection": {"graphql": {"document": True}}, }, True, id="data_collection_takes_precedence_over_send_default_pii_off", @@ -238,17 +238,17 @@ def test_real_gql_request_with_error_data_collection( [ pytest.param({"send_default_pii": True}, True, id="legacy_pii_on"), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="data_collection_defaults", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"variables": True}}}}, + {"data_collection": {"graphql": {"variables": True}}}, True, id="data_collection_variables_on", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"variables": False}}}}, + {"data_collection": {"graphql": {"variables": False}}}, False, id="data_collection_variables_off", ), diff --git a/tests/integrations/graphene/test_graphene.py b/tests/integrations/graphene/test_graphene.py index 76bfc13f77..60f47463cb 100644 --- a/tests/integrations/graphene/test_graphene.py +++ b/tests/integrations/graphene/test_graphene.py @@ -185,7 +185,7 @@ def test_event_processor_data_collection_sync( ): init_kwargs = { "integrations": [GrapheneIntegration(), FlaskIntegration()], - "_experiments": {"data_collection": data_collection}, + "data_collection": data_collection, } if send_default_pii is not None: init_kwargs["send_default_pii"] = send_default_pii @@ -231,7 +231,7 @@ def test_event_processor_data_collection_async( FastApiIntegration(), StarletteIntegration(), ], - "_experiments": {"data_collection": data_collection}, + "data_collection": data_collection, } if send_default_pii is not None: @@ -384,7 +384,7 @@ def test_graphql_span_data_collection( "integrations": [GrapheneIntegration(), FlaskIntegration()], "traces_sample_rate": 1.0, "default_integrations": False, - "_experiments": {"data_collection": data_collection}, + "data_collection": data_collection, } if send_default_pii is not None: init_kwargs["send_default_pii"] = send_default_pii @@ -494,7 +494,7 @@ def test_graphql_streamed_span_data_collection( "traces_sample_rate": 1.0, "default_integrations": False, "trace_lifecycle": "stream", - "_experiments": {"data_collection": data_collection}, + "data_collection": data_collection, } if send_default_pii is not None: init_kwargs["send_default_pii"] = send_default_pii diff --git a/tests/integrations/httpx/test_httpx.py b/tests/integrations/httpx/test_httpx.py index 0187b068c7..96e3dd001e 100644 --- a/tests/integrations/httpx/test_httpx.py +++ b/tests/integrations/httpx/test_httpx.py @@ -2350,16 +2350,14 @@ async def test_http_url_attributes_no_query_or_fragment_span_streaming_async( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -2367,10 +2365,8 @@ async def test_http_url_attributes_no_query_or_fragment_span_streaming_async( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -2378,30 +2374,22 @@ async def test_http_url_attributes_no_query_or_fragment_span_streaming_async( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -2457,16 +2445,14 @@ def test_url_query_data_collection_span_streaming_sync( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -2474,10 +2460,8 @@ def test_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -2485,30 +2469,22 @@ def test_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -2548,16 +2524,14 @@ async def test_url_query_data_collection_span_streaming_async( "init_kwargs, expected_url_full", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2596,16 +2570,14 @@ def test_url_full_reassembly_span_streaming_sync( "init_kwargs, expected_url_full", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2643,20 +2615,14 @@ async def test_url_full_reassembly_span_streaming_async( "init_kwargs, expected_url_full", [ pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "http://example.com/#frag", id="data_collection_wins_over_send_default_pii", @@ -2706,20 +2672,14 @@ def test_url_query_params_off_keeps_bare_url_span_streaming_sync( "init_kwargs, expected_url_full", [ pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "http://example.com/#frag", id="data_collection_wins_over_send_default_pii", @@ -2768,7 +2728,7 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( "init_kwargs, expected_url, expected_query, expected_fragment", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", "toy=tennisball&color=red&auth=%5BFiltered%5D", "frag", @@ -2776,10 +2736,8 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2788,11 +2746,7 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", "", "frag", @@ -2851,7 +2805,7 @@ def test_crumb_url_query_data_collection_span_streaming_sync( "init_kwargs, expected_url, expected_query, expected_fragment", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", "toy=tennisball&color=red&auth=%5BFiltered%5D", "frag", @@ -2859,10 +2813,8 @@ def test_crumb_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2871,11 +2823,7 @@ def test_crumb_url_query_data_collection_span_streaming_sync( id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", "", "frag", @@ -2933,15 +2881,11 @@ async def test_crumb_url_query_data_collection_span_streaming_async( "init_kwargs", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, id="data_collection_off", ), ], @@ -2979,15 +2923,11 @@ def test_crumb_url_query_unfiltered_legacy_sync( "init_kwargs", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, id="data_collection_off", ), ], @@ -3025,7 +2965,7 @@ def test_omit_url_data_if_parsing_fails_span_streaming( integrations=[HttpxIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) items = capture_items("span") diff --git a/tests/integrations/httpx2/test_httpx2.py b/tests/integrations/httpx2/test_httpx2.py index 9f4e10cf08..d0523bd05b 100644 --- a/tests/integrations/httpx2/test_httpx2.py +++ b/tests/integrations/httpx2/test_httpx2.py @@ -2389,16 +2389,14 @@ async def test_http_url_attributes_pii_disabled_span_streaming_async( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -2406,10 +2404,8 @@ async def test_http_url_attributes_pii_disabled_span_streaming_async( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -2417,30 +2413,22 @@ async def test_http_url_attributes_pii_disabled_span_streaming_async( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -2496,16 +2484,14 @@ def test_url_query_data_collection_span_streaming_sync( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -2513,10 +2499,8 @@ def test_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -2524,30 +2508,22 @@ def test_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -2587,16 +2563,14 @@ async def test_url_query_data_collection_span_streaming_async( "init_kwargs, expected_url_full", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2635,16 +2609,14 @@ def test_url_full_reassembly_span_streaming_sync( "init_kwargs, expected_url_full", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2682,20 +2654,14 @@ async def test_url_full_reassembly_span_streaming_async( "init_kwargs, expected_url_full", [ pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "http://example.com/#frag", id="data_collection_wins_over_send_default_pii", @@ -2745,20 +2711,14 @@ def test_url_query_params_off_keeps_bare_url_span_streaming_sync( "init_kwargs, expected_url_full", [ pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "http://example.com/#frag", id="data_collection_wins_over_send_default_pii", @@ -2807,7 +2767,7 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( "init_kwargs, expected_url, expected_query, expected_fragment", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", "toy=tennisball&color=red&auth=%5BFiltered%5D", "frag", @@ -2815,10 +2775,8 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2827,11 +2785,7 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", "", "frag", @@ -2890,7 +2844,7 @@ def test_crumb_url_query_data_collection_span_streaming_sync( "init_kwargs, expected_url, expected_query, expected_fragment", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "http://example.com/?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", "toy=tennisball&color=red&auth=%5BFiltered%5D", "frag", @@ -2898,10 +2852,8 @@ def test_crumb_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "http://example.com/?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -2910,11 +2862,7 @@ def test_crumb_url_query_data_collection_span_streaming_sync( id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "http://example.com/#frag", "", "frag", @@ -2972,15 +2920,11 @@ async def test_crumb_url_query_data_collection_span_streaming_async( "init_kwargs", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, id="data_collection_off", ), ], @@ -3018,15 +2962,11 @@ def test_crumb_url_query_unfiltered_legacy_sync( "init_kwargs", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, id="data_collection_off", ), ], @@ -3064,7 +3004,7 @@ def test_omit_url_data_if_parsing_fails_span_streaming( integrations=[Httpx2Integration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) items = capture_items("span") diff --git a/tests/integrations/huggingface_hub/test_huggingface_hub.py b/tests/integrations/huggingface_hub/test_huggingface_hub.py index c1b38d4377..3a04a51d52 100644 --- a/tests/integrations/huggingface_hub/test_huggingface_hub.py +++ b/tests/integrations/huggingface_hub/test_huggingface_hub.py @@ -2074,7 +2074,7 @@ def test_text_generation_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -2228,7 +2228,7 @@ def test_text_generation_streaming_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -2392,7 +2392,7 @@ def test_chat_completion_data_collection_tools( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -2572,7 +2572,7 @@ def test_chat_completion_streaming_data_collection_tools( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) diff --git a/tests/integrations/langchain/test_langchain.py b/tests/integrations/langchain/test_langchain.py index 6e906fa840..a6fa363744 100644 --- a/tests/integrations/langchain/test_langchain.py +++ b/tests/integrations/langchain/test_langchain.py @@ -6249,7 +6249,7 @@ def test_langchain_chat_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -6457,7 +6457,7 @@ def test_langchain_text_completion_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -6641,7 +6641,7 @@ def test_langchain_data_collection_tools( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -6770,7 +6770,7 @@ def test_langchain_data_collection_request_tool_call_params( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -6911,7 +6911,7 @@ def test_langchain_tool_execution_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -7086,7 +7086,7 @@ def test_langchain_agent_executor_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -7247,7 +7247,7 @@ async def test_langchain_embeddings_data_collection( trace_lifecycle="stream" if span_streaming else "static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) diff --git a/tests/integrations/langgraph/test_langgraph.py b/tests/integrations/langgraph/test_langgraph.py index 1070cb4104..7b6a6cc3d9 100644 --- a/tests/integrations/langgraph/test_langgraph.py +++ b/tests/integrations/langgraph/test_langgraph.py @@ -2195,7 +2195,7 @@ def test_pregel_invoke_gates_request_messages_on_inputs_setting( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -2286,7 +2286,7 @@ def test_pregel_invoke_gates_response_text_and_tool_calls_on_outputs_setting( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -2383,7 +2383,7 @@ def test_pregel_ainvoke_gates_inputs_and_outputs_independently( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -2448,9 +2448,7 @@ def test_pregel_invoke_message_delta_ignores_gen_ai_inputs_setting( traces_sample_rate=1.0, stream_gen_ai_spans=span_streaming, trace_lifecycle="stream" if span_streaming else "static", - _experiments={ - "data_collection": {"gen_ai": {"inputs": False, "outputs": True}} - }, + data_collection={"gen_ai": {"inputs": False, "outputs": True}}, ) prior_response = "Of course! How can I assist you?" @@ -2522,9 +2520,7 @@ def test_pregel_ainvoke_message_delta_ignores_gen_ai_inputs_setting( traces_sample_rate=1.0, stream_gen_ai_spans=span_streaming, trace_lifecycle="stream" if span_streaming else "static", - _experiments={ - "data_collection": {"gen_ai": {"inputs": False, "outputs": True}} - }, + data_collection={"gen_ai": {"inputs": False, "outputs": True}}, ) prior_response = "It is sunny in Berlin." @@ -2630,7 +2626,7 @@ def test_state_graph_compile_gates_available_tools_only_when_data_collection_con "stream_gen_ai_spans": False, } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) diff --git a/tests/integrations/litellm/test_litellm.py b/tests/integrations/litellm/test_litellm.py index 8358151580..a5d5c2ae9f 100644 --- a/tests/integrations/litellm/test_litellm.py +++ b/tests/integrations/litellm/test_litellm.py @@ -3673,7 +3673,7 @@ def test_chat_completion_data_collection( trace_lifecycle="static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -3800,7 +3800,7 @@ def test_embeddings_data_collection( trace_lifecycle="static", ) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) diff --git a/tests/integrations/litestar/test_litestar.py b/tests/integrations/litestar/test_litestar.py index 5453aaec6c..7e59e65864 100644 --- a/tests/integrations/litestar/test_litestar.py +++ b/tests/integrations/litestar/test_litestar.py @@ -704,9 +704,7 @@ def test_request_body_data_collection( sentry_init( traces_sample_rate=1.0, integrations=[LitestarIntegration()], - _experiments=( - {} if data_collection is None else {"data_collection": data_collection} - ), + data_collection=data_collection, ) litestar_app = litestar_app_factory() @@ -734,7 +732,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( traces_sample_rate=1.0, integrations=[LitestarIntegration()], send_default_pii=True, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) litestar_app = litestar_app_factory() @@ -773,12 +771,12 @@ def test_request_body_data_collection_wins_over_send_default_pii( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "off"}}}}, + {"data_collection": {"cookies": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}}, + {"data_collection": {"cookies": {"mode": "denylist"}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -788,13 +786,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "denylist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "denylist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": SENSITIVE_DATA_SUBSTITUTE, @@ -804,13 +796,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( id="data_collection_denylist_custom_terms", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "allowlist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -821,10 +807,8 @@ def test_request_body_data_collection_wins_over_send_default_pii( ), pytest.param( { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["identity"]} - } + "data_collection": { + "cookies": {"mode": "allowlist", "terms": ["identity"]} } }, { @@ -838,7 +822,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}, + "data_collection": {"cookies": {"mode": "denylist"}}, }, { "jwt": SENSITIVE_DATA_SUBSTITUTE, diff --git a/tests/integrations/mcp/test_mcp.py b/tests/integrations/mcp/test_mcp.py index 1150302ac8..15432d8d84 100644 --- a/tests/integrations/mcp/test_mcp.py +++ b/tests/integrations/mcp/test_mcp.py @@ -2247,7 +2247,7 @@ async def test_tool_data_collection_inputs( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -2365,7 +2365,7 @@ async def test_tool_data_collection_outputs( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -2486,7 +2486,7 @@ async def test_prompt_data_collection_inputs( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -2572,7 +2572,7 @@ async def test_include_prompts_ignored_when_data_collection_set( traces_sample_rate=1.0, send_default_pii=True, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {"gen_ai": {"outputs": True}}}, + data_collection={"gen_ai": {"outputs": True}}, ) server = Server("test-server") diff --git a/tests/integrations/mistral/test_mistral.py b/tests/integrations/mistral/test_mistral.py index 0854683f4d..21808020c4 100644 --- a/tests/integrations/mistral/test_mistral.py +++ b/tests/integrations/mistral/test_mistral.py @@ -490,7 +490,7 @@ def test_input_attributes_nonstreaming_chat( traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {}}, + data_collection={}, ) else: sentry_init( @@ -779,7 +779,7 @@ async def test_input_attributes_nonstreaming_chat_async( traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {}}, + data_collection={}, ) else: sentry_init( @@ -871,7 +871,7 @@ def test_output_attributes_nonstreaming_chat( traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {}}, + data_collection={}, ) else: sentry_init( @@ -981,7 +981,7 @@ async def test_output_attributes_nonstreaming_chat_async( traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {}}, + data_collection={}, ) else: sentry_init( diff --git a/tests/integrations/openai/test_openai.py b/tests/integrations/openai/test_openai.py index cb1c033c5e..96866886ec 100644 --- a/tests/integrations/openai/test_openai.py +++ b/tests/integrations/openai/test_openai.py @@ -729,7 +729,7 @@ def test_completions_api_data_collection( integrations=[OpenAIIntegration()], disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, - _experiments={"data_collection": data_collection}, + data_collection=data_collection, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) @@ -861,7 +861,7 @@ def test_completions_api_data_collection_outputs( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -977,7 +977,7 @@ async def test_completions_api_data_collection_outputs_async( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -1042,7 +1042,7 @@ def test_completions_api_data_collection_outputs_empty_choices( integrations=[OpenAIIntegration()], disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, - _experiments={"data_collection": {"gen_ai": {"outputs": True}}}, + data_collection={"gen_ai": {"outputs": True}}, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) @@ -1130,7 +1130,7 @@ def test_streaming_chat_completion_data_collection_outputs( disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, send_default_pii=False, - _experiments={"data_collection": data_collection}, + data_collection=data_collection, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) @@ -1246,7 +1246,7 @@ async def test_streaming_chat_completion_data_collection_outputs_async( disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, send_default_pii=False, - _experiments={"data_collection": data_collection}, + data_collection=data_collection, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) @@ -3585,7 +3585,7 @@ def test_embeddings_create_data_collection( sentry_init_kwargs = dict(init_kwargs) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -3652,7 +3652,7 @@ def test_embeddings_create_data_collection_inputs_disabled_input_shapes( send_default_pii=True, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {"gen_ai": {"inputs": False}}}, + data_collection={"gen_ai": {"inputs": False}}, ) client = OpenAI(api_key="z") @@ -3982,7 +3982,7 @@ async def test_embeddings_create_async_data_collection( sentry_init_kwargs = dict(init_kwargs) if data_collection is not None: - sentry_init_kwargs["_experiments"] = {"data_collection": data_collection} + sentry_init_kwargs["data_collection"] = data_collection sentry_init(**sentry_init_kwargs) @@ -5841,7 +5841,7 @@ def test_responses_api_data_collection( integrations=[OpenAIIntegration(include_prompts=include_prompts)], disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, - _experiments={"data_collection": data_collection}, + data_collection=data_collection, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) @@ -6034,7 +6034,7 @@ def test_responses_api_data_collection_outputs( "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -6133,7 +6133,7 @@ def test_responses_api_data_collection_outputs_shapes( integrations=[OpenAIIntegration()], disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, - _experiments={"data_collection": {"gen_ai": {"outputs": True}}}, + data_collection={"gen_ai": {"outputs": True}}, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) @@ -6201,7 +6201,7 @@ def test_streaming_responses_api_data_collection_outputs( disabled_integrations=[StdlibIntegration], traces_sample_rate=1.0, send_default_pii=False, - _experiments={"data_collection": data_collection}, + data_collection=data_collection, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", ) diff --git a/tests/integrations/openai_agents/test_openai_agents.py b/tests/integrations/openai_agents/test_openai_agents.py index 470af4a071..8bc49a2c9f 100644 --- a/tests/integrations/openai_agents/test_openai_agents.py +++ b/tests/integrations/openai_agents/test_openai_agents.py @@ -704,24 +704,24 @@ async def test_agent_invocation_span_no_pii( "init_kwargs,expect_messages", [ pytest.param( - {"_experiments": {"data_collection": {"gen_ai": {"inputs": True}}}}, + {"data_collection": {"gen_ai": {"inputs": True}}}, True, id="gen_ai_inputs_true", ), pytest.param( - {"_experiments": {"data_collection": {"gen_ai": {"inputs": False}}}}, + {"data_collection": {"gen_ai": {"inputs": False}}}, False, id="gen_ai_inputs_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="data_collection_defaults_to_enabled", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"gen_ai": {"inputs": False}}}, + "data_collection": {"gen_ai": {"inputs": False}}, }, False, id="data_collection_wins_over_send_default_pii_true", @@ -729,7 +729,7 @@ async def test_agent_invocation_span_no_pii( pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"gen_ai": {"inputs": True}}}, + "data_collection": {"gen_ai": {"inputs": True}}, }, True, id="data_collection_wins_over_send_default_pii_false", @@ -882,24 +882,24 @@ async def test_invoke_agent_span_data_collection_inputs( "init_kwargs,expect_response_text", [ pytest.param( - {"_experiments": {"data_collection": {"gen_ai": {"outputs": True}}}}, + {"data_collection": {"gen_ai": {"outputs": True}}}, True, id="gen_ai_outputs_true", ), pytest.param( - {"_experiments": {"data_collection": {"gen_ai": {"outputs": False}}}}, + {"data_collection": {"gen_ai": {"outputs": False}}}, False, id="gen_ai_outputs_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="data_collection_defaults_to_enabled", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"gen_ai": {"outputs": False}}}, + "data_collection": {"gen_ai": {"outputs": False}}, }, False, id="data_collection_wins_over_send_default_pii_true", @@ -907,7 +907,7 @@ async def test_invoke_agent_span_data_collection_inputs( pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"gen_ai": {"outputs": True}}}, + "data_collection": {"gen_ai": {"outputs": True}}, }, True, id="data_collection_wins_over_send_default_pii_false", @@ -1120,7 +1120,7 @@ async def test_data_collection_inputs( init_kwargs["disabled_integrations"] = [StdlibIntegration] init_kwargs["trace_lifecycle"] = "stream" if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection with patch.object( agent.model._client._client, @@ -1278,7 +1278,7 @@ async def test_data_collection_outputs( init_kwargs["disabled_integrations"] = [StdlibIntegration] init_kwargs["trace_lifecycle"] = "stream" if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection with patch.object( agent_with_tool.model._client._client, @@ -3890,7 +3890,7 @@ async def test_tool_execution_span_data_collection( ): init_kwargs = {"send_default_pii": send_default_pii} if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection _, tool_span_data = await run_tool_agent( simple_test_tool, @@ -3925,7 +3925,7 @@ def failing_tool(message: str) -> str: tool_span, tool_span_data = await run_tool_agent( failing_tool, span_streaming, - _experiments={"data_collection": {"gen_ai": {"outputs": False}}}, + data_collection={"gen_ai": {"outputs": False}}, ) assert tool_span_data[SPANDATA.GEN_AI_TOOL_NAME] == "failing_tool" @@ -3948,9 +3948,7 @@ async def test_tool_execution_span_non_pii_data_always_set( simple_test_tool, span_streaming, run_kwargs={"conversation_id": "conv_tool_test_456"}, - _experiments={ - "data_collection": {"gen_ai": {"inputs": False, "outputs": False}} - }, + data_collection={"gen_ai": {"inputs": False, "outputs": False}}, ) assert tool_span_data[SPANDATA.GEN_AI_TOOL_NAME] == "simple_test_tool" diff --git a/tests/integrations/pydantic_ai/test_pydantic_ai.py b/tests/integrations/pydantic_ai/test_pydantic_ai.py index 26d2734b78..e100e62671 100644 --- a/tests/integrations/pydantic_ai/test_pydantic_ai.py +++ b/tests/integrations/pydantic_ai/test_pydantic_ai.py @@ -4499,7 +4499,7 @@ async def test_data_collection_gen_ai_inputs_gates_request_messages_tool_inputs_ "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -4639,7 +4639,7 @@ async def test_data_collection_gen_ai_outputs_gates_response_text_and_tool_outpu "trace_lifecycle": "stream" if span_streaming else "static", } if data_collection is not None: - init_kwargs["_experiments"] = {"data_collection": data_collection} + init_kwargs["data_collection"] = data_collection sentry_init(**init_kwargs) @@ -4755,7 +4755,7 @@ async def test_data_collection_gen_ai_output_message_parts_follow_outputs_gate( traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {"gen_ai": gen_ai}}, + data_collection={"gen_ai": gen_ai}, ) test_agent = get_test_agent() @@ -4830,9 +4830,7 @@ async def test_data_collection_gen_ai_request_messages_keep_tool_returns_when_ou traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, trace_lifecycle="stream" if span_streaming else "static", - _experiments={ - "data_collection": {"gen_ai": {"inputs": True, "outputs": False}} - }, + data_collection={"gen_ai": {"inputs": True, "outputs": False}}, ) test_agent = get_test_agent() diff --git a/tests/integrations/pymongo/test_pymongo.py b/tests/integrations/pymongo/test_pymongo.py index 5bf6bb4e2c..9e296982f5 100644 --- a/tests/integrations/pymongo/test_pymongo.py +++ b/tests/integrations/pymongo/test_pymongo.py @@ -112,24 +112,24 @@ def test_transactions(sentry_init, capture_events, mongo_server, with_pii): DATA_COLLECTION_DATABASE_QUERY_DATA_USE_CASES = [ pytest.param( - {"_experiments": {"data_collection": {"database_query_data": True}}}, + {"data_collection": {"database_query_data": True}}, True, id="query_data_enabled", ), pytest.param( - {"_experiments": {"data_collection": {"database_query_data": False}}}, + {"data_collection": {"database_query_data": False}}, False, id="query_data_disabled", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="query_data_default", ), pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"database_query_data": True}}, + "data_collection": {"database_query_data": True}, }, True, id="data_collection_overrides_pii_off", @@ -137,7 +137,7 @@ def test_transactions(sentry_init, capture_events, mongo_server, with_pii): pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"database_query_data": False}}, + "data_collection": {"database_query_data": False}, }, False, id="data_collection_overrides_pii_on", diff --git a/tests/integrations/pyramid/test_pyramid.py b/tests/integrations/pyramid/test_pyramid.py index 0f90143600..4c80298e44 100644 --- a/tests/integrations/pyramid/test_pyramid.py +++ b/tests/integrations/pyramid/test_pyramid.py @@ -683,7 +683,7 @@ def test_request_body_data_collection( ): sentry_init( integrations=[PyramidIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) data = {"foo": "bar"} @@ -712,7 +712,7 @@ def test_request_body_dropped_with_form_and_files_data_collection( sentry_init( integrations=[PyramidIntegration()], max_request_body_size="always", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) data = { @@ -742,7 +742,7 @@ def test_transaction_request_body_data_collection( sentry_init( integrations=[PyramidIntegration()], traces_sample_rate=1.0, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) data = {"username": "sentry-user", "age": "26"} @@ -773,7 +773,7 @@ def test_oversized_request_body_not_annotated_data_collection( sentry_init( integrations=[PyramidIntegration()], max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) data = "a" * 2000 diff --git a/tests/integrations/pyreqwest/test_pyreqwest.py b/tests/integrations/pyreqwest/test_pyreqwest.py index 74c67ff66e..9c70aa9896 100644 --- a/tests/integrations/pyreqwest/test_pyreqwest.py +++ b/tests/integrations/pyreqwest/test_pyreqwest.py @@ -1223,16 +1223,14 @@ def test_crumb_capture_client_error_span_streaming( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -1240,10 +1238,8 @@ def test_crumb_capture_client_error_span_streaming( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -1251,30 +1247,22 @@ def test_crumb_capture_client_error_span_streaming( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -1334,16 +1322,14 @@ def test_url_query_data_collection_span_streaming_sync( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -1351,10 +1337,8 @@ def test_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -1362,30 +1346,22 @@ def test_url_query_data_collection_span_streaming_sync( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -1429,16 +1405,14 @@ async def test_url_query_data_collection_span_streaming_async( "init_kwargs, expected_suffix", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -1487,16 +1461,14 @@ def test_url_full_reassembly_span_streaming_sync( "init_kwargs, expected_suffix", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -1544,20 +1516,14 @@ async def test_url_full_reassembly_span_streaming_async( "init_kwargs, expected_suffix", [ pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "#frag", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "#frag", id="data_collection_wins_over_send_default_pii", @@ -1612,20 +1578,14 @@ def test_url_query_params_off_keeps_bare_url_span_streaming_sync( "init_kwargs, expected_suffix", [ pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "#frag", id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, "#frag", id="data_collection_wins_over_send_default_pii", @@ -1679,27 +1639,21 @@ async def test_url_query_params_off_keeps_bare_url_span_streaming_async( "init_kwargs, expected_query", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "", id="data_collection_off", ), @@ -1749,27 +1703,21 @@ def test_crumb_url_query_data_collection_sync( "init_kwargs, expected_query", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "", id="data_collection_off", ), @@ -1818,27 +1766,21 @@ async def test_crumb_url_query_data_collection_async( "init_kwargs, expected_query", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "", id="data_collection_off", ), @@ -1884,27 +1826,21 @@ def test_crumb_url_query_data_collection_legacy_sync( "init_kwargs, expected_query", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, "", id="data_collection_off", ), @@ -1959,7 +1895,7 @@ def test_omit_url_data_if_parsing_fails_span_streaming( integrations=[PyreqwestIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) items = capture_items("span") diff --git a/tests/integrations/quart/test_quart.py b/tests/integrations/quart/test_quart.py index 667b6d955a..d8e2a58f8e 100644 --- a/tests/integrations/quart/test_quart.py +++ b/tests/integrations/quart/test_quart.py @@ -936,7 +936,7 @@ async def test_span_streaming_request_attributes_with_pii(sentry_init, capture_i pytest.param( { "send_default_pii": True, - "data_collection": None, + "data_collection": {}, }, { "authorization": "[Filtered]", @@ -948,7 +948,7 @@ async def test_span_streaming_request_attributes_with_pii(sentry_init, capture_i pytest.param( { "send_default_pii": False, - "data_collection": None, + "data_collection": {}, }, { "authorization": "[Filtered]", @@ -1052,9 +1052,7 @@ async def test_span_streaming_sensitive_header_scrubbing( traces_sample_rate=1.0, send_default_pii=options["send_default_pii"], trace_lifecycle="stream", - _experiments={ - "data_collection": options["data_collection"], - }, + data_collection=options["data_collection"], ) items = capture_items("span") @@ -1172,24 +1170,24 @@ async def login(): QUART_USER_INFO_CASES = [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="dc_default_user_info", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": True}}}, + {"data_collection": {"user_info": True}}, True, id="dc_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, False, id="dc_user_info_false", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, False, id="dc_wins_over_pii", @@ -1243,13 +1241,11 @@ async def test_span_streaming_quart_auth_user_id_data_collection( ): from quart_auth import AuthUser, login_user - kwargs = dict(init_kwargs) sentry_init( integrations=[quart_sentry.QuartIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=kwargs.pop("_experiments", {}), - **kwargs, + **init_kwargs, ) items = capture_items("span") @@ -1283,13 +1279,11 @@ async def login(): async def test_span_streaming_request_attributes_data_collection( sentry_init, capture_items, init_kwargs, expect_user_info ): - kwargs = dict(init_kwargs) sentry_init( integrations=[quart_sentry.QuartIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=kwargs.pop("_experiments", {}), - **kwargs, + **init_kwargs, ) items = capture_items("span") @@ -1361,16 +1355,14 @@ async def test_span_streaming_sensitive_header_passthrough_with_pii_and_no_data_ id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -1378,10 +1370,8 @@ async def test_span_streaming_sensitive_header_passthrough_with_pii_and_no_data_ ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -1389,24 +1379,22 @@ async def test_span_streaming_sensitive_header_passthrough_with_pii_and_no_data_ ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - {"_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}}, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -1421,14 +1409,11 @@ async def test_span_streaming_sensitive_header_passthrough_with_pii_and_no_data_ async def test_span_streaming_url_query_data_collection( sentry_init, capture_items, init_kwargs, expected_query ): - kwargs = dict(init_kwargs) - experiments = kwargs.pop("_experiments", {}) sentry_init( integrations=[quart_sentry.QuartIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments=experiments, - **kwargs, + **init_kwargs, ) items = capture_items("span") @@ -1444,7 +1429,7 @@ async def test_span_streaming_url_query_data_collection( segment = spans[0] - data_collection_enabled = "data_collection" in experiments + data_collection_enabled = "data_collection" in init_kwargs url_attrs_expected = data_collection_enabled or init_kwargs.get( "send_default_pii", False ) @@ -1472,7 +1457,7 @@ async def test_span_streaming_url_query_multi_and_blank_values( integrations=[quart_sentry.QuartIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) items = capture_items("span") diff --git a/tests/integrations/redis/test_redis.py b/tests/integrations/redis/test_redis.py index 629f305ac3..cea9b51e19 100644 --- a/tests/integrations/redis/test_redis.py +++ b/tests/integrations/redis/test_redis.py @@ -138,7 +138,7 @@ def test_redis_pipeline_data_collection( integrations=[RedisIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) connection = FakeStrictRedis() @@ -293,7 +293,7 @@ def test_data_collection_database_query_data( integrations=[RedisIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) connection = FakeStrictRedis() @@ -349,7 +349,7 @@ def test_database_query_data_takes_precedence_over_send_default_pii( traces_sample_rate=1.0, send_default_pii=send_default_pii, trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) connection = FakeStrictRedis() diff --git a/tests/integrations/sanic/test_sanic.py b/tests/integrations/sanic/test_sanic.py index 0c84f63044..2d97a0ea12 100644 --- a/tests/integrations/sanic/test_sanic.py +++ b/tests/integrations/sanic/test_sanic.py @@ -661,16 +661,14 @@ def test_client_address_span_attribute_data_collection( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -678,10 +676,8 @@ def test_client_address_span_attribute_data_collection( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -689,24 +685,22 @@ def test_client_address_span_attribute_data_collection( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - {"_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}}, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -723,13 +717,10 @@ def test_client_address_span_attribute_data_collection( def test_url_query_data_collection_span_streaming( sentry_init, app, capture_items, init_kwargs, expected_query ): - init_kwargs = dict(init_kwargs) - experiments = dict(init_kwargs.pop("_experiments", {})) - experiments["trace_lifecycle"] = "stream" sentry_init( integrations=[SanicIntegration()], traces_sample_rate=1.0, - _experiments=experiments, + _experiments={"trace_lifecycle": "stream"}, **init_kwargs, ) @@ -749,7 +740,7 @@ def test_url_query_data_collection_span_streaming( and i.payload["is_segment"] ] - data_collection_enabled = "data_collection" in experiments + data_collection_enabled = "data_collection" in init_kwargs url_attrs_expected = data_collection_enabled or init_kwargs.get( "send_default_pii", False ) @@ -789,7 +780,7 @@ def test_url_query_data_collection_event_processor( assert event["request"]["url"].endswith("/message") assert event["request"]["method"] == "GET" - if "data_collection" not in init_kwargs.get("_experiments", {}): + if "data_collection" not in init_kwargs: assert ( event["request"]["query_string"] == "toy=tennisball&color=red&auth=secret" ) @@ -823,7 +814,7 @@ def test_request_body_data_collection_event_processor( ): sentry_init( integrations=[SanicIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) data = {"hey": 42} @@ -858,7 +849,7 @@ def test_oversized_request_body_not_annotated_data_collection( sentry_init( integrations=[SanicIntegration()], max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) @app.route("/oversized", methods=["POST"]) diff --git a/tests/integrations/starlette/test_starlette.py b/tests/integrations/starlette/test_starlette.py index 70b3940552..585cf4d541 100644 --- a/tests/integrations/starlette/test_starlette.py +++ b/tests/integrations/starlette/test_starlette.py @@ -520,7 +520,7 @@ async def test_formdata_request_body_data_collection_http_bodies_empty( max_request_body_size="always", integrations=[StarletteIntegration()], trace_lifecycle="stream" if span_streaming else "static", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) starlette_app = starlette_app_factory() @@ -580,9 +580,7 @@ async def test_request_body_data_collection( traces_sample_rate=1.0, integrations=[StarletteIntegration()], trace_lifecycle="stream" if span_streaming else "static", - _experiments=( - {} if data_collection is None else {"data_collection": data_collection} - ), + data_collection=data_collection, ) starlette_app = starlette_app_factory() @@ -676,12 +674,12 @@ async def test_request_info_no_pii(sentry_init, capture_events): id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "off"}}}}, + {"data_collection": {"cookies": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}}, + {"data_collection": {"cookies": {"mode": "denylist"}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -691,13 +689,7 @@ async def test_request_info_no_pii(sentry_init, capture_events): id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "denylist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "denylist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": SENSITIVE_DATA_SUBSTITUTE, @@ -707,13 +699,7 @@ async def test_request_info_no_pii(sentry_init, capture_events): id="data_collection_denylist_custom_terms", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "allowlist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -724,10 +710,8 @@ async def test_request_info_no_pii(sentry_init, capture_events): ), pytest.param( { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["identity"]} - } + "data_collection": { + "cookies": {"mode": "allowlist", "terms": ["identity"]} } }, { @@ -741,7 +725,7 @@ async def test_request_info_no_pii(sentry_init, capture_events): pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}, + "data_collection": {"cookies": {"mode": "denylist"}}, }, { "jwt": SENSITIVE_DATA_SUBSTITUTE, @@ -787,27 +771,21 @@ async def test_cookie_data_collection( id="legacy_send_default_pii_true", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -848,17 +826,13 @@ def test_query_string_data_collection( id="legacy_send_default_pii_true", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", "http://testserver/message?toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, "http://testserver/message", id="data_collection_off", @@ -918,24 +892,24 @@ def test_span_http_query_data_collection( id="legacy_send_default_pii_false", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, TESTCLIENT_IP, id="data_collection_default_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": True}}}, + {"data_collection": {"user_info": True}}, TESTCLIENT_IP, id="data_collection_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, NO_USER_INFO, id="data_collection_user_info_false", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, NO_USER_INFO, id="data_collection_wins_over_send_default_pii", @@ -1114,24 +1088,24 @@ def test_catch_exceptions( pytest.param({"send_default_pii": True}, True, id="legacy_pii_true"), pytest.param({"send_default_pii": False}, False, id="legacy_pii_false"), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, True, id="dc_default_user_info", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": True}}}, + {"data_collection": {"user_info": True}}, True, id="dc_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, False, id="dc_user_info_false", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, False, id="dc_wins_over_pii", diff --git a/tests/integrations/starlite/test_starlite.py b/tests/integrations/starlite/test_starlite.py index 5c39c897d1..cb659faf15 100644 --- a/tests/integrations/starlite/test_starlite.py +++ b/tests/integrations/starlite/test_starlite.py @@ -586,9 +586,7 @@ def test_request_body_data_collection( sentry_init( traces_sample_rate=1.0, integrations=[StarliteIntegration()], - _experiments=( - {} if data_collection is None else {"data_collection": data_collection} - ), + data_collection=data_collection, ) starlite_app = starlite_app_factory() @@ -616,7 +614,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( traces_sample_rate=1.0, integrations=[StarliteIntegration()], send_default_pii=True, - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) starlite_app = starlite_app_factory() @@ -655,12 +653,12 @@ def test_request_body_data_collection_wins_over_send_default_pii( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "off"}}}}, + {"data_collection": {"cookies": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}}, + {"data_collection": {"cookies": {"mode": "denylist"}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -670,13 +668,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "denylist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "denylist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": SENSITIVE_DATA_SUBSTITUTE, @@ -686,13 +678,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( id="data_collection_denylist_custom_terms", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "allowlist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -703,10 +689,8 @@ def test_request_body_data_collection_wins_over_send_default_pii( ), pytest.param( { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["identity"]} - } + "data_collection": { + "cookies": {"mode": "allowlist", "terms": ["identity"]} } }, { @@ -720,7 +704,7 @@ def test_request_body_data_collection_wins_over_send_default_pii( pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}, + "data_collection": {"cookies": {"mode": "denylist"}}, }, { "jwt": SENSITIVE_DATA_SUBSTITUTE, diff --git a/tests/integrations/stdlib/test_httplib.py b/tests/integrations/stdlib/test_httplib.py index 2da3a1a17e..db9c94bc51 100644 --- a/tests/integrations/stdlib/test_httplib.py +++ b/tests/integrations/stdlib/test_httplib.py @@ -1495,16 +1495,14 @@ def test_chunked_response_span_covers_body_read( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -1512,10 +1510,8 @@ def test_chunked_response_span_covers_body_read( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -1523,30 +1519,22 @@ def test_chunked_response_span_covers_body_read( ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - }, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -1590,16 +1578,14 @@ def test_url_query_data_collection_span_streaming( "init_kwargs, expected_suffix", [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "?toy=tennisball&color=red&auth=%5BFiltered%5D#frag", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "?toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D#frag", @@ -1659,17 +1645,13 @@ def test_url_full_reassembly_span_streaming( id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", True, id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, True, id="data_collection_off", diff --git a/tests/integrations/strawberry/test_strawberry.py b/tests/integrations/strawberry/test_strawberry.py index 69f45fd4b1..f9f652fd15 100644 --- a/tests/integrations/strawberry/test_strawberry.py +++ b/tests/integrations/strawberry/test_strawberry.py @@ -311,7 +311,7 @@ def test_event_processor_data_collection( init_kwargs = { "integrations": [StrawberryIntegration(async_execution=async_execution)] + framework_integrations, - "_experiments": {"data_collection": data_collection}, + "data_collection": data_collection, } if send_default_pii is not None: init_kwargs["send_default_pii"] = send_default_pii @@ -376,7 +376,7 @@ def test_response_data_collection( sentry_init( integrations=[StrawberryIntegration(async_execution=async_execution)] + framework_integrations, - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) events = capture_events() @@ -439,7 +439,7 @@ def test_request_data_collection_no_framework( # the integration's public event-processing path sentry_init( integrations=[StrawberryIntegration()], - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) events = capture_events() @@ -479,9 +479,7 @@ def test_request_data_collection_no_framework( def test_request_data_collection_no_variables(sentry_init, capture_events): sentry_init( integrations=[StrawberryIntegration()], - _experiments={ - "data_collection": {"graphql": {"document": True, "variables": True}} - }, + data_collection={"graphql": {"document": True, "variables": True}}, ) events = capture_events() @@ -1139,7 +1137,7 @@ def test_graphql_span_data_collection( + framework_integrations, "traces_sample_rate": 1, "trace_lifecycle": "stream" if span_streaming else "static", - "_experiments": {"data_collection": data_collection}, + "data_collection": data_collection, } if send_default_pii is not None: init_kwargs["send_default_pii"] = send_default_pii @@ -1234,9 +1232,7 @@ def test_handle_none_query_gracefully_with_data_collection( StrawberryIntegration(async_execution=async_execution), ] + framework_integrations, - _experiments={ - "data_collection": {"graphql": {"document": True, "variables": True}} - }, + data_collection={"graphql": {"document": True, "variables": True}}, ) events = capture_events() diff --git a/tests/integrations/tornado/test_tornado.py b/tests/integrations/tornado/test_tornado.py index 063e14b1e5..e995e3e2be 100644 --- a/tests/integrations/tornado/test_tornado.py +++ b/tests/integrations/tornado/test_tornado.py @@ -148,12 +148,12 @@ def test_basic(tornado_testcase, sentry_init, capture_events): id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "off"}}}}, + {"data_collection": {"cookies": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( - {"_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}}, + {"data_collection": {"cookies": {"mode": "denylist"}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -163,13 +163,7 @@ def test_basic(tornado_testcase, sentry_init, capture_events): id="data_collection_denylist_default", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "denylist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "denylist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": SENSITIVE_DATA_SUBSTITUTE, @@ -179,13 +173,7 @@ def test_basic(tornado_testcase, sentry_init, capture_events): id="data_collection_denylist_custom_terms", ), pytest.param( - { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["theme"]} - } - } - }, + {"data_collection": {"cookies": {"mode": "allowlist", "terms": ["theme"]}}}, { "jwt": SENSITIVE_DATA_SUBSTITUTE, "theme": "dark", @@ -196,10 +184,8 @@ def test_basic(tornado_testcase, sentry_init, capture_events): ), pytest.param( { - "_experiments": { - "data_collection": { - "cookies": {"mode": "allowlist", "terms": ["identity"]} - } + "data_collection": { + "cookies": {"mode": "allowlist", "terms": ["identity"]} } }, { @@ -213,7 +199,7 @@ def test_basic(tornado_testcase, sentry_init, capture_events): pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"cookies": {"mode": "denylist"}}}, + "data_collection": {"cookies": {"mode": "denylist"}}, }, { "jwt": SENSITIVE_DATA_SUBSTITUTE, @@ -264,16 +250,14 @@ async def get(self): id="defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -281,10 +265,8 @@ async def get(self): ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", @@ -292,24 +274,22 @@ async def get(self): ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["auth"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["auth"]} } }, "toy=%5BFiltered%5D&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist_sensitive_term", ), pytest.param( - {"_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}}, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"url_query_params": {"mode": "off"}}}, + "data_collection": {"url_query_params": {"mode": "off"}}, }, None, id="data_collection_wins_over_send_default_pii", @@ -341,7 +321,7 @@ def test_url_query_data_collection_span_streaming( (server_span,) = [item.payload for item in items] - data_collection_enabled = "data_collection" in init_kwargs.get("_experiments", {}) + data_collection_enabled = "data_collection" in init_kwargs url_attrs_expected = data_collection_enabled or init_kwargs.get( "send_default_pii", False ) @@ -386,7 +366,7 @@ def test_url_query_data_collection_event_processor( assert event["request"]["url"].endswith("/hi") assert event["request"]["method"] == "GET" - if "data_collection" not in init_kwargs.get("_experiments", {}): + if "data_collection" not in init_kwargs: assert ( event["request"]["query_string"] == "toy=tennisball&color=red&auth=secret" ) @@ -403,7 +383,7 @@ def test_url_query_data_collection_no_query_string( integrations=[TornadoIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) items = capture_items("span") @@ -428,7 +408,7 @@ def test_url_query_data_collection_repeated_and_blank_params( integrations=[TornadoIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": {}}, + data_collection={}, ) items = capture_items("span") @@ -451,7 +431,7 @@ def test_url_query_data_collection__event_processor_no_query_string( integrations=[TornadoIntegration()], traces_sample_rate=1.0, trace_lifecycle="static", - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -476,7 +456,7 @@ def test_url_query_data_collection_event_processor_repeated_and_blank_params( integrations=[TornadoIntegration()], traces_sample_rate=1.0, trace_lifecycle="static", - _experiments={"data_collection": {}}, + data_collection={}, ) events = capture_events() @@ -518,7 +498,7 @@ def test_request_body_data_collection_span_streaming( integrations=[TornadoIntegration()], traces_sample_rate=1.0, trace_lifecycle="stream", - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) items = capture_items("span") @@ -562,7 +542,7 @@ def test_request_body_data_collection_event_processor( sentry_init( integrations=[TornadoIntegration()], trace_lifecycle="static", - _experiments={"data_collection": data_collection}, + data_collection=data_collection, ) events = capture_events() @@ -599,7 +579,7 @@ def test_oversized_request_body_not_annotated_data_collection_span_streaming( traces_sample_rate=1.0, trace_lifecycle="stream", max_request_body_size="small", - _experiments={"data_collection": {"http_bodies": []}}, + data_collection={"http_bodies": []}, ) items = capture_items("span") diff --git a/tests/integrations/utils.py b/tests/integrations/utils.py index 8980c4f80c..2f0cbbaff7 100644 --- a/tests/integrations/utils.py +++ b/tests/integrations/utils.py @@ -12,19 +12,19 @@ {"send_default_pii": False}, False, id="legacy_send_default_pii_false" ), pytest.param( - {"_experiments": {"data_collection": {"user_info": True}}}, + {"data_collection": {"user_info": True}}, True, id="data_collection_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, False, id="data_collection_user_info_false", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, False, id="data_collection_wins_over_send_default_pii_true", @@ -32,7 +32,7 @@ pytest.param( { "send_default_pii": False, - "_experiments": {"data_collection": {"user_info": True}}, + "data_collection": {"user_info": True}, }, True, id="data_collection_wins_over_send_default_pii_false", @@ -48,23 +48,21 @@ pytest.param({}, True, id="defaults"), pytest.param({"send_default_pii": True}, True, id="send_default_pii_true"), pytest.param({"send_default_pii": False}, True, id="send_default_pii_false"), + pytest.param({"data_collection": {}}, True, id="data_collection_default"), pytest.param( - {"_experiments": {"data_collection": {}}}, True, id="data_collection_default" - ), - pytest.param( - {"_experiments": {"data_collection": {"user_info": True}}}, + {"data_collection": {"user_info": True}}, True, id="data_collection_user_info_true", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, False, id="data_collection_user_info_false", ), pytest.param( { "send_default_pii": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, False, id="data_collection_wins_over_send_default_pii", @@ -72,25 +70,25 @@ ] # Shared parametrization test matrix exercising the interaction between the -# ``data_collection.queues`` experiment and the legacy ``send_default_pii`` boolean +# ``data_collection.queues`` setting and the legacy ``send_default_pii`` boolean # for job/task args and kwargs collected by queue integrations (rq, arq, huey). # Each case is ``(init_kwargs, expected_args, expected_kwargs)`` where ``None`` for # the expected values means args/kwargs are not collected at all. DATA_COLLECTION_QUEUES_CASES = [ pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, [1], {"b": 0}, id="data_collection_default", ), pytest.param( - {"_experiments": {"data_collection": {"queues": True}}}, + {"data_collection": {"queues": True}}, [1], {"b": 0}, id="data_collection_queues_on", ), pytest.param( - {"_experiments": {"data_collection": {"queues": False}}}, + {"data_collection": {"queues": False}}, None, None, id="data_collection_queues_off", @@ -103,7 +101,7 @@ ), pytest.param( { - "_experiments": {"data_collection": {"queues": False}}, + "data_collection": {"queues": False}, "send_default_pii": False, }, None, @@ -112,7 +110,7 @@ ), pytest.param( { - "_experiments": {"data_collection": {"queues": True}}, + "data_collection": {"queues": True}, "send_default_pii": False, }, [1], diff --git a/tests/integrations/wsgi/test_wsgi.py b/tests/integrations/wsgi/test_wsgi.py index 27c1c29b11..6fbd0a8d7f 100644 --- a/tests/integrations/wsgi/test_wsgi.py +++ b/tests/integrations/wsgi/test_wsgi.py @@ -835,7 +835,7 @@ def test_request_headers_data_collection_default_redacts_sensitive( sentry_init, crashing_app, capture_events, send_default_pii ): """ - When ``data_collection`` is configured (even as ``None``, i.e. spec + When ``data_collection`` is configured (here as ``{}``, i.e. spec defaults), the WSGI event processor routes request headers through the data-collection filtering path. Sensitive headers are redacted regardless of ``send_default_pii`` -- the value of that legacy option must not change @@ -843,7 +843,7 @@ def test_request_headers_data_collection_default_redacts_sensitive( """ sentry_init( send_default_pii=send_default_pii, - _experiments={"data_collection": None}, + data_collection={}, ) app = SentryWsgiMiddleware(crashing_app) client = Client(app) @@ -914,9 +914,7 @@ def test_request_headers_data_collection_off_collects_no_headers( collected at all -- the filtering returns an empty mapping. """ sentry_init( - _experiments={ - "data_collection": {"http_headers": {"request": {"mode": "off"}}} - }, + data_collection={"http_headers": {"request": {"mode": "off"}}}, ) app = SentryWsgiMiddleware(crashing_app) client = Client(app) @@ -945,10 +943,8 @@ def test_request_headers_data_collection_allowlist_redacts_all_but_allowed_terms is redacted. """ sentry_init( - _experiments={ - "data_collection": { - "http_headers": {"request": {"mode": "allowlist", "terms": ["custom"]}} - } + data_collection={ + "http_headers": {"request": {"mode": "allowlist", "terms": ["custom"]}} }, ) app = SentryWsgiMiddleware(crashing_app) @@ -980,10 +976,8 @@ def test_request_headers_data_collection_denylist_redacts_only_matched_terms( matching a configured term (partial, case-insensitive). """ sentry_init( - _experiments={ - "data_collection": { - "http_headers": {"request": {"mode": "denylist", "terms": ["custom"]}} - } + data_collection={ + "http_headers": {"request": {"mode": "denylist", "terms": ["custom"]}} }, ) app = SentryWsgiMiddleware(crashing_app) @@ -1020,11 +1014,9 @@ def test_request_headers_data_collection_cookie_always_redacted( ``Client`` manages its own cookie jar and strips the ``Cookie`` header. """ sentry_init( - _experiments={ - "data_collection": { - "http_headers": { - "request": {"mode": "allowlist", "terms": ["cookie", "custom"]} - } + data_collection={ + "http_headers": { + "request": {"mode": "allowlist", "terms": ["cookie", "custom"]} } }, ) @@ -1103,16 +1095,14 @@ def test_request_headers_legacy_pii_passes_headers_through( # data_collection configured: query string is routed through filtering. # Spec defaults -> denylist: only the sensitive ``auth`` is redacted. pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -1122,21 +1112,15 @@ def test_request_headers_legacy_pii_passes_headers_through( # it is not sensitive, proving the redaction comes from the allowlist. pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -1183,16 +1167,14 @@ def test_query_string_data_collection( ), # data_collection configured: attribute is routed through filtering. pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, "toy=tennisball&color=red&auth=%5BFiltered%5D", id="data_collection_denylist_default", ), pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "denylist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "denylist", "terms": ["toy"]} } }, "toy=%5BFiltered%5D&color=red&auth=%5BFiltered%5D", @@ -1202,21 +1184,15 @@ def test_query_string_data_collection( # it is not sensitive, proving the redaction comes from the allowlist. pytest.param( { - "_experiments": { - "data_collection": { - "url_query_params": {"mode": "allowlist", "terms": ["toy"]} - } + "data_collection": { + "url_query_params": {"mode": "allowlist", "terms": ["toy"]} } }, "toy=tennisball&color=%5BFiltered%5D&auth=%5BFiltered%5D", id="data_collection_allowlist", ), pytest.param( - { - "_experiments": { - "data_collection": {"url_query_params": {"mode": "off"}} - } - }, + {"data_collection": {"url_query_params": {"mode": "off"}}}, None, id="data_collection_off", ), @@ -1346,7 +1322,7 @@ def test_user_info_error_event_data_collection( def test_error_event_no_user_ip_address_without_remote_addr( sentry_init, crashing_app, capture_events ): - sentry_init(_experiments={"data_collection": {"user_info": True}}) + sentry_init(data_collection={"user_info": True}) app = SentryWsgiMiddleware(crashing_app) client = Client(app) events = capture_events() diff --git a/tests/test_data_collection.py b/tests/test_data_collection.py index 0d1525de47..6cf3b67ac0 100644 --- a/tests/test_data_collection.py +++ b/tests/test_data_collection.py @@ -9,16 +9,12 @@ def test_kvcb_invalid_mode(): with pytest.raises(ValueError): - sentry_sdk.init(_experiments={"data_collection": {"cookies": {"mode": "nope"}}}) # type: ignore Purposely ignoring to test invalid option + sentry_sdk.init(data_collection={"cookies": {"mode": "nope"}}) # type: ignore Purposely ignoring to test invalid option def test_stack_frame_variables_invalid_mode(): with pytest.raises(ValueError): - sentry_sdk.init( - _experiments={ - "data_collection": {"stack_frame_variables": {"mode": "nope"}} - } - ) + sentry_sdk.init(data_collection={"stack_frame_variables": {"mode": "nope"}}) @pytest.mark.parametrize( @@ -33,17 +29,11 @@ def test_stack_frame_variables_invalid_mode(): ) def test_frame_context_lines_invalid_value(value): with pytest.raises(ValueError): - sentry_sdk.init( - _experiments={"data_collection": {"frame_context_lines": value}} - ) + sentry_sdk.init(data_collection={"frame_context_lines": value}) def test_kvcb_from_dict_defaults_mode(): - sentry_sdk.init( - _experiments={ - "data_collection": {"cookies": {"mode": "denylist", "terms": ["x"]}} - } - ) + sentry_sdk.init(data_collection={"cookies": {"mode": "denylist", "terms": ["x"]}}) client = sentry_sdk.get_client() assert client.options["data_collection"]["cookies"] == { "mode": "denylist", @@ -54,13 +44,13 @@ def test_kvcb_from_dict_defaults_mode(): def test_http_headers_collection_defaults(): default_terms = ["forwarded", "-ip", "remote-", "via", "-user"] - sentry_sdk.init(_experiments={"data_collection": {"http_headers": {}}}) # type: ignore Purposely ignoring to test invalid option + sentry_sdk.init(data_collection={"http_headers": {}}) # type: ignore Purposely ignoring to test invalid option client = sentry_sdk.get_client() assert client.options["data_collection"]["http_headers"]["request"] == { "mode": "denylist" } - sentry_sdk.init(_experiments={"data_collection": {"http_headers": "off"}}) # type: ignore Purposely ignoring to test invalid option + sentry_sdk.init(data_collection={"http_headers": "off"}) # type: ignore Purposely ignoring to test invalid option client = sentry_sdk.get_client() assert client.options["data_collection"]["http_headers"]["request"] == { "mode": "denylist" @@ -76,11 +66,9 @@ def test_http_headers_collection_defaults(): def test_http_headers_use_default_in_setting_with_missing_config(): sentry_sdk.init( - _experiments={ - "data_collection": { - "http_headers": { - "request": {"mode": "allowlist", "terms": ["x-id"]}, - } + data_collection={ + "http_headers": { + "request": {"mode": "allowlist", "terms": ["x-id"]}, } } ) @@ -141,7 +129,7 @@ def _get(dc, path): id="send_default_pii_false_collects_no_pii", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, { "user_info": True, "gen_ai.inputs": True, @@ -154,11 +142,7 @@ def _get(dc, path): id="explicit_data_collection_uses_spec_defaults", ), pytest.param( - { - "_experiments": { - "data_collection": {"user_info": False, "http_bodies": []} - } - }, + {"data_collection": {"user_info": False, "http_bodies": []}}, { "user_info": False, "http_bodies": [], @@ -169,7 +153,7 @@ def _get(dc, path): ), pytest.param( { - "_experiments": {"data_collection": {}}, + "data_collection": {}, "include_local_variables": False, "include_source_context": False, }, @@ -178,13 +162,11 @@ def _get(dc, path): ), pytest.param( { - "_experiments": { - "data_collection": { - "cookies": {"mode": "off"}, - "url_query_params": {"mode": "allowlist", "terms": ["page"]}, - "http_headers": {"request": {"mode": "off"}}, - "gen_ai": {"inputs": False, "outputs": True}, - } + "data_collection": { + "cookies": {"mode": "off"}, + "url_query_params": {"mode": "allowlist", "terms": ["page"]}, + "http_headers": {"request": {"mode": "off"}}, + "gen_ai": {"inputs": False, "outputs": True}, } }, { @@ -199,14 +181,12 @@ def _get(dc, path): ), pytest.param( { - "_experiments": { - "data_collection": { - "cookies": None, - "http_headers": None, - "url_query_params": None, - "graphql": None, - "gen_ai": None, - } + "data_collection": { + "cookies": None, + "http_headers": None, + "url_query_params": None, + "graphql": None, + "gen_ai": None, } }, { @@ -221,7 +201,7 @@ def _get(dc, path): id="none_values_fall_back_to_spec_defaults", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, { "graphql.document": True, "graphql.variables": True, @@ -250,48 +230,46 @@ def _get(dc, path): id="legacy_pii_on_collects_graphql_database_and_queues", ), pytest.param( - {"_experiments": {"data_collection": {"graphql": {"variables": False}}}}, + {"data_collection": {"graphql": {"variables": False}}}, {"graphql.document": True, "graphql.variables": False}, id="explicit_partial_graphql_fills_omitted", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": True}}}, + {"data_collection": {"frame_context_lines": True}}, {"frame_context_lines": 5}, id="frame_context_lines_bool_fallback_true", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": False}}}, + {"data_collection": {"frame_context_lines": False}}, {"frame_context_lines": 0}, id="frame_context_lines_bool_fallback_false", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": 3}}}, + {"data_collection": {"frame_context_lines": 3}}, {"frame_context_lines": 3}, id="frame_context_lines_bool_fallback_3", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": 0}}}, + {"data_collection": {"frame_context_lines": 0}}, {"frame_context_lines": 0}, id="frame_context_lines_bool_fallback_0", ), pytest.param( - {"_experiments": {"data_collection": {"stack_frame_variables": True}}}, + {"data_collection": {"stack_frame_variables": True}}, {"stack_frame_variables": True}, id="stack_frame_variables_explicit_true", ), pytest.param( - {"_experiments": {"data_collection": {"stack_frame_variables": False}}}, + {"data_collection": {"stack_frame_variables": False}}, {"stack_frame_variables": False}, id="stack_frame_variables_explicit_false", ), pytest.param( { - "_experiments": { - "data_collection": { - "stack_frame_variables": { - "mode": "allowlist", - "terms": ["order_id"], - } + "data_collection": { + "stack_frame_variables": { + "mode": "allowlist", + "terms": ["order_id"], } } }, @@ -304,13 +282,7 @@ def _get(dc, path): id="stack_frame_variables_allowlist_dict", ), pytest.param( - { - "_experiments": { - "data_collection": { - "stack_frame_variables": {"terms": ["order_id"]} - } - } - }, + {"data_collection": {"stack_frame_variables": {"terms": ["order_id"]}}}, { "stack_frame_variables": { "mode": "denylist", @@ -320,26 +292,22 @@ def _get(dc, path): id="stack_frame_variables_dict_defaults_mode_to_denylist", ), pytest.param( - { - "_experiments": { - "data_collection": {"stack_frame_variables": {"mode": "off"}} - } - }, + {"data_collection": {"stack_frame_variables": {"mode": "off"}}}, {"stack_frame_variables": {"mode": "off"}}, id="stack_frame_variables_off_dict_omits_terms", ), pytest.param( - {"_experiments": {"data_collection": {"stack_frame_variables": "yes"}}}, + {"data_collection": {"stack_frame_variables": "yes"}}, {"stack_frame_variables": True}, id="stack_frame_variables_non_bool_truthy_coerces_to_true", ), pytest.param( - {"_experiments": {"data_collection": {"stack_frame_variables": ""}}}, + {"data_collection": {"stack_frame_variables": ""}}, {"stack_frame_variables": False}, id="stack_frame_variables_non_bool_falsy_coerces_to_false", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": None}}}, + {"data_collection": {"frame_context_lines": None}}, {"frame_context_lines": 5}, id="frame_context_lines_none_falls_back_to_spec_default", ), @@ -366,7 +334,7 @@ def test_initialize_client_data_collection_overrides_send_default_pii_and_warns( warnings.simplefilter("always") dc = _initialize_client_with_config( send_default_pii=True, - _experiments={"data_collection": {"user_info": False}}, + data_collection={"user_info": False}, ) assert dc["user_info"] is False # data_collection wins assert any(issubclass(w.category, DeprecationWarning) for w in caught) @@ -390,7 +358,7 @@ def test_initialize_client_data_collection_overrides_send_default_pii_and_warns( id="send_default_pii_enables_user_info", ), pytest.param( - {"_experiments": {"data_collection": {"user_info": False}}}, + {"data_collection": {"user_info": False}}, {"user_info": False, "provided_by_user": True}, id="explicit_data_collection_overrides_user_info", ), @@ -402,7 +370,7 @@ def test_initialize_client_data_collection_overrides_send_default_pii_and_warns( pytest.param( { "spotlight": True, - "_experiments": {"data_collection": {"user_info": False}}, + "data_collection": {"user_info": False}, }, {"provided_by_user": True, "user_info": False}, id="dsnless_spotlight_respects_explicit_data_collection", @@ -419,21 +387,70 @@ def test_client_data_collection_settings(init_kwargs, expected): assert client.options["data_collection"][key] is value -def test_has_data_collection_enabled_gates_on_presence(): +def test_has_data_collection_enabled_gates_on_user_provided_config(): assert has_data_collection_enabled(None) is False - assert has_data_collection_enabled({"_experiments": {}}) is False + assert has_data_collection_enabled({}) is False + # An unset/None option is "not provided by the user". + assert has_data_collection_enabled({"data_collection": None}) is False + # Every SDK call site passes post-resolution client options, where + # `data_collection` is always a fully-resolved dict carrying + # `provided_by_user`. That flag -- not the key's presence -- is the gate. assert ( - has_data_collection_enabled({"_experiments": {"data_collection": {}}}) is True + has_data_collection_enabled({"data_collection": {"provided_by_user": False}}) + is False ) assert ( - has_data_collection_enabled({"_experiments": {"data_collection": None}}) is True + has_data_collection_enabled({"data_collection": {"provided_by_user": True}}) + is True ) -def test_no_experiments_data_collection_values_fall_back_to_send_default_pii_configuration(): +@pytest.mark.parametrize( + "init_kwargs, expected", + [ + pytest.param({}, False, id="no_config"), + pytest.param({"send_default_pii": True}, False, id="send_default_pii_true"), + pytest.param({"send_default_pii": False}, False, id="send_default_pii_false"), + pytest.param({"data_collection": {}}, True, id="empty_data_collection"), + pytest.param( + {"data_collection": {"user_info": False}}, + True, + id="partial_data_collection", + ), + ], +) +def test_has_data_collection_enabled_after_resolution(init_kwargs, expected): + sentry_sdk.init(**init_kwargs) + assert has_data_collection_enabled(sentry_sdk.get_client().options) is expected + + +def test_no_data_collection_values_fall_back_to_send_default_pii_configuration(): sentry_sdk.init(send_default_pii=True) client = sentry_sdk.get_client() dc = client.options["data_collection"] assert dc["provided_by_user"] is False assert dc["user_info"] is True assert has_data_collection_enabled(client.options) is False + + +def test_data_collection_via_experiments(sentry_init): + sentry_init( + _experiments={"data_collection": {"user_info": True}}, + ) + + dc = sentry_sdk.get_client().options["data_collection"] + assert dc is not None + assert dc["provided_by_user"] is True + assert dc["user_info"] is True + + +def test_top_level_takes_precedence_over_experiments(sentry_init): + sentry_init( + data_collection={"user_info": False}, + _experiments={"data_collection": {"user_info": True}}, + ) + + dc = sentry_sdk.get_client().options["data_collection"] + assert dc is not None + assert dc["provided_by_user"] is True + assert dc["user_info"] is False diff --git a/tests/test_tracing_utils.py b/tests/test_tracing_utils.py index 070c56e8b8..3098e73667 100644 --- a/tests/test_tracing_utils.py +++ b/tests/test_tracing_utils.py @@ -321,17 +321,17 @@ def _get_query_breadcrumb_data( "sentry_options, expected_data", ( pytest.param( - {"_experiments": {"data_collection": {"database_query_data": True}}}, + {"data_collection": {"database_query_data": True}}, {"db.params": [1, 2], "db.paramstyle": "format"}, id="data_collection_on_records_params", ), pytest.param( - {"_experiments": {"data_collection": {"database_query_data": False}}}, + {"data_collection": {"database_query_data": False}}, {}, id="data_collection_off_strips_params", ), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, {"db.params": [1, 2], "db.paramstyle": "format"}, id="data_collection_default_records_params", ), @@ -352,20 +352,16 @@ def _get_query_breadcrumb_data( ), pytest.param( { - "_experiments": { - "record_sql_params": True, - "data_collection": {"database_query_data": False}, - } + "_experiments": {"record_sql_params": True}, + "data_collection": {"database_query_data": False}, }, {}, id="data_collection_off_takes_precedence_over_legacy_on", ), pytest.param( { - "_experiments": { - "record_sql_params": False, - "data_collection": {"database_query_data": True}, - } + "_experiments": {"record_sql_params": False}, + "data_collection": {"database_query_data": True}, }, {"db.params": [1, 2], "db.paramstyle": "format"}, id="data_collection_on_takes_precedence_over_legacy_off", @@ -388,7 +384,7 @@ def test_record_sql_queries_empty_params_not_recorded( data = _get_query_breadcrumb_data( sentry_init, capture_events, - {"_experiments": {"data_collection": {"database_query_data": True}}}, + {"data_collection": {"database_query_data": True}}, params_list=params_list, ) assert "db.params" not in data @@ -398,7 +394,7 @@ def test_record_sql_queries_paramstyle_passthrough(sentry_init, capture_events): data = _get_query_breadcrumb_data( sentry_init, capture_events, - {"_experiments": {"data_collection": {"database_query_data": True}}}, + {"data_collection": {"database_query_data": True}}, paramstyle="qmark", ) assert data["db.paramstyle"] == "qmark" @@ -410,7 +406,7 @@ def test_record_sql_queries_paramstyle_dropped_when_collection_off( data = _get_query_breadcrumb_data( sentry_init, capture_events, - {"_experiments": {"data_collection": {"database_query_data": False}}}, + {"data_collection": {"database_query_data": False}}, paramstyle="qmark", ) assert "db.paramstyle" not in data diff --git a/tests/test_utils.py b/tests/test_utils.py index 1b6d2892b9..2be8698640 100644 --- a/tests/test_utils.py +++ b/tests/test_utils.py @@ -497,19 +497,19 @@ def test_warns_on_invalid_sample_rate(rate, StringContaining): # noqa: N803 pytest.param({}, True, True, id="no_data_collection-include_true"), pytest.param({}, False, False, id="no_data_collection-include_false"), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, False, True, id="data_collection-spec_default_overrides_include_false", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": 3}}}, + {"data_collection": {"frame_context_lines": 3}}, True, True, id="data_collection-frame_context_lines_3", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": 0}}}, + {"data_collection": {"frame_context_lines": 0}}, True, False, id="data_collection-frame_context_lines_0_overrides_include_true", @@ -563,7 +563,7 @@ def _frame_with_locals(): def test_stack_frame_variables_bool_when_serializing_frame( sentry_init, data_collection, include_local_variables, expected_vars ): - sentry_init(_experiments={"data_collection": data_collection}) + sentry_init(data_collection=data_collection) result = serialize_frame( _frame_with_locals(), include_local_variables=include_local_variables @@ -573,7 +573,7 @@ def test_stack_frame_variables_bool_when_serializing_frame( def test_stack_frame_variables_true_does_not_filter_sensitive_locals(sentry_init): - sentry_init(_experiments={"data_collection": {"stack_frame_variables": True}}) + sentry_init(data_collection={"stack_frame_variables": True}) result = serialize_frame(_frame_with_locals()) @@ -629,7 +629,7 @@ def test_stack_frame_variables_true_does_not_filter_sensitive_locals(sentry_init def test_stack_frame_variables_filtering_when_serializing_frame( sentry_init, behaviour, expected_vars ): - sentry_init(_experiments={"data_collection": {"stack_frame_variables": behaviour}}) + sentry_init(data_collection={"stack_frame_variables": behaviour}) result = serialize_frame(_frame_with_locals()) @@ -637,9 +637,7 @@ def test_stack_frame_variables_filtering_when_serializing_frame( def test_stack_frame_variables_off_omits_vars(sentry_init): - sentry_init( - _experiments={"data_collection": {"stack_frame_variables": {"mode": "off"}}} - ) + sentry_init(data_collection={"stack_frame_variables": {"mode": "off"}}) result = serialize_frame(_frame_with_locals()) @@ -650,11 +648,7 @@ def test_stack_frame_variables_omits_vars_when_frame_has_no_locals(sentry_init): def _frame_without_locals(): return sys._getframe() - sentry_init( - _experiments={ - "data_collection": {"stack_frame_variables": {"mode": "denylist"}} - } - ) + sentry_init(data_collection={"stack_frame_variables": {"mode": "denylist"}}) result = serialize_frame(_frame_without_locals()) @@ -662,11 +656,7 @@ def _frame_without_locals(): def test_stack_frame_variables_filtering_uses_custom_repr(sentry_init): - sentry_init( - _experiments={ - "data_collection": {"stack_frame_variables": {"mode": "denylist"}} - } - ) + sentry_init(data_collection={"stack_frame_variables": {"mode": "denylist"}}) def custom_repr(value): return "CUSTOM" if value == "not sensitive" else None @@ -711,7 +701,7 @@ def test_data_collection_stack_frame_variables_overrides_include_local_variables ): sentry_init( include_local_variables=False, - _experiments={"data_collection": {"stack_frame_variables": True}}, + data_collection={"stack_frame_variables": True}, ) events = capture_events() @@ -733,10 +723,8 @@ def test_data_collection_stack_frame_variables_filtering_applies_to_captured_exc sentry_init, capture_events ): sentry_init( - _experiments={ - "data_collection": { - "stack_frame_variables": {"mode": "denylist", "terms": ["nickname"]} - } + data_collection={ + "stack_frame_variables": {"mode": "denylist", "terms": ["nickname"]} } ) events = capture_events() @@ -762,10 +750,8 @@ def raise_with_locals(): def test_serialize_frame_variables_serializer_failure(sentry_init): sentry_init( - _experiments={ - "data_collection": { - "stack_frame_variables": {"mode": "denylist", "terms": ["password"]} - } + data_collection={ + "stack_frame_variables": {"mode": "denylist", "terms": ["password"]} } ) @@ -1348,23 +1334,23 @@ def fake_getlines(filename): [ pytest.param({}, 5, id="no_data_collection-defaults_to_5"), pytest.param( - {"_experiments": {"data_collection": {}}}, + {"data_collection": {}}, 5, id="data_collection-spec_default_5", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": 3}}}, + {"data_collection": {"frame_context_lines": 3}}, 3, id="data_collection-frame_context_lines_3", ), pytest.param( - {"_experiments": {"data_collection": {"frame_context_lines": 0}}}, + {"data_collection": {"frame_context_lines": 0}}, 0, id="data_collection-frame_context_lines_0", ), pytest.param( { - "_experiments": {"data_collection": {}}, + "data_collection": {}, "include_source_context": False, }, 5, diff --git a/tests/tracing/test_decorator.py b/tests/tracing/test_decorator.py index 85703f2276..e315b6f1ca 100644 --- a/tests/tracing/test_decorator.py +++ b/tests/tracing/test_decorator.py @@ -879,10 +879,8 @@ def my_agent(*args, **kwargs): sentry_init( traces_sample_rate=1.0, stream_gen_ai_spans=stream_gen_ai_spans, - _experiments={ - "data_collection": { - "gen_ai": {"inputs": collect_inputs, "outputs": collect_outputs} - } + data_collection={ + "gen_ai": {"inputs": collect_inputs, "outputs": collect_outputs} }, )