Browse Source

ref(perf-issues): Rename slow span issue to slow db query (#43432)

Ash Anand 2 years ago
parent
commit
c1eb2dff5b

+ 1 - 1
src/sentry/event_manager.py

@@ -166,7 +166,7 @@ PERFORMANCE_ISSUE_QUOTA = Quota(3600, 60, 5)
 DEFAULT_GROUPHASH_IGNORE_LIMIT = 3
 GROUPHASH_IGNORE_LIMIT_MAP = {
     GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: 3,
-    GroupType.PERFORMANCE_SLOW_SPAN: 100,
+    GroupType.PERFORMANCE_SLOW_DB_QUERY: 100,
 }
 
 

+ 1 - 1
src/sentry/models/group.py

@@ -436,7 +436,7 @@ class Group(Model):
         choices=(
             (GroupType.ERROR.value, _("Error")),
             (GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES.value, _("N Plus One DB Queries")),
-            (GroupType.PERFORMANCE_SLOW_SPAN.value, _("Slow Span")),
+            (GroupType.PERFORMANCE_SLOW_DB_QUERY.value, _("Slow DB Query")),
             (
                 GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN.value,
                 _("Render Blocking Asset Span"),

+ 4 - 4
src/sentry/options/defaults.py

@@ -573,10 +573,10 @@ register("performance.issues.n_plus_one_api_calls.problem-creation", default=0.0
 register("performance.issues.n_plus_one_api_calls.la-rollout", default=0.0)
 register("performance.issues.n_plus_one_api_calls.ea-rollout", default=0.0)
 register("performance.issues.n_plus_one_api_calls.ga-rollout", default=0.0)
-register("performance.issues.slow_span.problem-creation", default=0.0)
-register("performance.issues.slow_span.la-rollout", default=0.0)
-register("performance.issues.slow_span.ea-rollout", default=0.0)
-register("performance.issues.slow_span.ga-rollout", default=0.0)
+register("performance.issues.slow_db_query.problem-creation", default=0.0)
+register("performance.issues.slow_db_query.la-rollout", default=0.0)
+register("performance.issues.slow_db_query.ea-rollout", default=0.0)
+register("performance.issues.slow_db_query.ga-rollout", default=0.0)
 
 
 # System-wide options for default performance detection settings for any org opted into the performance-issues-ingest feature. Meant for rollout.

+ 3 - 3
src/sentry/types/issues.py

@@ -8,7 +8,7 @@ class GroupType(Enum):
     # DO NOT change the enum key string for any currently on detector or else
     # you will create duplicate issues for customers (until the fingerprints are fixed)
     ERROR = 1
-    PERFORMANCE_SLOW_SPAN = 1001
+    PERFORMANCE_SLOW_DB_QUERY = 1001
     PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN = 1004
     PERFORMANCE_N_PLUS_ONE_DB_QUERIES = 1006
     PERFORMANCE_CONSECUTIVE_DB_QUERIES = 1007
@@ -31,7 +31,7 @@ GROUP_CATEGORIES_CUSTOM_EMAIL = (GroupCategory.ERROR, GroupCategory.PERFORMANCE)
 GROUP_TYPE_TO_CATEGORY = {
     GroupType.ERROR: GroupCategory.ERROR,
     GroupType.PERFORMANCE_CONSECUTIVE_DB_QUERIES: GroupCategory.PERFORMANCE,
-    GroupType.PERFORMANCE_SLOW_SPAN: GroupCategory.PERFORMANCE,
+    GroupType.PERFORMANCE_SLOW_DB_QUERY: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_FILE_IO_MAIN_THREAD: GroupCategory.PERFORMANCE,
@@ -44,7 +44,7 @@ GROUP_TYPE_TO_CATEGORY = {
 GROUP_TYPE_TO_TEXT = {
     GroupType.ERROR: "Error",
     GroupType.PERFORMANCE_CONSECUTIVE_DB_QUERIES: "Consecutive DB Queries",
-    GroupType.PERFORMANCE_SLOW_SPAN: "Slow Span",
+    GroupType.PERFORMANCE_SLOW_DB_QUERY: "Slow DB Query",
     GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN: "Render Blocking Asset Span",
     GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: "N+1 Query",
     GroupType.PERFORMANCE_FILE_IO_MAIN_THREAD: "File IO on Main Thread",

+ 10 - 10
src/sentry/utils/performance_issues/performance_detection.py

@@ -52,7 +52,7 @@ CONTAINS_PARAMETER_REGEX = re.compile(
 
 
 class DetectorType(Enum):
-    SLOW_SPAN = "slow_span"
+    SLOW_DB_QUERY = "slow_db_query"
     RENDER_BLOCKING_ASSET_SPAN = "render_blocking_assets"
     N_PLUS_ONE_DB_QUERIES = "n_plus_one_db"
     N_PLUS_ONE_DB_QUERIES_EXTENDED = "n_plus_one_db_ext"
@@ -64,7 +64,7 @@ class DetectorType(Enum):
 
 
 DETECTOR_TYPE_TO_GROUP_TYPE = {
-    DetectorType.SLOW_SPAN: GroupType.PERFORMANCE_SLOW_SPAN,
+    DetectorType.SLOW_DB_QUERY: GroupType.PERFORMANCE_SLOW_DB_QUERY,
     DetectorType.RENDER_BLOCKING_ASSET_SPAN: GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN,
     DetectorType.N_PLUS_ONE_DB_QUERIES: GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
     DetectorType.N_PLUS_ONE_DB_QUERIES_EXTENDED: GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
@@ -83,7 +83,7 @@ DETECTOR_TYPE_ISSUE_CREATION_TO_SYSTEM_OPTION = {
     DetectorType.N_PLUS_ONE_API_CALLS: "performance.issues.n_plus_one_api_calls.problem-creation",
     DetectorType.FILE_IO_MAIN_THREAD: "performance.issues.file_io_main_thread.problem-creation",
     DetectorType.UNCOMPRESSED_ASSETS: "performance.issues.compressed_assets.problem-creation",
-    DetectorType.SLOW_SPAN: "performance.issues.slow_span.problem-creation",
+    DetectorType.SLOW_DB_QUERY: "performance.issues.slow_db_query.problem-creation",
 }
 
 
@@ -213,7 +213,7 @@ def get_detection_settings(project_id: Optional[int] = None) -> Dict[DetectorTyp
     )
 
     return {
-        DetectorType.SLOW_SPAN: [
+        DetectorType.SLOW_DB_QUERY: [
             {
                 "duration_threshold": 1000.0,  # ms
                 "allowed_span_ops": ["db"],
@@ -274,7 +274,7 @@ def _detect_performance_problems(
     detection_settings = get_detection_settings(project_id)
     detectors: List[PerformanceDetector] = [
         ConsecutiveDBSpanDetector(detection_settings, data),
-        SlowSpanDetector(detection_settings, data),
+        SlowDBQueryDetector(detection_settings, data),
         RenderBlockingAssetSpanDetector(detection_settings, data),
         NPlusOneDBSpanDetector(detection_settings, data),
         NPlusOneDBSpanDetectorExtended(detection_settings, data),
@@ -493,15 +493,15 @@ class PerformanceDetector(ABC):
         return True
 
 
-class SlowSpanDetector(PerformanceDetector):
+class SlowDBQueryDetector(PerformanceDetector):
     """
     Check for slow spans in a certain type of span.op (eg. slow db spans)
     """
 
     __slots__ = "stored_problems"
 
-    type: DetectorType = DetectorType.SLOW_SPAN
-    settings_key = DetectorType.SLOW_SPAN
+    type: DetectorType = DetectorType.SLOW_DB_QUERY
+    settings_key = DetectorType.SLOW_DB_QUERY
 
     def init(self):
         self.stored_problems = {}
@@ -518,7 +518,7 @@ class SlowSpanDetector(PerformanceDetector):
         if not fingerprint:
             return
 
-        if not SlowSpanDetector.is_span_eligible(span):
+        if not SlowDBQueryDetector.is_span_eligible(span):
             return
 
         description = span.get("description", None)
@@ -566,7 +566,7 @@ class SlowSpanDetector(PerformanceDetector):
     def _fingerprint(self, hash):
         signature = (str(hash)).encode("utf-8")
         full_fingerprint = hashlib.sha1(signature).hexdigest()
-        return f"1-{GroupType.PERFORMANCE_SLOW_SPAN.value}-{full_fingerprint}"
+        return f"1-{GroupType.PERFORMANCE_SLOW_DB_QUERY.value}-{full_fingerprint}"
 
 
 class RenderBlockingAssetSpanDetector(PerformanceDetector):

+ 2 - 2
tests/sentry/api/endpoints/test_group_details.py

@@ -522,7 +522,7 @@ class GroupUpdateTest(APITestCase):
 
     def test_discard_performance_issue(self):
         self.login_as(user=self.user)
-        group = self.create_group(type=GroupType.PERFORMANCE_SLOW_SPAN.value)
+        group = self.create_group(type=GroupType.PERFORMANCE_SLOW_DB_QUERY.value)
         GroupHash.objects.create(hash="x" * 32, project=group.project, group=group)
 
         url = f"/api/0/issues/{group.id}/"
@@ -585,7 +585,7 @@ class GroupDeleteTest(APITestCase):
         """Test that a performance issue cannot be deleted"""
         self.login_as(user=self.user)
 
-        group = self.create_group(type=GroupType.PERFORMANCE_SLOW_SPAN.value)
+        group = self.create_group(type=GroupType.PERFORMANCE_SLOW_DB_QUERY.value)
         GroupHash.objects.create(project=group.project, hash="x" * 32, group=group)
 
         url = f"/api/0/issues/{group.id}/"

+ 3 - 3
tests/sentry/api/test_issue_search.py

@@ -303,9 +303,9 @@ class ConvertTypeValueTest(TestCase):
         assert convert_type_value(
             ["performance_n_plus_one_db_queries"], [self.project], self.user, None
         ) == [1006]
-        assert convert_type_value(["performance_slow_span"], [self.project], self.user, None) == [
-            1001
-        ]
+        assert convert_type_value(
+            ["performance_slow_db_query"], [self.project], self.user, None
+        ) == [1001]
         assert convert_type_value(
             ["error", "performance_n_plus_one_db_queries"], [self.project], self.user, None
         ) == [1, 1006]

+ 2 - 2
tests/sentry/event_manager/test_event_manager.py

@@ -2437,7 +2437,7 @@ class EventManagerTest(TestCase, SnubaTestCase, EventManagerTestMixin):
 
     @override_options(
         {
-            "performance.issues.slow_span.problem-creation": 1.0,
+            "performance.issues.slow_db_query.problem-creation": 1.0,
             "performance_issue_creation_rate": 1.0,
         }
     )
@@ -2462,7 +2462,7 @@ class EventManagerTest(TestCase, SnubaTestCase, EventManagerTestMixin):
             last_event = attempt_to_generate_slow_db_issue()
 
             assert len(last_event.groups) == 1
-            assert last_event.groups[0].type == GroupType.PERFORMANCE_SLOW_SPAN.value
+            assert last_event.groups[0].type == GroupType.PERFORMANCE_SLOW_DB_QUERY.value
 
 
 class AutoAssociateCommitTest(TestCase, EventManagerTestMixin):

+ 1 - 1
tests/sentry/eventstore/snuba/test_backend.py

@@ -72,7 +72,7 @@ class SnubaEventStorageTest(TestCase, SnubaTestCase):
         self.transaction_event_2 = self.store_event(data=event_data_2, project_id=self.project2.id)
 
         event_data_3 = load_data(
-            "transaction", fingerprint=[f"{GroupType.PERFORMANCE_SLOW_SPAN.value}-group3"]
+            "transaction", fingerprint=[f"{GroupType.PERFORMANCE_SLOW_DB_QUERY.value}-group3"]
         )
         event_data_3["timestamp"] = iso_format(before_now(seconds=30))
         event_data_3["start_timestamp"] = iso_format(before_now(seconds=31))

+ 3 - 3
tests/sentry/utils/performance_issues/test_performance_detection.py

@@ -312,7 +312,7 @@ class EventPerformanceProblemTest(TestCase):
                 "test_2",
                 "db",
                 "something horrible happened",
-                GroupType.PERFORMANCE_SLOW_SPAN,
+                GroupType.PERFORMANCE_SLOW_DB_QUERY,
                 ["234"],
                 ["67", "87686", "786"],
                 ["4", "5", "6"],
@@ -333,7 +333,7 @@ class EventPerformanceProblemTest(TestCase):
                 "event_2_test_2",
                 "db",
                 "hello",
-                GroupType.PERFORMANCE_SLOW_SPAN,
+                GroupType.PERFORMANCE_SLOW_DB_QUERY,
                 ["234"],
                 ["fdgh", "gdhgf", "gdgh"],
                 ["gdf", "yu", "kjl"],
@@ -351,7 +351,7 @@ class EventPerformanceProblemTest(TestCase):
             "fake_fingerprint",
             "db",
             "hello",
-            GroupType.PERFORMANCE_SLOW_SPAN,
+            GroupType.PERFORMANCE_SLOW_DB_QUERY,
             ["234"],
             ["fdgh", "gdhgf", "gdgh"],
             ["gdf", "yu", "kjl"],

Some files were not shown because too many files changed in this diff