Monitoring
Cron monitors
A cron monitor watches a scheduled job: a nightly report, an hourly sync, a weekly cleanup. Your job tells Bugzor when it starts and how it ended (a check-in), using the same SDK and DSN you already use for errors. Bugzor then shows every run on the Crons page and emails you when something goes wrong.
Each monitor is identified by a slug you choose, such as nightly-report, within one project.
Send check-ins#
Wrap the job with your SDK’s monitor helper. It sends an in_progress check-in when the job starts, then ok or
error (with the duration) when it ends. Both belong to the same run.
Python:
from sentry_sdk.crons import monitor
@monitor(monitor_slug="nightly-report")
def nightly_report():
...JavaScript and Node.js:
Sentry.withMonitor("nightly-report", async () => {
await buildReport();
});Ruby (Sidekiq, Active Job or any class):
class NightlyReportJob < ApplicationJob
include Sentry::Cron::MonitorCheckIns
sentry_monitor_check_ins slug: "nightly-report"
endGo:
id := sentry.CaptureCheckIn(&sentry.CheckIn{MonitorSlug: "nightly-report", Status: sentry.CheckInStatusInProgress}, nil)
err := buildReport()
status := sentry.CheckInStatusOK
if err != nil {
status = sentry.CheckInStatusError
}
sentry.CaptureCheckIn(&sentry.CheckIn{ID: *id, MonitorSlug: "nightly-report", Status: status}, nil)PHP:
\Sentry\withMonitor(slug: 'nightly-report', callback: fn () => build_report());The run shows up on Crons within seconds. A job that only sends a single ok (a heartbeat) works too: each
check-in is then a run of its own.
Send a schedule#
With check-ins alone, Bugzor records runs and failures. To also be told when a job doesn’t run at all, send
its schedule as a monitor_config with the check-in. Bugzor uses the most recent one it received.
A crontab, evaluated in the job’s time zone:
@monitor(
monitor_slug="nightly-report",
monitor_config={
"schedule": {"type": "crontab", "value": "0 3 * * *"},
"timezone": "Europe/Paris",
"checkin_margin": 5, # minutes a run may be late before it counts as missed
"max_runtime": 30, # minutes a run may take before it counts as timed out
},
)
def nightly_report():
...Or an interval, counted from the last run:
Sentry.withMonitor("hourly-sync", syncInvoices, {
schedule: { type: "interval", value: 2, unit: "hour" },
checkinMargin: 5,
maxRuntime: 30,
});| Setting | Meaning | Default |
|---|---|---|
schedule | crontab (five fields, no seconds) or interval (value + minute, hour, day, week, month or year) | none |
timezone | IANA zone for a crontab, such as America/New_York; daylight saving is handled | UTC |
checkin_margin | Minutes after the expected time before a run counts as missed. A run that starts up to this many minutes early also counts | 1 |
max_runtime | Minutes a run may stay in progress before it counts as timed out | 30 |
The Ruby, Go and PHP SDKs take the same settings: Sentry::Cron::MonitorConfig.from_crontab(...),
sentry.MonitorConfig{Schedule: sentry.CrontabSchedule(...)} and new \Sentry\MonitorConfig(...).
No schedule means Bugzor can’t know when a run was due, so it never reports a missed run. The same applies when the crontab or time zone can’t be read: Bugzor treats it as no schedule rather than guessing. The monitor’s page says “No schedule sent” in that case.
Notifications#
Bugzor emails the members who can see the project. Each person can change or turn these off under Account → Notifications, including per project and per environment.
| When | How often | |
|---|---|---|
| Failed run | A run ends with status error | At most once per job per hour |
| Timed out | A scheduled run is still in progress after max_runtime | Counts as a failed run: at most once per job per hour |
| Missed check-in | A scheduled run hasn’t started by its expected time plus checkin_margin | Once per outage: nothing more until the job checks in again |
A job that stops completely therefore sends one “missed” email, not one per missed slot. The next check-in ends the outage, and a later outage sends a new email. Only jobs that checked in within the last week are watched, so a job you retired stops alerting by itself.
Mute a monitor#
On a monitor’s page, Mute stops its “failed”, “timed out” and “missed” emails, for example while you rework a job. Runs are still recorded and shown. Anyone who can triage issues can mute or unmute, and each change is recorded in the workspace’s audit log.
How long check-ins are kept#
Check-ins are kept for your plan’s error retention (one year today); each page says how long. A job that runs rarely, such as once a quarter, only shows the runs still kept, so it can look quiet on the Crons page’s longer ranges even though it is healthy.
Something unclear or out of date? Tell us.