Skip to content
Open
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: 1 addition & 1 deletion src/sentry/features/temporary.py
Original file line number Diff line number Diff line change
Expand Up @@ -514,7 +514,7 @@ def register_temporary_features(manager: FeatureManager) -> None:
# Enable logs to debug metric alert dual processing
manager.add("organizations:workflow-engine-metric-alert-dual-processing-logs", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
# Enable dual writing for metric alert issues (see: alerts create issues)
manager.add("organizations:workflow-engine-metric-alert-dual-write", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
manager.add("organizations:workflow-engine-metric-alert-dual-write", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False, default=True)
# Enable Processing for Metric Alerts in the workflow_engine
manager.add("organizations:workflow-engine-metric-alert-processing", OrganizationFeature, FeatureHandlerStrategy.FLAGPOLE, api_expose=False)
# Enable Creation of Metric Alerts that use the `group_by` field in the workflow_engine
Expand Down
16 changes: 6 additions & 10 deletions src/sentry/incidents/serializers/alert_rule.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,6 @@
from rest_framework import serializers
from urllib3.exceptions import MaxRetryError, TimeoutError

from sentry import features
from sentry.api.exceptions import BadRequest, RequestTimeout
from sentry.api.fields.actor import ActorField
from sentry.api.helpers.error_upsampling import are_any_projects_error_upsampled
Expand Down Expand Up @@ -298,15 +297,12 @@ def create(self, validated_data):

self._handle_triggers(alert_rule, triggers)

should_dual_write = features.has(
"organizations:workflow-engine-metric-alert-dual-write", alert_rule.organization
)
if should_dual_write:
try:
dual_write_alert_rule(alert_rule, user)
except Exception:
sentry_sdk.capture_exception()
raise BadRequest(message="Error when creating alert rule")
try:
dual_write_alert_rule(alert_rule, user)
except Exception:
sentry_sdk.capture_exception()
raise BadRequest(message="Error when creating alert rule")

return alert_rule

def _apply_error_upsampling_if_needed(self, validated_data):
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -825,7 +825,6 @@ def test_workflow_engine_serializer(self) -> None:

with (
self.feature("organizations:incidents"),
self.feature("organizations:workflow-engine-metric-alert-dual-write"),
self.feature("organizations:workflow-engine-rule-serializers"),
outbox_runner(),
):
Expand Down Expand Up @@ -996,7 +995,6 @@ def test_dual_delete_trigger(self, mock_dual_delete: MagicMock) -> None:
# we test the logic for this method elsewhere, so just test that it's correctly called
assert mock_dual_delete.call_count == 1

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_delete_trigger_dual_update_resolve(self) -> None:
"""
If there is no explicit resolve threshold on an alert rule, then we need to dual update the
Expand Down Expand Up @@ -1027,7 +1025,6 @@ def test_delete_trigger_dual_update_resolve(self) -> None:
assert len(resp.data["triggers"]) == 1
assert_dual_written_resolution_threshold_equals(alert_rule, new_threshold)

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_update_trigger_threshold_dual_update_resolve(self) -> None:
"""
If there is no explicit resolve threshold on an alert rule, then we need to dual update the
Expand Down Expand Up @@ -1066,7 +1063,6 @@ def test_update_trigger_threshold_dual_update_resolve(self) -> None:
)
assert_dual_written_resolution_threshold_equals(alert_rule, new_threshold)

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_update_trigger_threshold_dual_update_resolve_noop(self) -> None:
"""
If there is an explicit resolve threshold on an alert rule, then updating triggers should
Expand All @@ -1092,7 +1088,6 @@ def test_update_trigger_threshold_dual_update_resolve_noop(self) -> None:
# remains unchanged
assert_dual_written_resolution_threshold_equals(alert_rule, resolve_threshold)

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_remove_resolve_threshold_dual_update_resolve(self) -> None:
"""
If we set the remove the resolve threshold from an alert rule, then we need to update the
Expand All @@ -1118,7 +1113,6 @@ def test_remove_resolve_threshold_dual_update_resolve(self) -> None:
# resolve threshold changes to the warning threshold
assert_dual_written_resolution_threshold_equals(alert_rule, new_threshold)

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_dual_update_resolve_all_triggers_removed_and_recreated(self) -> None:
"""
If a PUT request is made via the API and the trigger IDs are not specified in the
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -384,7 +384,6 @@ def test_workflow_engine_serializer(self) -> None:
[
"organizations:incidents",
"organizations:performance-view",
"organizations:workflow-engine-metric-alert-dual-write",
"organizations:workflow-engine-rule-serializers",
]
),
Expand All @@ -398,7 +397,6 @@ def test_workflow_engine_serializer(self) -> None:
detector = Detector.objects.get(alertruledetector__alert_rule_id=int(resp.data.get("id")))
assert resp.data == serialize(detector, self.user, WorkflowEngineDetectorSerializer())

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_create_alert_rule_aci(self) -> None:
with (
outbox_runner(),
Expand Down
5 changes: 0 additions & 5 deletions tests/sentry/incidents/test_logic.py
Original file line number Diff line number Diff line change
Expand Up @@ -2200,7 +2200,6 @@ class EnableDisableAlertRuleTest(TestCase, BaseIncidentsTest):
def setUp(self) -> None:
self.alert_rule = self.create_alert_rule()

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_enable(self) -> None:
with self.tasks():
disable_alert_rule(self.alert_rule)
Expand All @@ -2215,7 +2214,6 @@ def test_enable(self) -> None:
for subscription in alert_rule.snuba_query.subscriptions.all():
assert subscription.status == QuerySubscription.Status.ACTIVE.value

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_disable(self) -> None:
with self.tasks():
disable_alert_rule(self.alert_rule)
Expand Down Expand Up @@ -2268,7 +2266,6 @@ def assert_detector_enabled_disabled(self, detector: Detector, enabled: bool = T
for qs in query_subscriptions:
assert qs.status == query_subscription_status

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_enable(self) -> None:
with self.tasks():
update_detector(detector=self.detector, enabled=False)
Expand All @@ -2280,14 +2277,12 @@ def test_enable(self) -> None:

self.assert_detector_enabled_disabled(detector=self.detector, enabled=True)

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_disable(self) -> None:
with self.tasks():
update_detector(detector=self.detector, enabled=False)

self.assert_detector_enabled_disabled(detector=self.detector, enabled=False)

@with_feature("organizations:workflow-engine-metric-alert-dual-write")
def test_multiple_data_sources_enable_disable(self) -> None:
with self.tasks():
self.snuba_query = create_snuba_query(
Expand Down