Skip to content

Commit 703c3f5

Browse files
authored
chore(aci milestone 3): move aggregation value helpers to incidents directory (#82103)
Move the helper methods out of the workflow engine directory so that we can keep everything clean.
1 parent b4f68c1 commit 703c3f5

File tree

3 files changed

+20
-15
lines changed

3 files changed

+20
-15
lines changed

Diff for: src/sentry/incidents/subscription_processor.py

+4-4
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,10 @@
4343
)
4444
from sentry.incidents.tasks import handle_trigger_action
4545
from sentry.incidents.utils.metric_issue_poc import create_or_update_metric_issue
46+
from sentry.incidents.utils.process_update_helpers import (
47+
get_aggregation_value_helper,
48+
get_crash_rate_alert_metrics_aggregation_value_helper,
49+
)
4650
from sentry.incidents.utils.types import QuerySubscriptionUpdate
4751
from sentry.models.project import Project
4852
from sentry.search.eap.utils import add_start_end_conditions
@@ -58,10 +62,6 @@
5862
from sentry.snuba.subscriptions import delete_snuba_subscription
5963
from sentry.utils import metrics, redis, snuba_rpc
6064
from sentry.utils.dates import to_datetime
61-
from sentry.workflow_engine.process_update_helpers import (
62-
get_aggregation_value_helper,
63-
get_crash_rate_alert_metrics_aggregation_value_helper,
64-
)
6565

6666
logger = logging.getLogger(__name__)
6767
REDIS_TTL = int(timedelta(days=7).total_seconds())

Diff for: src/sentry/workflow_engine/process_update_helpers.py renamed to src/sentry/incidents/utils/process_update_helpers.py

+5
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,11 @@
11
from sentry.incidents.utils.types import QuerySubscriptionUpdate
22
from sentry.utils import metrics
33

4+
"""
5+
We pull these methods out of the subscription processor to be used by the
6+
workflow engine data condition handlers.
7+
"""
8+
49
# NOTE (mifu67): this is set to None in the subscription processor code and doesn't
510
# seem to be used. Maybe we don't need the logic gated by it?
611
CRASH_RATE_ALERT_MINIMUM_THRESHOLD: int | None = None

Diff for: tests/sentry/incidents/test_subscription_processor.py

+11-11
Original file line numberDiff line numberDiff line change
@@ -3418,7 +3418,7 @@ def test_crash_rate_alert_for_sessions_with_triggers_lower_than_resolve_threshol
34183418
)
34193419
self.assert_active_incident(rule)
34203420

3421-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3421+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
34223422
def test_crash_rate_alert_for_sessions_with_no_sessions_data(self, helper_metrics):
34233423
"""
34243424
Test that ensures we skip the Crash Rate Alert processing if we have no sessions data
@@ -3441,8 +3441,8 @@ def test_crash_rate_alert_for_sessions_with_no_sessions_data(self, helper_metric
34413441
]
34423442
)
34433443

3444-
@patch("sentry.workflow_engine.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3445-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3444+
@patch("sentry.incidents.utils.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3445+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
34463446
def test_crash_rate_alert_when_session_count_is_lower_than_minimum_threshold(
34473447
self, helper_metrics
34483448
):
@@ -3470,7 +3470,7 @@ def test_crash_rate_alert_when_session_count_is_lower_than_minimum_threshold(
34703470
]
34713471
)
34723472

3473-
@patch("sentry.workflow_engine.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3473+
@patch("sentry.incidents.utils.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
34743474
def test_crash_rate_alert_when_session_count_is_higher_than_minimum_threshold(self):
34753475
rule = self.crash_rate_alert_rule
34763476
trigger = self.crash_rate_alert_critical_trigger
@@ -3489,7 +3489,7 @@ def test_crash_rate_alert_when_session_count_is_higher_than_minimum_threshold(se
34893489
self.assert_actions_fired_for_incident(incident, [action_critical], None)
34903490
self.assert_trigger_exists_with_status(incident, trigger, TriggerStatus.ACTIVE)
34913491

3492-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3492+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
34933493
def test_multiple_threshold_trigger_is_reset_when_no_sessions_data(self, helper_metrics):
34943494
rule = self.crash_rate_alert_rule
34953495
rule.update(threshold_period=2)
@@ -3528,8 +3528,8 @@ def test_multiple_threshold_trigger_is_reset_when_no_sessions_data(self, helper_
35283528
)
35293529
self.assert_trigger_counts(processor, trigger, 0, 0)
35303530

3531-
@patch("sentry.workflow_engine.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3532-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3531+
@patch("sentry.incidents.utils.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3532+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
35333533
def test_multiple_threshold_trigger_is_reset_when_count_is_lower_than_min_threshold(
35343534
self, helper_metrics
35353535
):
@@ -3571,7 +3571,7 @@ def test_multiple_threshold_trigger_is_reset_when_count_is_lower_than_min_thresh
35713571
)
35723572
self.assert_trigger_counts(processor, trigger, 0, 0)
35733573

3574-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3574+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
35753575
def test_multiple_threshold_resolve_is_reset_when_no_sessions_data(self, helper_metrics):
35763576
rule = self.crash_rate_alert_rule
35773577
trigger = self.crash_rate_alert_critical_trigger
@@ -3630,8 +3630,8 @@ def test_multiple_threshold_resolve_is_reset_when_no_sessions_data(self, helper_
36303630
self.assert_trigger_exists_with_status(incident, trigger, TriggerStatus.ACTIVE)
36313631
self.assert_action_handler_called_with_actions(incident, [])
36323632

3633-
@patch("sentry.workflow_engine.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3634-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3633+
@patch("sentry.incidents.utils.process_update_helpers.CRASH_RATE_ALERT_MINIMUM_THRESHOLD", 30)
3634+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
36353635
def test_multiple_threshold_resolve_is_reset_when_count_is_lower_than_min_threshold(
36363636
self, helper_metrics
36373637
):
@@ -3690,7 +3690,7 @@ def test_multiple_threshold_resolve_is_reset_when_count_is_lower_than_min_thresh
36903690
self.assert_trigger_exists_with_status(incident, trigger, TriggerStatus.ACTIVE)
36913691
self.assert_action_handler_called_with_actions(incident, [])
36923692

3693-
@patch("sentry.workflow_engine.process_update_helpers.metrics")
3693+
@patch("sentry.incidents.utils.process_update_helpers.metrics")
36943694
def test_ensure_case_when_no_metrics_index_not_found_is_handled_gracefully(
36953695
self, helper_metrics
36963696
):

0 commit comments

Comments
 (0)