Conversation
Add an opt-in APSchedulerIntegration(monitor_jobs=True) for APScheduler 3.x. When a job with a cron or interval trigger is submitted to its executor, send an in_progress check-in with a monitor config derived from the trigger, so the monitor is created on first run. A scheduler listener sends the ok/error check-in when the run finishes or is missed. The integration is not auto-enabled. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Contributor
Codecov Results 📊✅ 133740 passed | ⏭️ 7239 skipped | Total: 140979 | Pass Rate: 94.87% | Execution Time: 451m 27s 📊 Comparison with Base Branch
➖ Removed Tests (1)View removed tests
All tests are passing successfully. ✅ Patch coverage is 94.55%. Project has 2567 uncovered lines. Files with missing lines (1)
Coverage diff@@ Coverage Diff @@
## master #PR +/-##
==========================================
+ Coverage 90.38% 90.41% +0.03%
==========================================
Files 202 204 +2
Lines 26552 26772 +220
Branches 9858 9936 +78
==========================================
+ Hits 23997 24205 +208
- Misses 2555 2567 +12
- Partials 1487 1492 +5Generated by Codecov Action |
Regenerating locally dropped cached releases of other packages. Restore them and keep only the APScheduler entries. Co-Authored-By: Claude <noreply@anthropic.com>
Move the APScheduler interval-to-schedule conversion into a private helper in sentry_sdk.crons so other integrations can reuse it. Co-Authored-By: Claude <noreply@anthropic.com>
Co-Authored-By: Claude <noreply@anthropic.com>
- Handle the Optional[str] check-in id that capture_checkin now returns. - Send the monitor config only when the trigger's timezone is an IANA name. Sentry rejects names like "UTC+02:00", and without a timezone it would read the crontab as UTC. - Open the check-ins only once the executor accepts the job, so runs skipped because of max_instances send none, instead of in_progress followed by error. - Warn once per job when it has no explicit id and its name is used as the monitor slug. - Say that only APScheduler 3.x is supported when the import fails. Co-Authored-By: Claude <noreply@anthropic.com>
This branch has not been deployed
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.
Description
Adds cron monitoring to a new APScheduler integration (3.3+), opt-in like
CeleryIntegration(monitor_beat_tasks=True):When a job is due, an
in_progresscheck-in is sent with a monitor config built from its trigger, so Sentry creates the monitor on the first run;okorerrorfollows with the duration.CronTriggerandIntervalTriggerare supported. Triggers Sentry can't represent exactly, and one-offDateTriggerjobs, are not monitored, rather than sent with a schedule that would cause false missed-check-in alerts. The slug is the job id, or the job name when the id was generated;exclude_jobsskips jobs by regex.Motivation
Check-ins for a monitor that doesn't exist yet are dropped, so APScheduler users have to create each monitor by hand and add check-in calls to every job. The schedule is already on the trigger, so the SDK can send it and monitors are created and kept in sync automatically.
Testing
tests/integrations/apscheduler, including thread pool, process pool and asyncio schedulers.Docs: getsentry/sentry-docs#19786