diff --git a/sentry_sdk/integrations/dramatiq.py b/sentry_sdk/integrations/dramatiq.py index 2ac023bb63..615fb18668 100644 --- a/sentry_sdk/integrations/dramatiq.py +++ b/sentry_sdk/integrations/dramatiq.py @@ -15,7 +15,6 @@ AnnotatedValue, capture_internal_exceptions, event_from_exception, - has_data_collection_enabled, parse_version, ) @@ -226,13 +225,7 @@ def extract_into_event(self, event: "Event") -> None: request_info = contexts.setdefault("dramatiq", {}) request_info["type"] = "dramatiq" - attach_request_body = True - if has_data_collection_enabled(client.options): - attach_request_body = ( - "incoming_request" in client.options["data_collection"]["http_bodies"] - ) - - if attach_request_body: + if client.options["data_collection"]["queues"]: data: "Optional[Union[AnnotatedValue, Dict[str, Any]]]" = None if not request_body_within_bounds(client, self.content_length()): data = AnnotatedValue.removed_because_over_size_limit() diff --git a/tests/integrations/dramatiq/test_dramatiq.py b/tests/integrations/dramatiq/test_dramatiq.py index 31577cd621..64917dcf60 100644 --- a/tests/integrations/dramatiq/test_dramatiq.py +++ b/tests/integrations/dramatiq/test_dramatiq.py @@ -355,6 +355,7 @@ def dummy_actor(x, y): True, ], ) +@pytest.mark.parametrize("broker", [{"data_collection": {}}], indirect=True) def test_that_message_data_is_added_as_request( broker, worker, capture_events, fail_fast ): @@ -394,16 +395,21 @@ def dummy_actor(x, y): @pytest.mark.parametrize( "broker,expect_message_data", [ - pytest.param({}, True, id="data_collection_not_enabled"), + pytest.param({"data_collection": {}}, True, id="data_collection_default"), pytest.param( - {"data_collection": {"http_bodies": ["incoming_request"]}}, + {"data_collection": {"queues": True}}, True, - id="data_collection_http_bodies_incoming_request", + id="data_collection_queues_on", ), pytest.param( - {"data_collection": {"http_bodies": []}}, + {"data_collection": {"queues": False}}, False, - id="data_collection_http_bodies_empty", + id="data_collection_queues_off", + ), + pytest.param( + {"data_collection": {"queues": True, "http_bodies": []}}, + True, + id="data_collection_queues_independent_of_http_bodies", ), ], indirect=["broker"], @@ -433,7 +439,7 @@ def dummy_actor(x, y): @pytest.mark.parametrize( "broker", - [{"data_collection": {"http_bodies": []}}], + [{"data_collection": {"queues": False}}], indirect=True, ) def test_that_dramatiq_context_type_is_set_regardless_of_data_collection(