Skip to content

Commit e984842

Browse files
chore(aci): Remove MetricIssuePOC group type (#95685)
We're now creating groups with the real MetricIssue group type, so this should be safe to remove. We may want to eventually remove the registered group type but there are still issues in the db that reference it, so we'll need to clean that up first. --------- Co-authored-by: getsantry[bot] <66042841+getsantry[bot]@users.noreply.github.com>
1 parent e018642 commit e984842

File tree

13 files changed

+57
-504
lines changed

13 files changed

+57
-504
lines changed

src/sentry/incidents/grouptype.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,6 @@
88
from sentry.incidents.metric_issue_detector import MetricIssueDetectorValidator
99
from sentry.incidents.models.alert_rule import AlertRuleDetectionType, ComparisonDeltaChoices
1010
from sentry.incidents.utils.format_duration import format_duration_idiomatic
11-
from sentry.incidents.utils.metric_issue_poc import QUERY_AGGREGATION_DISPLAY
1211
from sentry.incidents.utils.types import QuerySubscriptionUpdate
1312
from sentry.integrations.metric_alerts import TEXT_COMPARISON_DELTA
1413
from sentry.issues.grouptype import GroupCategory, GroupType
@@ -28,6 +27,15 @@
2827
COMPARISON_DELTA_CHOICES: list[None | int] = [choice.value for choice in ComparisonDeltaChoices]
2928
COMPARISON_DELTA_CHOICES.append(None)
3029

30+
QUERY_AGGREGATION_DISPLAY = {
31+
"count()": "Number of events",
32+
"count_unique(tags[sentry:user])": "Number of users affected",
33+
"percentage(sessions_crashed, sessions)": "Crash free session rate",
34+
"percentage(users_crashed, users)": "Crash free user rate",
35+
"failure_rate()": "Failure rate",
36+
"apdex()": "Apdex score",
37+
}
38+
3139

3240
@dataclass
3341
class MetricIssueEvidenceData(EvidenceData[float]):

src/sentry/incidents/subscription_processor.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,6 @@
4040
TriggerStatus,
4141
)
4242
from sentry.incidents.tasks import handle_trigger_action
43-
from sentry.incidents.utils.metric_issue_poc import create_or_update_metric_issue
4443
from sentry.incidents.utils.process_update_helpers import (
4544
get_comparison_aggregation_value,
4645
get_crash_rate_alert_metrics_aggregation_value_helper,
@@ -779,12 +778,6 @@ def handle_trigger_actions(
779778
metric_value=metric_value,
780779
)
781780

782-
if features.has("organizations:metric-issue-poc", self.alert_rule.organization):
783-
create_or_update_metric_issue(
784-
incident=incident,
785-
metric_value=metric_value,
786-
)
787-
788781
def _schedule_trigger_action(
789782
self,
790783
action_id: int,

src/sentry/incidents/utils/metric_issue_poc.py

Lines changed: 0 additions & 184 deletions
This file was deleted.

src/sentry/issues/grouptype.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -675,9 +675,10 @@ class FeedbackGroup(GroupType):
675675

676676
@dataclass(frozen=True)
677677
class MetricIssuePOC(GroupType):
678+
# DEPRECATED, use metric_issue (8001) instead
678679
type_id = 8002
679680
slug = "metric_issue_poc"
680-
description = "Metric Issue POC"
681+
description = "DEPRECATED Metric Issue POC"
681682
category = GroupCategory.METRIC_ALERT.value
682683
category_v2 = GroupCategory.METRIC.value
683684
default_priority = PriorityLevel.HIGH

src/sentry/models/groupopenperiod.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import logging
2+
from dataclasses import dataclass
23
from datetime import datetime, timedelta
34
from typing import Any
45

@@ -20,6 +21,24 @@
2021
logger = logging.getLogger(__name__)
2122

2223

24+
@dataclass
25+
class OpenPeriod:
26+
start: datetime
27+
end: datetime | None
28+
duration: timedelta | None
29+
is_open: bool
30+
last_checked: datetime
31+
32+
def to_dict(self) -> dict[str, Any]:
33+
return {
34+
"start": self.start,
35+
"end": self.end,
36+
"duration": self.duration,
37+
"isOpen": self.is_open,
38+
"lastChecked": self.last_checked,
39+
}
40+
41+
2342
class TsTzRange(models.Func):
2443
function = "TSTZRANGE"
2544
output_field = DateTimeRangeField()
@@ -99,12 +118,12 @@ def reopen_open_period(self) -> None:
99118

100119

101120
def get_last_checked_for_open_period(group: Group) -> datetime:
121+
from sentry.incidents.grouptype import MetricIssue
102122
from sentry.incidents.models.alert_rule import AlertRule
103-
from sentry.issues.grouptype import MetricIssuePOC
104123

105124
event = group.get_latest_event()
106125
last_checked = group.last_seen
107-
if event and group.type == MetricIssuePOC.type_id:
126+
if event and group.type == MetricIssue.type_id:
108127
alert_rule_id = event.data.get("contexts", {}).get("metric_alert", {}).get("alert_rule_id")
109128
if alert_rule_id:
110129
try:
@@ -124,7 +143,6 @@ def get_open_periods_for_group(
124143
offset: int | None = None,
125144
limit: int | None = None,
126145
) -> list[Any]:
127-
from sentry.incidents.utils.metric_issue_poc import OpenPeriod
128146

129147
if not features.has("organizations:issue-open-periods", group.organization):
130148
return []

src/sentry/testutils/helpers/features.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -119,14 +119,14 @@ def batch_features_override(
119119
results = {}
120120
for project in projects:
121121
result_key = f"project:{project.id}"
122-
proj_results = {**feature_results, **default_feature_results[result_key]}
122+
proj_results = {**feature_results, **default_feature_results.get(result_key, {})}
123123
results[result_key] = {
124124
name: val for name, val in proj_results.items() if name.startswith("project")
125125
}
126126
return results
127127
elif organization:
128128
result_key = f"organization:{organization.id}"
129-
results_for_org = {**feature_results, **default_feature_results[result_key]}
129+
results_for_org = {**feature_results, **default_feature_results.get(result_key, {})}
130130
results_for_org = {
131131
name: resolve_feature_name_value_for_org(organization, val)
132132
for name, val in results_for_org.items()

0 commit comments

Comments
 (0)