Skip to content

Commit 968e67b

Browse files
gggritsopull[bot]
authored andcommitted
fix(n1-api-calls): Omit span URL subdomain from fingerprinting (getsentry#43706)
Closes PERF-1937. Sometimes we get spans with URLs like `"http://<client>.service.io/resource"` in them. The `<client>` is a hard-to-parameterize string of some kind. This causes a fingerprint explosion if different transactions are getting data from different clients. Omit the subdomain from fingerprinting (but leave detection alone). For fingerprinting, we actually _want_ to ignore this, and only fingerprint on the path. There's basically no scenario where an application would use the same path structure from different domains and it's _not_ an error.
1 parent 5548f83 commit 968e67b

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

src/sentry/utils/performance_issues/performance_detection.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -864,12 +864,8 @@ def _maybe_store_problem(self):
864864

865865
def _fingerprint(self) -> str:
866866
parameterized_first_url = self.parameterize_url(get_url_from_span(self.spans[0]))
867-
868-
parts = parameterized_first_url.split("?")
869-
if len(parts) > 1:
870-
[path, _query] = parts
871-
else:
872-
path = parts[0]
867+
parsed_first_url = urlparse(parameterized_first_url)
868+
path = parsed_first_url.path
873869

874870
fingerprint = hashlib.sha1(path.encode("utf8")).hexdigest()
875871

tests/sentry/utils/performance_issues/test_n_plus_one_api_calls_detector.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -179,14 +179,14 @@ def test_fingerprints_different_relative_url_separately(self):
179179

180180
assert problem1.fingerprint != problem2.fingerprint
181181

182-
def test_fingerprints_using_full_url_path(self):
182+
def test_ignores_hostname_for_fingerprinting(self):
183183
event1 = self.create_event(lambda i: f"GET http://service.io/clients/info?id={i}")
184184
[problem1] = self.find_problems(event1)
185185

186186
event2 = self.create_event(lambda i: f"GET /clients/info?id={i}")
187187
[problem2] = self.find_problems(event2)
188188

189-
assert problem1.fingerprint != problem2.fingerprint
189+
assert problem1.fingerprint == problem2.fingerprint
190190

191191

192192
@pytest.mark.parametrize(

0 commit comments

Comments
 (0)