Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
9 changes: 1 addition & 8 deletions sentry_sdk/integrations/dramatiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,6 @@
AnnotatedValue,
capture_internal_exceptions,
event_from_exception,
has_data_collection_enabled,
parse_version,
)

Expand Down Expand Up @@ -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()
Expand Down
18 changes: 12 additions & 6 deletions tests/integrations/dramatiq/test_dramatiq.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
):
Expand Down Expand Up @@ -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"],
Expand Down Expand Up @@ -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(
Expand Down
Loading