-
-
Notifications
You must be signed in to change notification settings - Fork 4.2k
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
ref(aci): pass WorkflowJob into process_workflows (#82489)
- Loading branch information
Showing
15 changed files
with
136 additions
and
51 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,9 +1,12 @@ | ||
__all__ = [ | ||
"EventCreatedByDetectorConditionHandler", | ||
"EventSeenCountConditionHandler", | ||
"ReappearedEventConditionHandler", | ||
"RegressedEventConditionHandler", | ||
] | ||
|
||
from .group_event_handlers import ( | ||
EventCreatedByDetectorConditionHandler, | ||
EventSeenCountConditionHandler, | ||
) | ||
from .group_state_handlers import ReappearedEventConditionHandler, RegressedEventConditionHandler |
13 changes: 7 additions & 6 deletions
13
src/sentry/workflow_engine/handlers/condition/group_event_handlers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,23 +1,24 @@ | ||
from typing import Any | ||
|
||
from sentry.eventstore.models import GroupEvent | ||
from sentry.workflow_engine.models.data_condition import Condition | ||
from sentry.workflow_engine.registry import condition_handler_registry | ||
from sentry.workflow_engine.types import DataConditionHandler | ||
from sentry.workflow_engine.types import DataConditionHandler, WorkflowJob | ||
|
||
|
||
@condition_handler_registry.register(Condition.EVENT_CREATED_BY_DETECTOR) | ||
class EventCreatedByDetectorConditionHandler(DataConditionHandler[GroupEvent]): | ||
class EventCreatedByDetectorConditionHandler(DataConditionHandler[WorkflowJob]): | ||
@staticmethod | ||
def evaluate_value(event: GroupEvent, comparison: Any) -> bool: | ||
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool: | ||
event = job["event"] | ||
if event.occurrence is None or event.occurrence.evidence_data is None: | ||
return False | ||
|
||
return event.occurrence.evidence_data.get("detector_id", None) == comparison | ||
|
||
|
||
@condition_handler_registry.register(Condition.EVENT_SEEN_COUNT) | ||
class EventSeenCountConditionHandler(DataConditionHandler[GroupEvent]): | ||
class EventSeenCountConditionHandler(DataConditionHandler[WorkflowJob]): | ||
@staticmethod | ||
def evaluate_value(event: GroupEvent, comparison: Any) -> bool: | ||
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool: | ||
event = job["event"] | ||
return event.group.times_seen == comparison |
27 changes: 27 additions & 0 deletions
27
src/sentry/workflow_engine/handlers/condition/group_state_handlers.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
from typing import Any | ||
|
||
from sentry.workflow_engine.models.data_condition import Condition | ||
from sentry.workflow_engine.registry import condition_handler_registry | ||
from sentry.workflow_engine.types import DataConditionHandler, WorkflowJob | ||
|
||
|
||
@condition_handler_registry.register(Condition.REGRESSED_EVENT) | ||
class RegressedEventConditionHandler(DataConditionHandler[WorkflowJob]): | ||
@staticmethod | ||
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool: | ||
state = job.get("group_state", None) | ||
if state is None: | ||
return False | ||
|
||
return state["is_regression"] == comparison | ||
|
||
|
||
@condition_handler_registry.register(Condition.REAPPEARED_EVENT) | ||
class ReappearedEventConditionHandler(DataConditionHandler[WorkflowJob]): | ||
@staticmethod | ||
def evaluate_value(job: WorkflowJob, comparison: Any) -> bool: | ||
has_reappeared = job.get("has_reappeared", None) | ||
if has_reappeared is None: | ||
return False | ||
|
||
return has_reappeared == comparison |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.