-
-
Notifications
You must be signed in to change notification settings - Fork 4.5k
ref(aci): remove passing in detector to action.trigger #103000
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
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -67,7 +67,6 @@ def build_trigger_action_task_params( | |
| @retry(timeouts=True, raise_on_no_retries=False, ignore_and_capture=Action.DoesNotExist) | ||
| def trigger_action( | ||
| action_id: int, | ||
| detector_id: int, | ||
| workflow_id: int, | ||
| event_id: str | None, | ||
| activity_id: int | None, | ||
|
|
@@ -76,8 +75,10 @@ def trigger_action( | |
| group_state: GroupState, | ||
| has_reappeared: bool, | ||
| has_escalated: bool, | ||
| detector_id: int | None = None, | ||
| ) -> None: | ||
| from sentry.notifications.notification_action.utils import should_fire_workflow_actions | ||
| from sentry.workflow_engine.processors.detector import get_detector_by_event | ||
|
|
||
| # XOR check to ensure exactly one of event_id or activity_id is provided | ||
| if (event_id is not None) == (activity_id is not None): | ||
|
|
@@ -88,19 +89,14 @@ def trigger_action( | |
| raise ValueError("Exactly one of event_id or activity_id must be provided") | ||
|
|
||
| action = Action.objects.annotate(workflow_id=Value(workflow_id)).get(id=action_id) | ||
| detector = Detector.objects.get(id=detector_id) | ||
|
|
||
| metrics.incr( | ||
| "workflow_engine.tasks.trigger_action_task_started", | ||
| tags={"action_type": action.type, "detector_type": detector.type}, | ||
| sample_rate=1.0, | ||
| ) | ||
|
|
||
| project_id = detector.project_id | ||
| # TODO: remove detector usage from this task | ||
| detector: Detector | None = None | ||
| if detector_id is not None: | ||
| detector = Detector.objects.get(id=detector_id) | ||
|
|
||
| if event_id is not None: | ||
| event_data = build_workflow_event_data_from_event( | ||
| project_id=project_id, | ||
| event_id=event_id, | ||
| group_id=group_id, | ||
| workflow_id=workflow_id, | ||
|
|
@@ -122,6 +118,15 @@ def trigger_action( | |
| ) | ||
| raise ValueError("Exactly one of event_id or activity_id must be provided") | ||
|
|
||
| if detector is None: | ||
| detector = get_detector_by_event(event_data) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Bug: Event type mismatch breaks activity processing.When
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. fire action shouldn't work anyway, so I think this is fine? Not sure of the status of activity notifications |
||
|
|
||
| metrics.incr( | ||
| "workflow_engine.tasks.trigger_action_task_started", | ||
| tags={"action_type": action.type, "detector_type": detector.type}, | ||
| sample_rate=1.0, | ||
| ) | ||
|
|
||
| should_trigger_actions = should_fire_workflow_actions( | ||
| detector.project.organization, event_data.group.type | ||
| ) | ||
|
|
@@ -130,7 +135,7 @@ def trigger_action( | |
| # Set up a timeout grouping context because we want to make sure any Sentry timeout reporting | ||
| # in this scope is grouped properly. | ||
| with timeout_grouping_context(action.type): | ||
| action.trigger(event_data, detector) | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 😍 |
||
| action.trigger(event_data) | ||
| else: | ||
| logger.info( | ||
| "workflow_engine.triggered_actions.dry-run", | ||
|
|
||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -93,14 +93,14 @@ def process_workflow_activity(activity_id: int, group_id: int, detector_id: int) | |
| on_silent=DataConditionGroup.DoesNotExist, | ||
| ) | ||
| def process_workflows_event( | ||
| project_id: int, | ||
| event_id: str, | ||
| group_id: int, | ||
| occurrence_id: str | None, | ||
| group_state: GroupState, | ||
| has_reappeared: bool, | ||
| has_escalated: bool, | ||
| start_timestamp_seconds: float | None = None, | ||
| project_id: int | None = None, | ||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. looks like we could omit this here now too 🎉
Member
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. in the next PR! |
||
| **kwargs: dict[str, Any], | ||
| ) -> None: | ||
| from sentry.workflow_engine.buffer.batch_client import DelayedWorkflowClient | ||
|
|
@@ -111,7 +111,6 @@ def process_workflows_event( | |
| with recorder.record(): | ||
| try: | ||
| event_data = build_workflow_event_data_from_event( | ||
| project_id=project_id, | ||
| event_id=event_id, | ||
| group_id=group_id, | ||
| occurrence_id=occurrence_id, | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.