Skip to content
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
2 changes: 0 additions & 2 deletions src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -393,8 +393,6 @@ def register_temporary_features(manager: FeatureManager) -> None:
manager.add("organizations:workflow-engine-metric-detector-limit", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enable seer activities to be evaluated in workflow engine
manager.add("organizations:workflow-engine-evaluate-seer-activities", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
# Route group status change activities through the workflow activity registry (replaces group_status_update_registry)
manager.add("organizations:workflow-engine-status-change-via-activity", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
# Enable our logs product (known internally as ourlogs) in UI and backend
manager.add("organizations:ourlogs-enabled", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=True)
# Enable our logs product to be ingested via Relay.
Expand Down
37 changes: 1 addition & 36 deletions src/sentry/issues/status_change_consumer.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

import logging
from collections import defaultdict
from collections.abc import Callable, Iterable, Mapping, Sequence
from collections.abc import Iterable, Mapping, Sequence
from typing import Any

import sentry_sdk
Expand All @@ -12,7 +12,6 @@
from sentry.issues.action_log import SYSTEM_ACTOR, ActionSource, action_context_scope
from sentry.issues.escalating.escalating import manage_issue_states
from sentry.issues.status_change_message import StatusChangeMessageData
from sentry.models.activity import Activity
from sentry.models.group import Group, GroupStatus
from sentry.models.grouphash import GroupHash
from sentry.models.groupinbox import (
Expand All @@ -26,7 +25,6 @@
from sentry.types.activity import ActivityType
from sentry.types.group import IGNORED_SUBSTATUS_CHOICES, GroupSubStatus
from sentry.utils import metrics
from sentry.utils.registry import Registry

logger = logging.getLogger(__name__)

Expand Down Expand Up @@ -151,35 +149,6 @@ def update_status(group: Group, status_change: StatusChangeMessageData) -> None:
f"Unsupported status: {status_change['new_status']} {status_change['new_substatus']}"
)

if activity_type is not None:
"""
If we have set created an activity, then we'll also notify any registered handlers
that the group status has changed.

This is used to trigger the `workflow_engine` processing status changes.
"""
latest_activity = (
Activity.objects.filter(group_id=group.id, type=activity_type.value)
.order_by("-datetime")
.first()
)
if latest_activity is not None:
metrics.incr(
"workflow_engine.issue_platform.status_change_handler",
amount=len(group_status_update_registry.registrations.keys()),
tags={"activity_type": activity_type.value},
sample_rate=1.0,
)
for handler in group_status_update_registry.registrations.values():
logger.info(
"group.status_change.activity_created.handler",
extra={
"group_id": group.id,
"activity_type": activity_type,
},
)
handler(group, status_change, latest_activity)


def get_group_from_fingerprint(project_id: int, fingerprint: Sequence[str]) -> Group | None:
results = bulk_get_groups_from_fingerprints([(project_id, fingerprint)])
Expand Down Expand Up @@ -307,7 +276,3 @@ def process_status_change_message(
update_status(group, status_change_data)

return group


GroupUpdateHandler = Callable[[Group, StatusChangeMessageData, Activity], None]
group_status_update_registry = Registry[GroupUpdateHandler](enable_reverse_lookup=False)
2 changes: 0 additions & 2 deletions src/sentry/workflow_engine/handlers/workflow/__init__.py
Original file line number Diff line number Diff line change
@@ -1,8 +1,6 @@
from .workflow_activity_handlers import activity_handler, seer_activity_handler
from .workflow_status_update_handler import workflow_status_update_handler

__all__ = [
"activity_handler",
"seer_activity_handler",
"workflow_status_update_handler",
]
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@
ActivityType.SEER_ITERATION_COMPLETED,
]

# Activity types handled by the generic activity_handler. This replaces the
# group_status_update_registry path (see workflow_status_update_handler) once the
# organizations:workflow-engine-status-change-via-activity flag is fully rolled out.
# Activity types handled by the generic activity_handler.
SUPPORTED_ACTIVITIES = [
ActivityType.SET_RESOLVED,
]

STATUS_CHANGE_VIA_ACTIVITY_FLAG = "organizations:workflow-engine-status-change-via-activity"


@workflow_activity_registry.register("seer_activity")
def seer_activity_handler(
Expand Down Expand Up @@ -127,12 +123,6 @@ def activity_handler(
if activity_type not in SUPPORTED_ACTIVITIES:
return

if not features.has(
STATUS_CHANGE_VIA_ACTIVITY_FLAG,
group.organization,
):
return

event_data = WorkflowEventData(event=activity, group=group)

try:
Expand Down

This file was deleted.

9 changes: 8 additions & 1 deletion tests/sentry/incidents/test_metric_issue_post_process.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,12 @@
from sentry.issues.issue_occurrence import IssueOccurrence
from sentry.issues.status_change_consumer import update_status
from sentry.issues.status_change_message import StatusChangeMessage
from sentry.models.group import Group
from sentry.models.group import Group, GroupStatus
from sentry.notifications.models.notificationaction import ActionTarget
from sentry.services import eventstore
from sentry.tasks.post_process import post_process_group
from sentry.types.activity import ActivityType
from sentry.types.group import GroupSubStatus
from sentry.workflow_engine.models import Detector
from sentry.workflow_engine.models.data_condition import Condition
from sentry.workflow_engine.types import DetectorPriorityLevel
Expand Down Expand Up @@ -202,6 +203,9 @@ def test_resolution_from_critical(self, mock_trigger: MagicMock) -> None:
evaluation_result = self.process_packet_and_return_result(data_packet)
assert isinstance(evaluation_result, StatusChangeMessage)
message = evaluation_result.to_dict()
# Packet processing already resolved the group; reset it so update_status creates a
# genuine SET_RESOLVED activity, which is what dispatches workflow processing.
group.update(status=GroupStatus.UNRESOLVED, substatus=GroupSubStatus.ONGOING)
# TODO: Actions don't trigger on resolution yet. Update this test when this functionality exists.
with patch("sentry.workflow_engine.tasks.workflows.metrics.incr") as mock_incr:
with self.tasks():
Expand Down Expand Up @@ -233,6 +237,9 @@ def test_resolution_from_warning(self, mock_trigger: MagicMock) -> None:
evaluation_result = self.process_packet_and_return_result(data_packet)
assert isinstance(evaluation_result, StatusChangeMessage)
message = evaluation_result.to_dict()
# Packet processing already resolved the group; reset it so update_status creates a
# genuine SET_RESOLVED activity, which is what dispatches workflow processing.
group.update(status=GroupStatus.UNRESOLVED, substatus=GroupSubStatus.ONGOING)
# TODO: Actions don't trigger on resolution yet. Update this test when this functionality exists.
with patch("sentry.workflow_engine.tasks.workflows.metrics.incr") as mock_incr:
with self.tasks():
Expand Down
Loading
Loading