Repository navigation
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
Coverage Results 📊✅ 134919 passed | ⏭️ 7393 skipped | Total: 142312 | Pass Rate: 94.81% | Execution Time: 434m 56s 📊 Comparison with Base Branch
All tests are passing successfully. ✅ Patch coverage is 95.39% (207 of 217 changed executable lines covered; target 80%). Changed files with executable lines (3)
Coverage diff@@ Coverage Diff @@
## master #7840 +/-##
==========================================
+ Coverage 90.31% 90.35% +0.04%
==========================================
Files 203 204 +1
Tracked lines 26880 27084 +204
Branches 10042 10118 +76
==========================================
+ Hits 24276 24470 +194
- Misses 2604 2614 +10
- Partials 1517 1522 +5Generated by Coverage 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>
# Conflicts: # scripts/populate_tox/package_dependencies.jsonl # scripts/populate_tox/releases.jsonl
Sentry monitor schedules don't end, so a finite cron or interval trigger would raise missed check-ins after its last run.
Move arq's timezone name logic into sentry_sdk.crons.utils and use it for APScheduler too, so fixed-offset timezones with whole-hour offsets are monitored with Etc/GMT names. tzlocal's "local" zone is rejected.
Jitter delays runs by up to that many seconds, so add it on top of Sentry's default 1 minute check-in margin.
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