Skip to content

Commit

Permalink
fix(n1-api-calls): Omit span URL subdomain from fingerprinting (getse…
Browse files Browse the repository at this point in the history
…ntry#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.
  • Loading branch information
gggritso authored and pull[bot] committed Feb 22, 2024
1 parent 5548f83 commit 968e67b
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 2 additions & 6 deletions src/sentry/utils/performance_issues/performance_detection.py
Original file line number Diff line number Diff line change
Expand Up @@ -864,12 +864,8 @@ def _maybe_store_problem(self):

def _fingerprint(self) -> str:
parameterized_first_url = self.parameterize_url(get_url_from_span(self.spans[0]))

parts = parameterized_first_url.split("?")
if len(parts) > 1:
[path, _query] = parts
else:
path = parts[0]
parsed_first_url = urlparse(parameterized_first_url)
path = parsed_first_url.path

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

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -179,14 +179,14 @@ def test_fingerprints_different_relative_url_separately(self):

assert problem1.fingerprint != problem2.fingerprint

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

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

assert problem1.fingerprint != problem2.fingerprint
assert problem1.fingerprint == problem2.fingerprint


@pytest.mark.parametrize(
Expand Down

0 comments on commit 968e67b

Please sign in to comment.