Skip to content

Commit 8b6fffc

Browse files
committed
update the task after changing the base branch
1 parent 9947ad0 commit 8b6fffc

File tree

1 file changed

+19
-6
lines changed

1 file changed

+19
-6
lines changed

src/sentry/workflow_engine/tasks.py

Lines changed: 19 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,17 @@
1-
from sentry.models.activity import Activity, activity_creation_registry
1+
from typing import TYPE_CHECKING
2+
3+
from sentry.issues.status_change_consumer import group_status_update_registry
24
from sentry.silo.base import SiloMode
35
from sentry.tasks.base import instrumented_task
46
from sentry.taskworker import config, namespaces, retry
57
from sentry.utils import metrics
68

9+
if TYPE_CHECKING:
10+
from sentry.issues.status_change_message import StatusChangeMessageData
11+
from sentry.models.activity import Activity
12+
from sentry.models.group import Group
13+
from sentry.workflow_engine.models import Detector
14+
715

816
@instrumented_task(
917
name="sentry.workflow_engine.processors.process_workflow_task",
@@ -22,9 +30,9 @@
2230
),
2331
),
2432
)
25-
def process_workflow_task(activity_id: int) -> None:
33+
def process_workflow_task(activity_id: Activity.id, detector_id: Detector.id) -> None:
2634
"""
27-
Process a workflow task identified by the given activity ID.
35+
Process a workflow task identified by the given Activity ID and Detector ID.
2836
2937
This task will retry up to 3 times with a delay of 5 seconds between attempts.
3038
It has a soft time limit of 50 seconds and a hard time limit of 60 seconds.
@@ -38,14 +46,18 @@ def process_workflow_task(activity_id: int) -> None:
3846
pass
3947

4048

41-
@activity_creation_registry.register("workflow_status_update")
42-
def workflow_status_update_handler(activity: Activity, detector_id: int | None) -> None:
49+
@group_status_update_registry.register("workflow_status_update")
50+
def workflow_status_update_handler(
51+
group: Group, status_change_message: StatusChangeMessageData, activity: Activity
52+
) -> None:
4353
"""
4454
Hook the process_workflow_task into the activity creation registry.
4555
4656
Since this handler is called in process for the activity, we want
4757
to queue a task to process workflows asynchronously.
4858
"""
59+
detector_id = status_change_message.get("detector_id")
60+
4961
if detector_id is None:
5062
# We should not hit this case, it's should only occur if there is a bug
5163
# passing it from the workflow_engine to the issue platform.
@@ -56,4 +68,5 @@ def workflow_status_update_handler(activity: Activity, detector_id: int | None)
5668
metrics.incr(
5769
"workflow_engine.process_workflow.activity_update", tags={"activity_type": activity.type}
5870
)
59-
# process_workflow_task.delay(activity.id)
71+
# TODO - should this also set the group id so we can set it on WorkflowEventData at the top level? :thinking:
72+
# process_workflow_task.delay(activity.id, detector_id)

0 commit comments

Comments
 (0)