Skip to content

ref(workflow_engine): Change the issue fingerprint to be prefixed with detector #92527

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 1 commit into from
May 30, 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
5 changes: 3 additions & 2 deletions src/sentry/workflow_engine/handlers/detector/stateful.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,15 +138,16 @@ def bulk_get_detector_state(
def build_key(
self, group_key: DetectorGroupKey = None, postfix: str | int | None = None
) -> str:
key = f"detector:{self.detector.id}"
group_postfix = f"{group_key if group_key is not None else ''}"

if postfix:
group_postfix = f"{group_postfix}:{postfix}"

if group_postfix:
return f"{self.detector.id}:{group_postfix}"
return f"{key}:{group_postfix}"

return f"{self.detector.id}"
return key

def commit_state_updates(self):
self._bulk_commit_detector_state()
Expand Down
9 changes: 6 additions & 3 deletions tests/sentry/workflow_engine/processors/test_detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -223,9 +223,12 @@ def build_handler(self, detector: Detector | None = None) -> MockDetectorStateHa
def test(self):
assert (
self.build_handler().state_manager.build_key("test", "dedupe_value")
== "123:test:dedupe_value"
== "detector:123:test:dedupe_value"
)
assert (
self.build_handler().state_manager.build_key("test", "name_1")
== "detector:123:test:name_1"
)
assert self.build_handler().state_manager.build_key("test", "name_1") == "123:test:name_1"

def test_different_dedupe_keys(self):
handler = self.build_handler()
Expand Down Expand Up @@ -477,7 +480,7 @@ def test_above_below_threshold(self):
group_key="val1",
is_triggered=False,
result=StatusChangeMessage(
fingerprint=[f"{handler.detector.id}:val1"],
fingerprint=[f"detector:{handler.detector.id}:val1"],
project_id=self.project.id,
new_status=1,
new_substatus=None,
Expand Down
Loading