Browse Source

ref(perf-issues): Update Slow DB Span Issue fingerprinting (#43318)

Ash Anand 2 years ago
parent
commit
cde27e7933

+ 4 - 5
src/sentry/utils/performance_issues/performance_detection.py

@@ -535,11 +535,10 @@ class SlowSpanDetector(PerformanceDetector):
 
             hash = span.get("hash", "")
             type = DETECTOR_TYPE_TO_GROUP_TYPE[self.settings_key]
-            transaction_name = self._event.get("transaction")
 
             self.stored_problems[fingerprint] = PerformanceProblem(
                 type=type,
-                fingerprint=self._fingerprint(transaction_name, op, hash, type),
+                fingerprint=self._fingerprint(hash),
                 op=op,
                 desc=description,
                 cause_span_ids=[],
@@ -574,10 +573,10 @@ class SlowSpanDetector(PerformanceDetector):
 
         return True
 
-    def _fingerprint(self, transaction_name, span_op, hash, problem_class):
-        signature = (str(transaction_name) + str(span_op) + str(hash)).encode("utf-8")
+    def _fingerprint(self, hash):
+        signature = (str(hash)).encode("utf-8")
         full_fingerprint = hashlib.sha1(signature).hexdigest()
-        return f"1-{problem_class}-{full_fingerprint}"
+        return f"1-{GroupType.PERFORMANCE_SLOW_SPAN.value}-{full_fingerprint}"
 
 
 class RenderBlockingAssetSpanDetector(PerformanceDetector):

+ 8 - 8
tests/sentry/utils/performance_issues/test_slow_span_detector.py

@@ -40,7 +40,7 @@ class SlowSpanDetectorTest(unittest.TestCase):
         assert self.find_problems(slow_not_allowed_op_span_event) == []
         assert self.find_problems(slow_span_event) == [
             PerformanceProblem(
-                fingerprint="1-GroupType.PERFORMANCE_SLOW_SPAN-020e34d374ab4b5cd00a6a1b4f76f325209f7263",
+                fingerprint="1-1001-da39a3ee5e6b4b0d3255bfef95601890afd80709",
                 op="db",
                 desc="SELECT count() FROM table WHERE id = %s",
                 type=GroupType.PERFORMANCE_SLOW_SPAN,
@@ -63,12 +63,12 @@ class SlowSpanDetectorTest(unittest.TestCase):
         assert self.find_problems(http_span_event) == []
         assert self.find_problems(db_span_event) == [
             PerformanceProblem(
-                fingerprint="1-GroupType.PERFORMANCE_SLOW_SPAN-dff8b4c2cafa12af9b5a35f3b12f9f8c2d790170",
+                fingerprint="1-1001-da39a3ee5e6b4b0d3255bfef95601890afd80709",
                 op="db.query",
                 desc="SELECT count() FROM table WHERE id = %s",
                 type=GroupType.PERFORMANCE_SLOW_SPAN,
-                parent_span_ids=None,
-                cause_span_ids=None,
+                parent_span_ids=[],
+                cause_span_ids=[],
                 offender_span_ids=["bbbbbbbbbbbbbbbb"],
             )
         ]
@@ -78,7 +78,7 @@ class SlowSpanDetectorTest(unittest.TestCase):
 
         assert self.find_problems(n_plus_one_event) == [
             PerformanceProblem(
-                fingerprint="1-GroupType.PERFORMANCE_SLOW_SPAN-8dbbcc64ef67d2d9d390327411669ebe29b0ea45",
+                fingerprint="1-1001-d02c8b2fd92a2d72011671feda429fa8ce2ac00f",
                 op="db",
                 desc="\n                SELECT VERSION(),\n                       @@sql_mode,\n                       @@default_storage_engine,\n                       @@sql_auto_is_null,\n                       @@lower_case_table_names,\n                       CONVERT_TZ('2001-01-01 01:00:00', 'UTC', 'UTC') IS NOT NULL\n            ",
                 type=GroupType.PERFORMANCE_SLOW_SPAN,
@@ -99,12 +99,12 @@ class SlowSpanDetectorTest(unittest.TestCase):
         assert self.find_problems(slow_span_event_with_truncated_query) == []
         assert self.find_problems(slow_span_event) == [
             PerformanceProblem(
-                fingerprint="1-GroupType.PERFORMANCE_SLOW_SPAN-020e34d374ab4b5cd00a6a1b4f76f325209f7263",
+                fingerprint="1-1001-da39a3ee5e6b4b0d3255bfef95601890afd80709",
                 op="db",
                 desc="SELECT `product`.`id` FROM `products`",
                 type=GroupType.PERFORMANCE_SLOW_SPAN,
-                parent_span_ids=None,
-                cause_span_ids=None,
+                parent_span_ids=[],
+                cause_span_ids=[],
                 offender_span_ids=["bbbbbbbbbbbbbbbb"],
             )
         ]