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
4 changes: 2 additions & 2 deletions src/sentry/monitors/models.py
Original file line number Diff line number Diff line change
Expand Up @@ -650,12 +650,12 @@ def get_occurrence_data(reason: str, **kwargs):
"subtitle": f"No check-in reported on {expected_time}.",
}
elif reason == MonitorFailure.DURATION:
timeout = kwargs.get("timeout", 30)
duration = kwargs.get("duration", 30)
return {
"group_type": MonitorCheckInTimeout,
"level": "error",
"reason": "duration",
"subtitle": f"Check-in exceeded maximum duration of {timeout} minutes.",
"subtitle": f"Check-in exceeded maximum duration of {duration} minutes.",
}

return {
Expand Down
12 changes: 8 additions & 4 deletions tests/sentry/monitors/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -394,7 +394,11 @@ def test_mark_failed_with_reason_issue_platform(self, mock_produce_occurrence_to
organization_id=self.organization.id,
project_id=self.project.id,
type=MonitorType.CRON_JOB,
config={"schedule": [1, "month"], "schedule_type": ScheduleType.INTERVAL},
config={
"schedule": [1, "month"],
"schedule_type": ScheduleType.INTERVAL,
"max_runtime": 10,
},
)
monitor_environment = MonitorEnvironment.objects.create(
monitor=monitor,
Expand All @@ -411,7 +415,7 @@ def test_mark_failed_with_reason_issue_platform(self, mock_produce_occurrence_to
assert monitor_environment.mark_failed(
last_checkin=last_checkin,
reason=MonitorFailure.DURATION,
occurrence_context={"duration": 30},
occurrence_context={"duration": monitor.config.get("max_runtime")},
)

assert len(mock_produce_occurrence_to_kafka.mock_calls) == 1
Expand All @@ -425,7 +429,7 @@ def test_mark_failed_with_reason_issue_platform(self, mock_produce_occurrence_to
"project_id": self.project.id,
"fingerprint": [hash_from_values(["monitor", str(monitor.guid), "duration"])],
"issue_title": f"Monitor failure: {monitor.name}",
"subtitle": "Check-in exceeded maximum duration of 30 minutes.",
"subtitle": "Check-in exceeded maximum duration of 10 minutes.",
"resource_id": None,
"evidence_data": {},
"evidence_display": [
Expand Down Expand Up @@ -454,7 +458,7 @@ def test_mark_failed_with_reason_issue_platform(self, mock_produce_occurrence_to
"monitor": {
"status": "active",
"type": "cron_job",
"config": {"schedule_type": 2, "schedule": [1, "month"]},
"config": {"schedule_type": 2, "schedule": [1, "month"], "max_runtime": 10},
"id": str(monitor.guid),
"name": monitor.name,
"slug": monitor.slug,
Expand Down