From 7b042556fe23a4e8cbd7b13a873108331900e8d6 Mon Sep 17 00:00:00 2001 From: Colleen O'Rourke Date: Wed, 21 May 2025 14:53:58 -0700 Subject: [PATCH 1/2] chore(ACI): Update metric issue dual processing metrics --- src/sentry/incidents/subscription_processor.py | 2 +- src/sentry/workflow_engine/processors/workflow.py | 9 +++++---- tests/sentry/incidents/test_subscription_processor.py | 2 +- 3 files changed, 7 insertions(+), 6 deletions(-) diff --git a/src/sentry/incidents/subscription_processor.py b/src/sentry/incidents/subscription_processor.py index 1266d9abbe746b..27afe647a822d6 100644 --- a/src/sentry/incidents/subscription_processor.py +++ b/src/sentry/incidents/subscription_processor.py @@ -498,7 +498,7 @@ def process_update(self, subscription_update: QuerySubscriptionUpdate) -> None: "organizations:workflow-engine-metric-alert-dual-processing-logs", self.subscription.project.organization, ): - metrics.incr("dual_processing.alert_rules.fire") + metrics.incr("dual_processing.alert_rules.resolve") incident_trigger = self.trigger_resolve_threshold( trigger, aggregation_value ) diff --git a/src/sentry/workflow_engine/processors/workflow.py b/src/sentry/workflow_engine/processors/workflow.py index cf38ea63710e7d..61bc96a6121653 100644 --- a/src/sentry/workflow_engine/processors/workflow.py +++ b/src/sentry/workflow_engine/processors/workflow.py @@ -313,9 +313,10 @@ def process_workflows(event_data: WorkflowEventData) -> set[Workflow]: }, ) # in order to check if workflow engine is firing 1:1 with the old system, we must only count once rather than each action - metrics.incr( - "workflow_engine.process_workflows.fired_actions", - tags={"detector_type": detector.type}, - ) + if len(actions) > 0: + metrics.incr( + "workflow_engine.process_workflows.fired_actions", + tags={"detector_type": detector.type}, + ) return triggered_workflows diff --git a/tests/sentry/incidents/test_subscription_processor.py b/tests/sentry/incidents/test_subscription_processor.py index df4713a529c8b8..7abfeedb2098cd 100644 --- a/tests/sentry/incidents/test_subscription_processor.py +++ b/tests/sentry/incidents/test_subscription_processor.py @@ -1285,7 +1285,7 @@ def test_resolve_metrics(self, mock_metrics): tags={"detection_type": "static"}, ), call( - "dual_processing.alert_rules.fire", + "dual_processing.alert_rules.resolve", ), call("incidents.alert_rules.trigger", tags={"type": "resolve"}), ] From 7e9904d470e659d1e000d4db99cec8d3a944e078 Mon Sep 17 00:00:00 2001 From: Colleen O'Rourke Date: Wed, 21 May 2025 16:30:12 -0700 Subject: [PATCH 2/2] move test --- .../processors/test_workflow.py | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/tests/sentry/workflow_engine/processors/test_workflow.py b/tests/sentry/workflow_engine/processors/test_workflow.py index 5c6d20ae032e28..6cd1e93074729d 100644 --- a/tests/sentry/workflow_engine/processors/test_workflow.py +++ b/tests/sentry/workflow_engine/processors/test_workflow.py @@ -301,18 +301,6 @@ def test_metrics_triggered_actions(self, mock_incr): tags={"detector_type": self.error_detector.type}, ) - @with_feature("organizations:workflow-engine-process-workflows") - @with_feature("organizations:workflow-engine-metric-alert-dual-processing-logs") - @patch("sentry.utils.metrics.incr") - def test_metrics_issue_dual_processing_metrics(self, mock_incr): - process_workflows(self.event_data) - mock_incr.assert_any_call( - "workflow_engine.process_workflows.fired_actions", - tags={ - "detector_type": self.error_detector.type, - }, - ) - class TestEvaluateWorkflowTriggers(BaseWorkflowTest): def setUp(self): @@ -543,6 +531,18 @@ def setUp(self): ) self.event_data = WorkflowEventData(event=self.group_event) + @with_feature("organizations:workflow-engine-process-workflows") + @with_feature("organizations:workflow-engine-metric-alert-dual-processing-logs") + @patch("sentry.utils.metrics.incr") + def test_metrics_issue_dual_processing_metrics(self, mock_incr): + process_workflows(self.event_data) + mock_incr.assert_any_call( + "workflow_engine.process_workflows.fired_actions", + tags={ + "detector_type": self.detector.type, + }, + ) + def test_basic__no_filter(self): triggered_actions = evaluate_workflows_action_filters({self.workflow}, self.event_data) assert set(triggered_actions) == {self.action}