Browse Source

ref(first-event-severity): Don't catch errors in escalation job (#61316)

Isabella Enriquez 1 year ago
parent
commit
fe79f3830d

+ 2 - 2
src/sentry/issues/issue_velocity.py

@@ -139,10 +139,10 @@ def calculate_threshold(project: Project) -> Optional[float]:
 
     try:
         return result[0][THRESHOLD_QUANTILE["name"]]
-    except KeyError:
+    except Exception:
         logger.exception(
             "Unexpected shape for threshold query results",
-            extra={"project_id": project.id, "results_received": json.dumps(result)},
+            extra={"project_id": project.id, "result": json.dumps(result)},
         )
         return None
 

+ 0 - 7
src/sentry/tasks/post_process.py

@@ -1400,13 +1400,6 @@ def detect_new_escalation(job: PostProcessJob):
             "tasks.post_process.detect_new_escalation.unable_to_acquire_lock", extra=extra
         )
         return
-    except Exception as error:
-        metrics.incr("tasks.post_process.detect_new_escalation.failed")
-        extra["error"] = error
-        logger.exception(
-            "Unexpected error type while calling `get_latest_threshold()`", extra=extra
-        )
-        return
 
 
 GROUP_CATEGORY_POST_PROCESS_PIPELINE = {

+ 0 - 25
tests/sentry/tasks/test_post_process.py

@@ -2097,31 +2097,6 @@ class DetectNewEscalationTestMixin(BasePostProgressGroupMixin):
         group.refresh_from_db()
         assert group.substatus == GroupSubStatus.ESCALATING
 
-    @patch("sentry.utils.metrics.incr")
-    @patch(
-        "sentry.issues.issue_velocity.get_latest_threshold",
-        side_effect=Exception("mocked exception"),
-    )
-    @patch("sentry.tasks.post_process.run_post_process_job", side_effect=run_post_process_job)
-    def test_has_escalated_exception(
-        self, mock_run_post_process_job, mock_threshold, metric_incr_mock
-    ):
-        event = self.create_event(data={}, project_id=self.project.id)
-        group = event.group
-        group.update(first_seen=datetime.now() - timedelta(hours=1), times_seen=10000)
-        with self.feature("projects:first-event-severity-new-escalation"):
-            self.call_post_process_group(
-                is_new=True,
-                is_regression=False,
-                is_new_group_environment=True,
-                event=event,
-            )
-        metric_incr_mock.assert_any_call("tasks.post_process.detect_new_escalation.failed")
-        job = mock_run_post_process_job.call_args[0][0]
-        assert not job["has_escalated"]
-        group.refresh_from_db()
-        assert group.substatus == GroupSubStatus.NEW
-
     @patch("sentry.issues.issue_velocity.get_latest_threshold", return_value=0)
     @patch("sentry.tasks.post_process.run_post_process_job", side_effect=run_post_process_job)
     def test_zero_escalation_rate(self, mock_run_post_process_job, mock_threshold):