Add HTTP-based cron monitoring support#597
Merged
Merged
Conversation
Report the lifecycle of each scheduled backup run to an HTTP-based cron monitoring service (such as Sentry Crons or healthchecks.io) via simple HTTP GET requests. A new top-level `monitor` config key accepts an optional URL for each of the `start`, `success`, and `failure` states. The relevant URL is fetched when a run starts and when it completes; a run is reported as a failure if any policy produced one or more errors and a success otherwise. Reporting is best-effort, so an unreachable monitor only logs a warning and never affects the backup itself. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tzz3yuCYDQ2ghxW81e6FMS
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #597 +/- ##
==========================================
+ Coverage 70.87% 72.74% +1.87%
==========================================
Files 28 29 +1
Lines 1971 2077 +106
==========================================
+ Hits 1397 1511 +114
+ Misses 574 566 -8 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Rename the top-level `monitor` configuration key to `ping`, along with the supporting `MonitorConfig`/`Monitor` types (now `PingConfig`/`Pinger`) and the `monitor` module (now `ping`), so the configuration reads more naturally. Also add a unit test covering the backup run's error tracking, which drives the decision of whether a run is reported to the cron monitor as a success or a failure. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com> Claude-Session: https://claude.ai/code/session_01Tzz3yuCYDQ2ghxW81e6FMS
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.
Summary
Adds support for reporting the lifecycle of each scheduled backup run to an HTTP-based cron monitoring service (such as Sentry Cron Monitors or healthchecks.io), as requested.
The application makes a simple HTTP
GETrequest to a configured endpoint whenever a scheduled run starts and again when it completes — reporting success if every policy ran cleanly and failure if any policy produced one or more errors.Configuration
A new top-level
pingkey accepts an optional URL for each state. Any state you leave out is simply not reported:Allowing a separate URL per state keeps the implementation to plain
GETrequests while supporting both query-parameter-based services (Sentry:?status=...) and path-suffix-based services (healthchecks.io:/start,/fail).Behaviour notes
SIGINT, neithersuccessnorfailureis reported (the monitor will naturally observe a missed check-in).failurewhen any policy reports one or more errors, tracked via the pairing handler's error count.Implementation
src/ping.rsmodule withPingConfig(deserialized from thepingkey) and aPingerthat issues theGETrequests.Configgains apingfield.main.rsinstantiates the pinger and reportsstartbefore each run andsuccess/failureafterwards;LoggingPairingHandlernow accumulates an error count to drive that decision.Testing
PingConfigdeserialization.wiremock-backed tests verifying each state hits the right URL, that unconfigured states make no request, and that error responses are swallowed without panicking.pingsection (present and absent).LoggingPairingHandler's error counting (the success/failure decision logic).cargo clippyandcargo test --features pure_testsboth pass cleanly. (The repository's network-dependent GitHub API tests fail in the sandbox due to no outbound access, unrelated to this change; they are gated by thepure_testsfeature.)Docs
docs/guide/monitors.mdguide page (added to the VuePress sidebar) with Sentry and healthchecks.io examples.examples/config.yaml.🤖 Generated with Claude Code