Skip to content

Add HTTP-based cron monitoring support#597

Merged
notheotherben merged 2 commits into
mainfrom
claude/adoring-tesla-pulbsg
Jun 19, 2026
Merged

Add HTTP-based cron monitoring support#597
notheotherben merged 2 commits into
mainfrom
claude/adoring-tesla-pulbsg

Conversation

@notheotherben

@notheotherben notheotherben commented Jun 19, 2026

Copy link
Copy Markdown
Member

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 GET request 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 ping key accepts an optional URL for each state. Any state you leave out is simply not reported:

schedule: "0 * * * *"

ping:
  start: https://sentry.io/api/0/organizations/your-org/monitors/github-backup/checkins/?status=in_progress
  success: https://sentry.io/api/0/organizations/your-org/monitors/github-backup/checkins/?status=ok
  failure: https://sentry.io/api/0/organizations/your-org/monitors/github-backup/checkins/?status=error

backups:
  - kind: github/repo
    from: user
    to: /backup/github
    credentials: !Token your_access_token

Allowing a separate URL per state keeps the implementation to plain GET requests while supporting both query-parameter-based services (Sentry: ?status=...) and path-suffix-based services (healthchecks.io: /start, /fail).

Behaviour notes

  • Best-effort. If the monitoring service can't be reached (or returns a non-2xx status), a warning is logged but the backup run itself is never affected. A flaky monitor can't cause an otherwise healthy run to be reported as failed.
  • Interrupted runs. If a run is interrupted via SIGINT, neither success nor failure is reported (the monitor will naturally observe a missed check-in).
  • A run is reported as failure when any policy reports one or more errors, tracked via the pairing handler's error count.

Implementation

  • New src/ping.rs module with PingConfig (deserialized from the ping key) and a Pinger that issues the GET requests.
  • Config gains a ping field.
  • main.rs instantiates the pinger and reports start before each run and success/failure afterwards; LoggingPairingHandler now accumulates an error count to drive that decision.

Testing

  • Unit tests for PingConfig deserialization.
  • wiremock-backed tests verifying each state hits the right URL, that unconfigured states make no request, and that error responses are swallowed without panicking.
  • Config tests covering the new ping section (present and absent).
  • A unit test for LoggingPairingHandler's error counting (the success/failure decision logic).

cargo clippy and cargo test --features pure_tests both 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 the pure_tests feature.)

Docs

  • New "Cron Monitoring" section in the README.
  • New docs/guide/monitors.md guide page (added to the VuePress sidebar) with Sentry and healthchecks.io examples.
  • Example added to examples/config.yaml.

🤖 Generated with Claude Code

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

codecov Bot commented Jun 19, 2026

Copy link
Copy Markdown

Codecov Report

❌ Patch coverage is 92.17391% with 9 lines in your changes missing coverage. Please review.
✅ Project coverage is 72.74%. Comparing base (43f0cb0) to head (2f87213).

Files with missing lines Patch % Lines
src/main.rs 62.50% 9 Missing ⚠️
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.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.

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
@notheotherben notheotherben merged commit 07e90f6 into main Jun 19, 2026
15 checks passed
@notheotherben notheotherben deleted the claude/adoring-tesla-pulbsg branch June 19, 2026 00:35
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants