Skip to content
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

ref(workflow_engine): Remove DetectorType #82111

Merged
merged 1 commit into from
Dec 13, 2024
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
9 changes: 7 additions & 2 deletions src/sentry/workflow_engine/models/detector.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,8 +55,7 @@ class Detector(DefaultFieldsModel, OwnerModel, JSONConfigBase):
on_delete=models.SET_NULL,
)

# The type of detector that is being used, this is used to determine the class
# to load for the detector
# maps to registry (sentry.issues.grouptype.registry) entries for GroupType.slug in sentry.issues.grouptype.GroupType
type = models.CharField(max_length=200)

# The user that created the detector
Expand Down Expand Up @@ -106,8 +105,14 @@ def get_audit_log_data(self) -> dict[str, Any]:

@receiver(pre_save, sender=Detector)
def enforce_config_schema(sender, instance: Detector, **kwargs):
"""
Ensures the detector type is valid in the grouptype registry.
This needs to be a signal because the grouptype registry's entries are not available at import time.
"""
group_type = instance.group_type

if not group_type:
raise ValueError(f"No group type found with type {instance.type}")

config_schema = group_type.detector_config_schema
instance.validate_config(config_schema)
7 changes: 1 addition & 6 deletions src/sentry/workflow_engine/types.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from __future__ import annotations

from enum import IntEnum, StrEnum
from enum import IntEnum
from typing import TYPE_CHECKING, Any, Generic, TypeVar

from sentry.types.group import PriorityLevel
Expand Down Expand Up @@ -44,8 +44,3 @@ class DataConditionHandler(Generic[T]):
@staticmethod
def evaluate_value(value: T, comparison: Any, condition: str) -> DataConditionResult:
raise NotImplementedError


class DetectorType(StrEnum):
ERROR = "ErrorDetector"
METRIC_ALERT_FIRE = "metric_alert_fire"
Loading