diff --git a/src/sentry/utils/performance_issues/detectors/large_payload_detector.py b/src/sentry/utils/performance_issues/detectors/large_payload_detector.py index 755e4c319b9bd9..a4c2dd37cbf319 100644 --- a/src/sentry/utils/performance_issues/detectors/large_payload_detector.py +++ b/src/sentry/utils/performance_issues/detectors/large_payload_detector.py @@ -54,6 +54,10 @@ def visit_span(self, span: Span) -> None: return payload_size_threshold = self.settings.get("payload_size_threshold") + + if isinstance(encoded_body_size, str): + encoded_body_size = int(encoded_body_size) + if encoded_body_size > payload_size_threshold: self._store_performance_problem(span) diff --git a/tests/sentry/utils/performance_issues/test_large_http_payload_detector.py b/tests/sentry/utils/performance_issues/test_large_http_payload_detector.py index 1da252e8a47ebb..02558f55624a47 100644 --- a/tests/sentry/utils/performance_issues/test_large_http_payload_detector.py +++ b/tests/sentry/utils/performance_issues/test_large_http_payload_detector.py @@ -42,7 +42,7 @@ def test_detects_large_http_payload_issue(self): "http.response_content_length": 50_000_000, "http.decoded_response_content_length": 50_000_000, }, - ) + ), ] event = create_event(spans) @@ -250,3 +250,39 @@ def test_does_not_trigger_detection_for_http_span_lower_than_100_ms_duration(sel ] event = create_event(spans) assert self.find_problems(event) == [] + + def test_handles_string_payload_size_threshold(self): + + spans = [ + create_span( + "http.client", + 1000, + "GET /api/0/organizations/endpoint1", + "hash2", + data={ + "http.response_transfer_size": "50_000_000", + "http.response_content_length": "50_000_000", + "http.decoded_response_content_length": "50_000_000", + }, + ), + ] + + event = create_event(spans) + assert self.find_problems(event) == [ + PerformanceProblem( + fingerprint="1-1015-5e5543895c0f1f12c2d468da8c7f2d9e4dca81dc", + op="http", + desc="GET /api/0/organizations/endpoint1", + type=PerformanceLargeHTTPPayloadGroupType, + parent_span_ids=None, + cause_span_ids=[], + offender_span_ids=["bbbbbbbbbbbbbbbb"], + evidence_data={ + "parent_span_ids": [], + "cause_span_ids": [], + "offender_span_ids": ["bbbbbbbbbbbbbbbb"], + "op": "http", + }, + evidence_display=[], + ) + ]