Skip to content

Commit e981f33

Browse files
authored
feat(workflow_engine): Only execute enabled Detectors (#86652)
1 parent 0d2c8ed commit e981f33

File tree

2 files changed

+11
-1
lines changed

2 files changed

+11
-1
lines changed

src/sentry/workflow_engine/processors/data_source.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,9 @@ def process_data_sources(
2121
# Fetch all data sources and associated detectors for the given data packets
2222
with sentry_sdk.start_span(op="workflow_engine.process_data_sources.fetch_data_sources"):
2323
data_sources = DataSource.objects.filter(
24-
source_id__in=data_packet_ids, type=query_type
24+
source_id__in=data_packet_ids,
25+
type=query_type,
26+
detectors__enabled=True,
2527
).prefetch_related(Prefetch("detectors"))
2628

2729
# Build a lookup dict for source_id to detectors

tests/sentry/workflow_engine/processors/test_data_sources.py

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -52,6 +52,14 @@ def test_multiple_data_packets(self):
5252
(self.packet_two, [self.detector_two]),
5353
]
5454

55+
def test_disabled_detector(self):
56+
self.detector_one.enabled = False
57+
self.detector_one.save()
58+
59+
assert process_data_sources(self.data_packets, "test") == [
60+
(self.packet_two, [self.detector_two])
61+
]
62+
5563
def test_multiple_detectors(self):
5664
self.detector_three = self.create_detector(name="test_detector3")
5765
self.detector_four = self.create_detector(name="test_detector4")

0 commit comments

Comments
 (0)