Skip to content

feat(arq): Add cron monitoring for arq cron jobs - #8051

Draft
wedamija wants to merge 4 commits into
masterfrom
danf/arq-crons
Draft

wedamija wants to merge 4 commits into
masterfrom
danf/arq-crons

Conversation

@wedamija

@wedamija wedamija commented Oct 17, 2026 •

Copy link
Copy Markdown
Member

Description

Part of a series adding automatic Crons monitoring for the most-used job schedulers in each SDK. Check-ins for a monitor that doesn't exist yet are dropped, so today each monitor has to be created by hand with its schedule copied from the code. Sending the job's schedule as the monitor config lets Sentry create the monitor and keep it in sync.

This adds opt-in check-ins for arq cron jobs (cron(...) in cron_jobs), modelled on CeleryIntegration(monitor_beat_tasks=True, exclude_beat_tasks=[...]):

sentry_sdk.init(
    integrations=[ArqIntegration(monitor_cron_jobs=True, exclude_cron_jobs=["cleanup"])],
)
  • The worker sends in_progress when a cron job starts and ok or error when it ends.
  • The slug is the cron job's name, without arq's default cron: prefix (so cron(send_report) becomes send_report). exclude_cron_jobs takes regexes, matched like exclude_beat_tasks.
  • The monitor config is a crontab built from the month/day/weekday/hour/minute fields, in the worker's timezone. Fixed UTC offsets (arq's default is the system's offset at startup) are sent as Etc/GMT±N. Before arq 0.25, cron jobs run in local time, so the config is only sent when the system timezone is UTC.
  • Check-ins are sent without a config when the schedule can't be represented: a second other than 0, both day and weekday set (arq requires both to match, cron either), or a timezone with no IANA name (such as a UTC+05:30 offset).
  • run_at_startup runs are checked in like any other run.

Issues

Docs: getsentry/sentry-docs#20056

Send check-ins around each run of an arq cron job when
ArqIntegration(monitor_cron_jobs=True) is set. The cron job's schedule is
sent as the monitor config when it maps to a crontab in an IANA timezone,
so Sentry creates the monitor and keeps it in sync.

Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
Comment thread sentry_sdk/integrations/arq.py
@github-actions

github-actions Bot commented Oct 17, 2026 •

Copy link
Copy Markdown
Contributor

Coverage Results 📊

✅ 133854 passed | ⏭️ 7294 skipped | Total: 141148 | Pass Rate: 94.83% | Execution Time: 442m 55s

📊 Comparison with Base Branch

Metric Change
Total Tests 📈 +206
Passed Tests 📈 +188
Failed Tests —
Skipped Tests 📈 +18

All tests are passing successfully.

✅ Patch coverage is 94.81% (73 of 77 changed executable lines covered; target 80%).
Project statement coverage is 90.24% (down 0.01 percentage points from base (0f7acd5) to head (9b8ca99)).

Changed files with executable lines (1)
File Patch coverage Changed executable lines
sentry_sdk/integrations/arq.py 94.81% 73/77 covered; missed: 361, 363, 391, 416; partial branches: 360, 362, 390, 409
Coverage diff
@@            Coverage Diff             @@
##        master     #8051       +/-##
==========================================
- Coverage    90.25%    90.24%    -0.01%
==========================================
  Files          202       202         —
  Tracked lines     26660     26736       +76
  Branches      9926      9968       +42
==========================================
+ Hits         24062     24127       +65
- Misses        2598      2609       +11
- Partials      1510      1514        +4

Generated by Coverage Action

wedamija and others added 2 commits October 16, 2026 18:09
Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>

This branch has not been deployed

No deployments
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.

1 participant