Skip to content

feat(workflow_engine): Only execute enabled Detectors #86652

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 2 commits into from
Mar 8, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion src/sentry/workflow_engine/processors/data_source.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,9 @@ def process_data_sources(
# Fetch all data sources and associated detectors for the given data packets
with sentry_sdk.start_span(op="workflow_engine.process_data_sources.fetch_data_sources"):
data_sources = DataSource.objects.filter(
source_id__in=data_packet_ids, type=query_type
source_id__in=data_packet_ids,
type=query_type,
detectors__enabled=True,
).prefetch_related(Prefetch("detectors"))

# Build a lookup dict for source_id to detectors
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -52,6 +52,14 @@ def test_multiple_data_packets(self):
(self.packet_two, [self.detector_two]),
]

def test_disabled_detector(self):
self.detector_one.enabled = False
self.detector_one.save()

assert process_data_sources(self.data_packets, "test") == [
(self.packet_two, [self.detector_two])
]

def test_multiple_detectors(self):
self.detector_three = self.create_detector(name="test_detector3")
self.detector_four = self.create_detector(name="test_detector4")
Expand Down
Loading