Skip to content

Commit 2717275

Browse files
yashikakhuranaYashika Khurana
andauthored
feat(nimbus): Should skip same day alert for unenrollments (#15284)
Because - If the enrollment just started and the job task ran just after that, then it may notifies the users false positive about enrollment monitoring, we should wait at least a day and then should notify on the next job task run This commit - Skips the alert and only sends the alert if its more than 1 day Fixes #15221 --------- Co-authored-by: Yashika Khurana <[email protected]>
1 parent 39fc5cc commit 2717275

3 files changed

Lines changed: 24 additions & 0 deletions

File tree

experimenter/experimenter/experiments/constants.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1173,6 +1173,8 @@ class FirefoxLabsGroups(models.TextChoices):
11731173

11741174
EXPOSURE_CLIENT_CUTOFF = 10
11751175

1176+
MONITORING_ALERT_MINIMUM_DAYS = 1
1177+
11761178

11771179
EXTERNAL_URLS = {
11781180
"SIGNOFF_QA": "https://experimenter.info/workflow/risk-mitigation#qa-sign-off",

experimenter/experimenter/slack/tasks.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
import logging
23
from datetime import timedelta
34

@@ -426,6 +427,11 @@ def _check_monitoring_alerts(experiment):
426427
if not experiment.monitoring_data:
427428
return
428429

430+
if experiment.start_date and (
431+
datetime.date.today() - experiment.start_date
432+
) < datetime.timedelta(days=NimbusConstants.MONITORING_ALERT_MINIMUM_DAYS):
433+
return
434+
429435
try:
430436
is_spike, rate = check_unenrollment_spike(experiment.monitoring_data)
431437
if is_spike:

experimenter/experimenter/slack/tests/test_tasks.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
import datetime
12
from datetime import timedelta
23
from unittest import mock
34

@@ -1039,6 +1040,21 @@ def test_skips_when_monitoring_data_is_none(self):
10391040

10401041
self.assertEqual(NimbusAlert.objects.filter(experiment=experiment).count(), 0)
10411042

1043+
def test_skips_when_experiment_started_less_than_minimum_days_ago(self):
1044+
experiment = NimbusExperimentFactory.create_with_lifecycle(
1045+
NimbusExperimentFactory.Lifecycles.LIVE_ENROLLING,
1046+
monitoring_data=_SPIKE_MONITORING_DATA,
1047+
start_date=datetime.date.today()
1048+
- datetime.timedelta(days=NimbusConstants.MONITORING_ALERT_MINIMUM_DAYS - 1),
1049+
)
1050+
with mock.patch(
1051+
"experimenter.slack.tasks.send_slack_notification"
1052+
) as mock_send_slack:
1053+
tasks._check_monitoring_alerts(experiment)
1054+
mock_send_slack.assert_not_called()
1055+
1056+
self.assertEqual(NimbusAlert.objects.filter(experiment=experiment).count(), 0)
1057+
10421058
def test_sends_unenrollment_spike_alert(self):
10431059
experiment = NimbusExperimentFactory.create_with_lifecycle(
10441060
NimbusExperimentFactory.Lifecycles.LIVE_ENROLLING,

0 commit comments

Comments
 (0)