Skip to content

Commit ae8bc63

Browse files
authored
fix(uptime): log when we detect missed uptime checkins (#91733)
If a check result comes in that (according to schedule) is much later than when we expected our next check, record the number of missed checks in logs and datadog. If we somehow get an intervening check, we'll just drop it as per preceding logic.
1 parent bfb1cf8 commit ae8bc63

File tree

1 file changed

+29
-0
lines changed

1 file changed

+29
-0
lines changed

src/sentry/uptime/consumers/results_consumer.py

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,35 @@ def handle_result(self, subscription: UptimeSubscription | None, result: CheckRe
464464
)
465465
return
466466

467+
subscription_interval_ms = 1000 * subscription.interval_seconds
468+
num_intervals = (
469+
result["scheduled_check_time_ms"] - last_update_ms
470+
) / subscription_interval_ms
471+
472+
# If the scheduled check is two or more intervals since the last seen check, we can declare the
473+
# intervening checks missed.
474+
if last_update_raw is not None and num_intervals > 1:
475+
num_missed_checks = num_intervals - 1
476+
metrics.distribution(
477+
"uptime.result_processer.num_missing_check",
478+
num_missed_checks,
479+
tags=metric_tags,
480+
)
481+
logger.info(
482+
"uptime.result_processor.num_missing_check",
483+
extra={"num_missed_checks": num_missed_checks, **result},
484+
)
485+
if num_intervals != int(num_intervals):
486+
logger.info(
487+
"uptime.result_processor.invalid_check_interval",
488+
extra={
489+
"last_update_ms": last_update_ms,
490+
"current_update_ms": result["scheduled_check_time_ms"],
491+
"interval_ms": subscription_interval_ms,
492+
**result,
493+
},
494+
)
495+
467496
if features.has("organizations:uptime-detailed-logging", organization):
468497
logger.info("handle_result_for_project.after_dedupe", extra=result)
469498

0 commit comments

Comments
 (0)