77from django .db .models import Q
88
99from sentry import features
10- from sentry .issues .grouptype import (
11- MonitorCheckInFailure ,
12- MonitorCheckInMissed ,
13- MonitorCheckInTimeout ,
14- )
10+ from sentry .issues .grouptype import MonitorIncidentType
1511from sentry .models .organization import Organization
16- from sentry .monitors .constants import SUBTITLE_DATETIME_FORMAT , TIMEOUT
1712from sentry .monitors .models import (
1813 CheckInStatus ,
1914 MonitorCheckIn ,
@@ -243,10 +238,8 @@ def create_issue_platform_occurrence(
243238 monitor_env = failed_checkin .monitor_environment
244239 current_timestamp = datetime .now (timezone .utc )
245240
246- occurrence_data = get_occurrence_data (failed_checkin )
247-
248241 # Get last successful check-in to show in evidence display
249- last_successful_checkin_timestamp = "None "
242+ last_successful_checkin_timestamp = "Never "
250243 last_successful_checkin = monitor_env .get_last_successful_checkin ()
251244 if last_successful_checkin :
252245 last_successful_checkin_timestamp = last_successful_checkin .date_added .isoformat ()
@@ -257,11 +250,11 @@ def create_issue_platform_occurrence(
257250 project_id = monitor_env .monitor .project_id ,
258251 event_id = uuid .uuid4 ().hex ,
259252 fingerprint = [incident .grouphash ],
260- type = occurrence_data [ "group_type" ] ,
253+ type = MonitorIncidentType ,
261254 issue_title = f"Monitor failure: { monitor_env .monitor .name } " ,
262- subtitle = occurrence_data [ "subtitle" ] ,
255+ subtitle = "Your monitor has reached its failure threshold." ,
263256 evidence_display = [
264- IssueEvidence (name = "Failure reason" , value = occurrence_data [ "reason" ] , important = True ),
257+ IssueEvidence (name = "Failure reason" , value = "incident" , important = True ),
265258 IssueEvidence (
266259 name = "Environment" , value = monitor_env .get_environment ().name , important = False
267260 ),
@@ -272,9 +265,9 @@ def create_issue_platform_occurrence(
272265 ),
273266 ],
274267 evidence_data = {},
275- culprit = occurrence_data [ "reason" ] ,
268+ culprit = "incident" ,
276269 detection_time = current_timestamp ,
277- level = occurrence_data [ "level" ] ,
270+ level = "error" ,
278271 assignee = monitor_env .monitor .owner_actor ,
279272 )
280273
@@ -324,36 +317,3 @@ def get_monitor_environment_context(monitor_environment: MonitorEnvironment):
324317 "status" : monitor_environment .get_status_display (),
325318 "type" : monitor_environment .monitor .get_type_display (),
326319 }
327-
328-
329- def get_occurrence_data (checkin : MonitorCheckIn ):
330- if checkin .status == CheckInStatus .MISSED :
331- expected_time = (
332- checkin .expected_time .astimezone (checkin .monitor .timezone ).strftime (
333- SUBTITLE_DATETIME_FORMAT
334- )
335- if checkin .expected_time
336- else "the expected time"
337- )
338- return {
339- "group_type" : MonitorCheckInMissed ,
340- "level" : "warning" ,
341- "reason" : "missed_checkin" ,
342- "subtitle" : f"No check-in reported on { expected_time } ." ,
343- }
344-
345- if checkin .status == CheckInStatus .TIMEOUT :
346- duration = (checkin .monitor .config or {}).get ("max_runtime" ) or TIMEOUT
347- return {
348- "group_type" : MonitorCheckInTimeout ,
349- "level" : "error" ,
350- "reason" : "duration" ,
351- "subtitle" : f"Check-in exceeded maximum duration of { duration } minutes." ,
352- }
353-
354- return {
355- "group_type" : MonitorCheckInFailure ,
356- "level" : "error" ,
357- "reason" : "error" ,
358- "subtitle" : "An error occurred during the latest check-in." ,
359- }
0 commit comments