Skip to content

Commit

Permalink
chore(alerts): Remove activated alerts from notifications (#81283)
Browse files Browse the repository at this point in the history
Another chunk of #81095 that
removes the notification code for activated alerts.

This can't be merged until
#81218 is merged.
  • Loading branch information
ceorourke authored Jan 6, 2025
1 parent 54be212 commit 32b9853
Show file tree
Hide file tree
Showing 8 changed files with 0 additions and 177 deletions.
6 changes: 0 additions & 6 deletions src/sentry/incidents/action_handlers.py
Original file line number Diff line number Diff line change
Expand Up @@ -346,7 +346,6 @@ def generate_incident_trigger_email_context(
):
trigger = alert_rule_trigger
alert_rule = trigger.alert_rule
activation = incident.activation
assert alert_rule.snuba_query is not None
snuba_query = alert_rule.snuba_query
is_active = trigger_status == TriggerStatus.ACTIVE
Expand Down Expand Up @@ -445,9 +444,4 @@ def generate_incident_trigger_email_context(
"timezone": tz,
"snooze_alert": snooze_alert,
"snooze_alert_url": snooze_alert_url,
"monitor_type": alert_rule.monitor_type, # 0 = continuous, 1 = activated
"activator": (activation.activator if activation else ""),
"condition_type": (
activation.condition_type if activation else None
), # 0 = release creation, 1 = deploy creation
}
2 changes: 0 additions & 2 deletions src/sentry/integrations/metric_alerts.py
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,6 @@ def metric_alert_attachment_info(
if latest_incident:
last_triggered_date = latest_incident.date_started

# TODO: determine whether activated alert data is useful for integration messages
return {
"title": title,
"text": text,
Expand All @@ -240,7 +239,6 @@ def metric_alert_attachment_info(
"date_started": date_started,
"last_triggered_date": last_triggered_date,
"title_link": title_link,
"monitor_type": alert_rule.monitor_type, # 0 = continuous, 1 = activated
"activator": (activation.activator if activation else ""),
"condition_type": (
activation.condition_type if activation else None
Expand Down
1 change: 0 additions & 1 deletion src/sentry/templates/sentry/debug/mail/preview.html
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,6 @@
<option value="mail/generic-alert/">Generic Alert</option>
<option value="mail/digest/">Digest</option>
<option value="mail/incident-trigger">Metric Alert Trigger</option>
<option value="mail/activated-incident-trigger">Activated Metric Alert Trigger</option>
</optgroup>
<optgroup label="Account">
<option value="mail/confirm-email/">Confirm Email</option>
Expand Down
11 changes: 0 additions & 11 deletions src/sentry/templates/sentry/emails/incidents/trigger.html
Original file line number Diff line number Diff line change
Expand Up @@ -50,17 +50,6 @@ <h5 style="margin-bottom: 12px;">
<td width="25%">Environment</td>
<td>{{ environment }}</td>
</tr>
{% if monitor_type == 1 %}
<tr>
{% if condition_type == 0 %}
<td width="25%">New Release</td>
<td>{{activator}}</td>
{% elif condition_type == 1 %}
<td width="25%">New Deploy</td>
<td>{{activator}}</td>
{% endif %}
</tr>
{% endif %}
<tr>
<td width="25%">Threshold</td>
<td>
Expand Down
7 changes: 0 additions & 7 deletions src/sentry/templates/sentry/emails/incidents/trigger.txt
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,6 @@ controls are enabled. For more details about this alert alert, view on Sentry:
Alert: {{ link }}
Status: {{ status }}
Project: {{ project_slug }}
{% if monitor_type == 1 %}
{% if condition_type == 0 %}
New Release: {{activator}}
{% elif condition_type == 1 %}
New Deploy: {{activator}}
{% endif %}
{% endif %}
Metric: {{ aggregate }}
Environment: {{ environment }}
Threshold: {{ threshold_prefix_string }} {{ threshold }}
Expand Down
7 changes: 0 additions & 7 deletions src/sentry/web/debug_urls.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,9 +22,6 @@
from sentry.web.frontend.debug.debug_feedback_issue import DebugFeedbackIssueEmailView
from sentry.web.frontend.debug.debug_generic_issue import DebugGenericIssueEmailView
from sentry.web.frontend.debug.debug_incident_trigger_email import DebugIncidentTriggerEmailView
from sentry.web.frontend.debug.debug_incident_trigger_email_activated_alert import (
DebugIncidentActivatedAlertTriggerEmailView,
)
from sentry.web.frontend.debug.debug_invalid_identity_email import DebugInvalidIdentityEmailView
from sentry.web.frontend.debug.debug_mfa_added_email import DebugMfaAddedEmailView
from sentry.web.frontend.debug.debug_mfa_removed_email import DebugMfaRemovedEmailView
Expand Down Expand Up @@ -148,10 +145,6 @@
r"^debug/mail/sso-unlinked/no-password/$", DebugSsoUnlinkedNoPasswordEmailView.as_view()
),
re_path(r"^debug/mail/incident-trigger/$", DebugIncidentTriggerEmailView.as_view()),
re_path(
r"^debug/mail/activated-incident-trigger/$",
DebugIncidentActivatedAlertTriggerEmailView.as_view(),
),
re_path(r"^debug/mail/setup-2fa/$", DebugSetup2faEmailView.as_view()),
re_path(r"^debug/embed/error-page/$", DebugErrorPageEmbedView.as_view()),
re_path(r"^debug/trigger-error/$", DebugTriggerErrorView.as_view()),
Expand Down

This file was deleted.

66 changes: 0 additions & 66 deletions tests/sentry/incidents/action_handlers/test_email.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,14 +18,12 @@
from sentry.incidents.logic import CRITICAL_TRIGGER_LABEL, WARNING_TRIGGER_LABEL
from sentry.incidents.models.alert_rule import (
AlertRuleDetectionType,
AlertRuleMonitorTypeInt,
AlertRuleSeasonality,
AlertRuleSensitivity,
AlertRuleThresholdType,
AlertRuleTriggerAction,
)
from sentry.incidents.models.incident import INCIDENT_STATUS, IncidentStatus, TriggerStatus
from sentry.incidents.utils.types import AlertRuleActivationConditionType
from sentry.notifications.models.notificationsettingoption import NotificationSettingOption
from sentry.seer.anomaly_detection.types import StoreDataResponse
from sentry.sentry_metrics import indexer
Expand Down Expand Up @@ -278,67 +276,6 @@ def test_simple(self):
"timezone": settings.SENTRY_DEFAULT_TIME_ZONE,
"snooze_alert": True,
"snooze_alert_url": alert_link + "&mute=1",
"monitor_type": 0,
"activator": "",
"condition_type": None,
}
assert expected == generate_incident_trigger_email_context(
self.project,
incident,
action.alert_rule_trigger,
trigger_status,
IncidentStatus(incident.status),
)

def test_with_activated_alert(self):
trigger_status = TriggerStatus.ACTIVE
alert_rule = self.create_alert_rule(monitor_type=AlertRuleMonitorTypeInt.ACTIVATED)
alert_rule.subscribe_projects(
projects=[self.project],
monitor_type=AlertRuleMonitorTypeInt.ACTIVATED,
activation_condition=AlertRuleActivationConditionType.DEPLOY_CREATION,
activator="testing",
)
activations = alert_rule.activations.all()
incident = self.create_incident(alert_rule=alert_rule, activation=activations[0])
alert_rule_trigger = self.create_alert_rule_trigger(alert_rule=alert_rule)
action = self.create_alert_rule_trigger_action(
alert_rule_trigger=alert_rule_trigger, triggered_for_incident=incident
)
aggregate = action.alert_rule_trigger.alert_rule.snuba_query.aggregate
alert_link = self.organization.absolute_url(
reverse(
"sentry-metric-alert",
kwargs={
"organization_slug": incident.organization.slug,
"incident_id": incident.identifier,
},
),
query="referrer=metric_alert_email",
)
expected = {
"link": alert_link,
"incident_name": incident.title,
"aggregate": aggregate,
"query": action.alert_rule_trigger.alert_rule.snuba_query.query,
"threshold": action.alert_rule_trigger.alert_threshold,
"status": INCIDENT_STATUS[IncidentStatus(incident.status)],
"status_key": INCIDENT_STATUS[IncidentStatus(incident.status)].lower(),
"environment": "All",
"is_critical": False,
"is_warning": False,
"threshold_prefix_string": ">",
"time_window": "10 minutes",
"triggered_at": timezone.now(),
"project_slug": self.project.slug,
"unsubscribe_link": None,
"chart_url": None,
"timezone": settings.SENTRY_DEFAULT_TIME_ZONE,
"snooze_alert": True,
"snooze_alert_url": alert_link + "&mute=1",
"monitor_type": AlertRuleMonitorTypeInt.ACTIVATED,
"activator": "testing",
"condition_type": AlertRuleActivationConditionType.DEPLOY_CREATION.value,
}
assert expected == generate_incident_trigger_email_context(
self.project,
Expand Down Expand Up @@ -402,9 +339,6 @@ def test_dynamic_alert(self, mock_seer_request):
"timezone": settings.SENTRY_DEFAULT_TIME_ZONE,
"snooze_alert": True,
"snooze_alert_url": alert_link + "&mute=1",
"monitor_type": 0,
"activator": "",
"condition_type": None,
}
assert expected == generate_incident_trigger_email_context(
self.project,
Expand Down

0 comments on commit 32b9853

Please sign in to comment.