Repository navigation
fix(monitor): count a heartbeat a few seconds early as the expected firing (closes #3564) - #3590
Merged
Merged
Conversation
…iring Closes #3564. `HeartbeatAdapter` treated a schedule as silent whenever its last heartbeat was before the most recent expected firing, with no tolerance. Timer hosts can fire slightly early (an Azure Functions `0 */5 * * * *` timer logged 03:59:59.999238Z for a 04:00:00Z firing, about 1.4% of heartbeats over a week), so healthy schedules got `silent-schedule` findings that persist for a whole period on daily or weekly schedules. A heartbeat now counts as the expected firing when it lands within `HEARTBEAT_EARLY_FIRING_TOLERANCE` (5 seconds) before it. The issue suggested one minute; 5 seconds covers the observed early firing while a missed firing on a one-minute or seconds-dialect schedule is still caught. Tests: - tests/test_heartbeat_early_firing.py — sub-millisecond and 5-second-early heartbeats are not silent; 6 seconds early and the previous firing's heartbeat still are. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Root cause
HeartbeatAdaptertreated a schedule as silent whenever its last heartbeat was before the most recent expected firing (observed >= expected, no tolerance). Timer hosts can fire slightly early — an Azure Functions0 */5 * * * *timer logged03:59:59.999238Zfor a04:00:00Zfiring, about 1.4% of heartbeats over a week — so healthy schedules gotsilent-schedulefindings that persist for a whole period on daily or weekly schedules.Fix
A heartbeat counts as the expected firing when it lands within
HEARTBEAT_EARLY_FIRING_TOLERANCE(5 seconds) before it.The issue suggested one minute. 5 seconds covers the observed early firing (sub-millisecond) with wide margin, while a missed firing on a one-minute or seconds-dialect schedule is still caught; a one-minute tolerance would mask a missed run on a
* * * * *schedule.Ingestion delay (the issue's related note) is not addressed here: it only matters when a run lands within seconds of a firing, and a tolerance on the comparison would not fix it anyway.
Tests
tests/test_heartbeat_early_firing.py— sub-millisecond and 5-second-early heartbeats are not silent; 6 seconds early and the previous firing's heartbeat still are. Fails on unchanged code.Verification
scripts/smoke-test.sh: full suite OK, smoke test OK.Closes #3564.
🤖 Generated with Claude Code