Skip to content

Commit

Permalink
fix(perf-issues): Fix HTTP Overhead Detector (#79300)
Browse files Browse the repository at this point in the history
Fixes SENTRY-FOR-SENTRY-1WGT

Changes the detection code to first ensure that `request_start` is not
None before multiplying the value to convert it to ms

---------

Co-authored-by: Matt Quinn <[email protected]>
  • Loading branch information
0Calories and mjq authored Oct 17, 2024
1 parent 019bf33 commit 78948de
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,13 @@ def visit_span(self, span: Span) -> None:

url = span_data.get("url", "")
span_start = span.get("start_timestamp", 0) * 1000
request_start = span_data.get("http.request.request_start", 0) * 1000
request_start = span_data.get("http.request.request_start", 0)

if not url or not span_start or not request_start:
return

request_start *= 1000

if url.startswith("/"):
location = "/"
else:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -260,3 +260,23 @@ def test_detect_other_location(self):
evidence_display=[],
)
]

def test_none_request_start(self):
url = "https://example.com/api/endpoint/123"
event = _valid_http_overhead_event("/api/endpoint/123")

# Include an invalid span to ensure it's not processed
span = create_span(
"http.client",
desc=url,
duration=1000,
data={
"url": url,
"network.protocol.version": "1.1",
"http.request.request_start": None,
},
)

event["spans"] = [span]

assert self.find_problems(event) == []

0 comments on commit 78948de

Please sign in to comment.