diff --git a/src/sentry/tasks/post_process.py b/src/sentry/tasks/post_process.py index 74967c4d569a..99390b36efad 100644 --- a/src/sentry/tasks/post_process.py +++ b/src/sentry/tasks/post_process.py @@ -1356,7 +1356,10 @@ def detect_new_escalation(job: PostProcessJob): job. """ from sentry.issues.issue_velocity import get_latest_threshold + from sentry.models.activity import Activity + from sentry.models.grouphistory import GroupHistoryStatus, record_group_history from sentry.models.groupinbox import GroupInboxReason, add_group_to_inbox + from sentry.types.activity import ActivityType group = job["event"].group if not group or not features.has( @@ -1382,7 +1385,15 @@ def detect_new_escalation(job: PostProcessJob): if project_escalation_rate > 0 and group_hourly_event_rate > project_escalation_rate: job["has_escalated"] = True group.update(substatus=GroupSubStatus.ESCALATING) + + # TODO(snigdha): reuse manage_issue_states when we allow escalating from other statuses add_group_to_inbox(group, GroupInboxReason.ESCALATING) + record_group_history(group, GroupHistoryStatus.ESCALATING) + Activity.objects.create_group_activity( + group=group, + type=ActivityType.SET_ESCALATING, + data={"event_id": job["event"].event_id}, + ) except UnableToAcquireLock as error: extra["error"] = error logger.warning(