Browse Source

ref(perf-issues): Remove unused long task detector (#42156)

Another vestige of a detector plan left behind to time itself. tl;dr
this one won't ship, it's being subsumed by a new generation of
detectors.
George Gritsouk 2 years ago
parent
commit
a5363ebe09

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

@@ -427,7 +427,6 @@ class Group(Model):
             (GroupType.PERFORMANCE_N_PLUS_ONE.value, _("N Plus One")),
             (GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES.value, _("N Plus One DB Queries")),
             (GroupType.PERFORMANCE_SLOW_SPAN.value, _("Slow Span")),
-            (GroupType.PERFORMANCE_LONG_TASK_SPANS.value, _("Long Task Span")),
             (
                 GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN.value,
                 _("Render Blocking Asset Span"),

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

@@ -6,7 +6,6 @@ class GroupType(Enum):
     ERROR = 1
     PERFORMANCE_N_PLUS_ONE = 1000
     PERFORMANCE_SLOW_SPAN = 1001
-    PERFORMANCE_LONG_TASK_SPANS = 1003
     PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN = 1004
     PERFORMANCE_DUPLICATE_SPANS = 1005
     PERFORMANCE_N_PLUS_ONE_DB_QUERIES = 1006
@@ -30,7 +29,6 @@ GROUP_TYPE_TO_CATEGORY = {
     GroupType.ERROR: GroupCategory.ERROR,
     GroupType.PERFORMANCE_N_PLUS_ONE: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_SLOW_SPAN: GroupCategory.PERFORMANCE,
-    GroupType.PERFORMANCE_LONG_TASK_SPANS: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_DUPLICATE_SPANS: GroupCategory.PERFORMANCE,
     GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: GroupCategory.PERFORMANCE,
@@ -44,7 +42,6 @@ GROUP_TYPE_TO_TEXT = {
     GroupType.ERROR: "Error",
     GroupType.PERFORMANCE_N_PLUS_ONE: "N+1",  # may be N+1 Spans, N+1 Web Requests
     GroupType.PERFORMANCE_SLOW_SPAN: "Slow Span",
-    GroupType.PERFORMANCE_LONG_TASK_SPANS: "Long Task Spans",
     GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN: "Render Blocking Asset Span",
     GroupType.PERFORMANCE_DUPLICATE_SPANS: "Duplicate Spans",
     GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES: "N+1 Query",

+ 0 - 44
src/sentry/utils/performance_issues/performance_detection.py

@@ -55,7 +55,6 @@ CONTAINS_PARAMETER_REGEX = re.compile(
 class DetectorType(Enum):
     SLOW_SPAN = "slow_span"
     DUPLICATE_SPANS = "duplicates"
-    LONG_TASK_SPANS = "long_task"
     RENDER_BLOCKING_ASSET_SPAN = "render_blocking_assets"
     N_PLUS_ONE_SPANS = "n_plus_one"
     N_PLUS_ONE_DB_QUERIES = "n_plus_one_db"
@@ -69,7 +68,6 @@ class DetectorType(Enum):
 DETECTOR_TYPE_TO_GROUP_TYPE = {
     DetectorType.SLOW_SPAN: GroupType.PERFORMANCE_SLOW_SPAN,
     DetectorType.DUPLICATE_SPANS: GroupType.PERFORMANCE_DUPLICATE_SPANS,
-    DetectorType.LONG_TASK_SPANS: GroupType.PERFORMANCE_LONG_TASK_SPANS,
     DetectorType.RENDER_BLOCKING_ASSET_SPAN: GroupType.PERFORMANCE_RENDER_BLOCKING_ASSET_SPAN,
     DetectorType.N_PLUS_ONE_SPANS: GroupType.PERFORMANCE_N_PLUS_ONE,
     DetectorType.N_PLUS_ONE_DB_QUERIES: GroupType.PERFORMANCE_N_PLUS_ONE_DB_QUERIES,
@@ -285,12 +283,6 @@ def get_detection_settings(project_id: Optional[str] = None) -> Dict[DetectorTyp
                 "allowed_span_ops": ["db"],
             },
         ],
-        DetectorType.LONG_TASK_SPANS: [
-            {
-                "cumulative_duration": 500.0,  # ms
-                "allowed_span_ops": ["ui.long-task", "ui.sentry.long-task"],
-            }
-        ],
         DetectorType.RENDER_BLOCKING_ASSET_SPAN: {
             "fcp_minimum_threshold": settings["render_blocking_fcp_min"],  # ms
             "fcp_maximum_threshold": settings["render_blocking_fcp_max"],  # ms
@@ -349,7 +341,6 @@ def _detect_performance_problems(data: Event, sdk_span: Any) -> List[Performance
         DetectorType.CONSECUTIVE_DB_OP: ConsecutiveDBSpanDetector(detection_settings, data),
         DetectorType.DUPLICATE_SPANS: DuplicateSpanDetector(detection_settings, data),
         DetectorType.SLOW_SPAN: SlowSpanDetector(detection_settings, data),
-        DetectorType.LONG_TASK_SPANS: LongTaskSpanDetector(detection_settings, data),
         DetectorType.RENDER_BLOCKING_ASSET_SPAN: RenderBlockingAssetSpanDetector(
             detection_settings, data
         ),
@@ -678,41 +669,6 @@ class SlowSpanDetector(PerformanceDetector):
             )
 
 
-class LongTaskSpanDetector(PerformanceDetector):
-    """
-    Checks for ui.long-task spans, where the cumulative duration of the spans exceeds our threshold
-    """
-
-    __slots__ = ("cumulative_duration", "spans_involved", "stored_problems")
-
-    settings_key = DetectorType.LONG_TASK_SPANS
-
-    def init(self):
-        self.cumulative_duration = timedelta(0)
-        self.spans_involved = []
-        self.stored_problems = {}
-
-    def visit_span(self, span: Span):
-        settings_for_span = self.settings_for_span(span)
-        if not settings_for_span:
-            return
-        op, span_id, op_prefix, span_duration, settings = settings_for_span
-        duration_threshold = settings.get("cumulative_duration")
-
-        fingerprint = fingerprint_span(span)
-        if not fingerprint:
-            return
-
-        span_duration = get_span_duration(span)
-        self.cumulative_duration += span_duration
-        self.spans_involved.append(span_id)
-
-        if self.cumulative_duration >= timedelta(milliseconds=duration_threshold):
-            self.stored_problems[fingerprint] = PerformanceSpanProblem(
-                span_id, op_prefix, self.spans_involved
-            )
-
-
 class RenderBlockingAssetSpanDetector(PerformanceDetector):
     __slots__ = ("stored_problems", "fcp", "transaction_start")
 

+ 0 - 64
tests/sentry/utils/performance_issues/test_performance_detection.py

@@ -378,70 +378,6 @@ class PerformanceDetectionTest(unittest.TestCase):
             ]
         )
 
-    def test_calls_detect_long_task(self):
-        tolerable_long_task_spans_event = create_event(
-            [create_span("ui.long-task", 50.0, "Long Task")] * 3, "a" * 16
-        )
-        long_task_span_event = create_event(
-            [create_span("ui.long-task", 550.0, "Long Task")], "a" * 16
-        )
-        multiple_long_task_span_event = create_event(
-            [create_span("ui.long-task", 50.0, "Long Task")] * 11, "c" * 16
-        )
-
-        sdk_span_mock = Mock()
-
-        _detect_performance_problems(tolerable_long_task_spans_event, sdk_span_mock)
-        assert sdk_span_mock.containing_transaction.set_tag.call_count == 0
-
-        _detect_performance_problems(long_task_span_event, sdk_span_mock)
-        assert sdk_span_mock.containing_transaction.set_tag.call_count == 4
-        sdk_span_mock.containing_transaction.set_tag.assert_has_calls(
-            [
-                call(
-                    "_pi_all_issue_count",
-                    1,
-                ),
-                call(
-                    "_pi_sdk_name",
-                    "sentry.python",
-                ),
-                call(
-                    "_pi_transaction",
-                    "aaaaaaaaaaaaaaaa",
-                ),
-                call(
-                    "_pi_long_task",
-                    "bbbbbbbbbbbbbbbb",
-                ),
-            ]
-        )
-
-        sdk_span_mock.reset_mock()
-
-        _detect_performance_problems(multiple_long_task_span_event, sdk_span_mock)
-        assert sdk_span_mock.containing_transaction.set_tag.call_count == 4
-        sdk_span_mock.containing_transaction.set_tag.assert_has_calls(
-            [
-                call(
-                    "_pi_all_issue_count",
-                    1,
-                ),
-                call(
-                    "_pi_sdk_name",
-                    "sentry.python",
-                ),
-                call(
-                    "_pi_transaction",
-                    "cccccccccccccccc",
-                ),
-                call(
-                    "_pi_long_task",
-                    "bbbbbbbbbbbbbbbb",
-                ),
-            ]
-        )
-
     def test_calls_detect_render_blocking_asset(self):
         render_blocking_asset_event = {
             "event_id": "a" * 16,