@@ -228,13 +228,17 @@ def crons_task_success(sender, **kwargs):
228228
229229 monitor_config = headers .get ("sentry-monitor-config" , {})
230230
231- start_timestamp_s = float ( headers [ "sentry-monitor-start-timestamp-s" ] )
231+ start_timestamp_s = headers . get ( "sentry-monitor-start-timestamp-s" )
232232
233233 capture_checkin (
234234 monitor_slug = headers ["sentry-monitor-slug" ],
235235 monitor_config = monitor_config ,
236236 check_in_id = headers ["sentry-monitor-check-in-id" ],
237- duration = _now_seconds_since_epoch () - start_timestamp_s ,
237+ duration = (
238+ _now_seconds_since_epoch () - float (start_timestamp_s )
239+ if start_timestamp_s
240+ else None
241+ ),
238242 status = MonitorStatus .OK ,
239243 )
240244
@@ -249,13 +253,17 @@ def crons_task_failure(sender, **kwargs):
249253
250254 monitor_config = headers .get ("sentry-monitor-config" , {})
251255
252- start_timestamp_s = float ( headers [ "sentry-monitor-start-timestamp-s" ] )
256+ start_timestamp_s = headers . get ( "sentry-monitor-start-timestamp-s" )
253257
254258 capture_checkin (
255259 monitor_slug = headers ["sentry-monitor-slug" ],
256260 monitor_config = monitor_config ,
257261 check_in_id = headers ["sentry-monitor-check-in-id" ],
258- duration = _now_seconds_since_epoch () - start_timestamp_s ,
262+ duration = (
263+ _now_seconds_since_epoch () - float (start_timestamp_s )
264+ if start_timestamp_s
265+ else None
266+ ),
259267 status = MonitorStatus .ERROR ,
260268 )
261269
@@ -270,12 +278,16 @@ def crons_task_retry(sender, **kwargs):
270278
271279 monitor_config = headers .get ("sentry-monitor-config" , {})
272280
273- start_timestamp_s = float ( headers [ "sentry-monitor-start-timestamp-s" ] )
281+ start_timestamp_s = headers . get ( "sentry-monitor-start-timestamp-s" )
274282
275283 capture_checkin (
276284 monitor_slug = headers ["sentry-monitor-slug" ],
277285 monitor_config = monitor_config ,
278286 check_in_id = headers ["sentry-monitor-check-in-id" ],
279- duration = _now_seconds_since_epoch () - start_timestamp_s ,
287+ duration = (
288+ _now_seconds_since_epoch () - float (start_timestamp_s )
289+ if start_timestamp_s
290+ else None
291+ ),
280292 status = MonitorStatus .ERROR ,
281293 )
0 commit comments