From ee09337cd6c4ec8fbe02f6d3a6a2bd9c7c45e25b Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Fri, 2 Oct 2026 13:05:02 -0700 Subject: [PATCH 1/2] docs(python): Add APScheduler integration page Document the opt-in APSchedulerIntegration that monitors APScheduler jobs with Sentry Crons, and link it from the Python crons page. Co-Authored-By: Claude Opus 5.5 --- .../python/integrations/apscheduler/index.mdx | 80 +++++++++++++++++++ docs/platforms/python/integrations/index.mdx | 1 + platform-includes/crons/setup/python.mdx | 2 + 3 files changed, 83 insertions(+) create mode 100644 docs/platforms/python/integrations/apscheduler/index.mdx diff --git a/docs/platforms/python/integrations/apscheduler/index.mdx b/docs/platforms/python/integrations/apscheduler/index.mdx new file mode 100644 index 0000000000000..8a008c9d29f1c --- /dev/null +++ b/docs/platforms/python/integrations/apscheduler/index.mdx @@ -0,0 +1,80 @@ +--- +title: APScheduler +description: "Learn how to monitor APScheduler jobs with Sentry Crons." +--- + +The APScheduler integration monitors jobs scheduled with [APScheduler](https://apscheduler.readthedocs.io/en/3.x/) using [Sentry Crons](/product/monitors-and-alerts/monitors/crons/). You get alerted when a job doesn't run on time, fails, or runs too long. + + + This integration is available from the next SDK release after `2.71.0`. + + +## Install + +Install `sentry-sdk` from PyPI: + +```bash {tabTitle:pip} +pip install "sentry-sdk" +``` + +```bash {tabTitle:uv} +uv add "sentry-sdk" +``` + +## Configure + +The integration isn't enabled automatically. Add `APSchedulerIntegration` with `monitor_jobs=True` in the process that runs the scheduler: + +```python +import sentry_sdk +from sentry_sdk.integrations.apscheduler import APSchedulerIntegration + +sentry_sdk.init( + dsn="___PUBLIC_DSN___", + integrations=[ + APSchedulerIntegration(monitor_jobs=True), + ], +) +``` + +Each job gets a monitor, created the first time the job runs. The monitor slug is the job's `id`. Give your jobs an explicit `id`. If a job has no `id`, its name is used, which defaults to the function name. + +The schedule comes from the job's trigger: + +- `CronTrigger`: a crontab schedule in the trigger's timezone. Triggers that use seconds, years, weeks, or both `day` and `day_of_week` aren't monitored. +- `IntervalTrigger`: an interval schedule. Intervals must be whole minutes. +- `DateTrigger`: one-off jobs aren't monitored. + +## Verify + +```python +from apscheduler.schedulers.blocking import BlockingScheduler + +def send_report(): + 1 / 0 + +scheduler = BlockingScheduler() +scheduler.add_job(send_report, "cron", minute="*", id="send-report") +scheduler.start() +``` + +Within a minute, a `send-report` cron monitor appears in Sentry with a failed check-in. + +## Options + +- `monitor_jobs`: Send check-ins for scheduled jobs. Defaults to `False`. +- `exclude_jobs`: A list of monitor slugs or regular expressions for jobs that shouldn't be monitored. + +```python +APSchedulerIntegration( + monitor_jobs=True, + exclude_jobs=["cleanup", "report-.*"], +) +``` + +## Supported Versions + +- APScheduler: 3.3+ (APScheduler 4 isn't supported) +- Python: 3.6+ + + diff --git a/docs/platforms/python/integrations/index.mdx b/docs/platforms/python/integrations/index.mdx index 94064985d0a65..8e22c85f28560 100644 --- a/docs/platforms/python/integrations/index.mdx +++ b/docs/platforms/python/integrations/index.mdx @@ -63,6 +63,7 @@ The Sentry SDK uses integrations to hook into the functionality of popular libra | | | | | | | | | +| | | | | ✓ | | | ✓ | | | | diff --git a/platform-includes/crons/setup/python.mdx b/platform-includes/crons/setup/python.mdx index 27e90b390e83e..d5c37f004f4cd 100644 --- a/platform-includes/crons/setup/python.mdx +++ b/platform-includes/crons/setup/python.mdx @@ -2,6 +2,8 @@ If you're using **Celery Beat** to run your periodic tasks, have a look at our [Celery Beat Auto Discovery documentation](/platforms/python/integrations/celery/crons/). +If you're using **APScheduler**, see the [APScheduler integration](/platforms/python/integrations/apscheduler/). + ## Job Monitoring Use the Python SDK to monitor and notify you if your periodic task is missed (or doesn't start when expected), if it fails due to a problem in the runtime (such as an error), or if it fails by exceeding its maximum runtime. From e2e61545ed1bac48337334683897b7de8b2917fc Mon Sep 17 00:00:00 2001 From: Dan Fuller Date: Mon, 5 Oct 2026 12:22:13 -0700 Subject: [PATCH 2/2] docs(python): Clarify APScheduler exclude_jobs matching and skipped runs Co-Authored-By: Claude --- docs/platforms/python/integrations/apscheduler/index.mdx | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/docs/platforms/python/integrations/apscheduler/index.mdx b/docs/platforms/python/integrations/apscheduler/index.mdx index 8a008c9d29f1c..61a4ad9c683f8 100644 --- a/docs/platforms/python/integrations/apscheduler/index.mdx +++ b/docs/platforms/python/integrations/apscheduler/index.mdx @@ -37,14 +37,16 @@ sentry_sdk.init( ) ``` -Each job gets a monitor, created the first time the job runs. The monitor slug is the job's `id`. Give your jobs an explicit `id`. If a job has no `id`, its name is used, which defaults to the function name. +Each job gets a monitor, created the first time the job runs. The monitor slug is the job's `id`. Give your jobs an explicit `id`. If a job has no `id`, the SDK uses its name, which defaults to the function name, and logs a warning. The schedule comes from the job's trigger: -- `CronTrigger`: a crontab schedule in the trigger's timezone. Triggers that use seconds, years, weeks, or both `day` and `day_of_week` aren't monitored. +- `CronTrigger`: a crontab schedule in the trigger's timezone. Triggers that use seconds, years, weeks, or both `day` and `day_of_week` aren't monitored, and neither are triggers whose timezone has no IANA name (such as a fixed UTC offset). - `IntervalTrigger`: an interval schedule. Intervals must be whole minutes. - `DateTrigger`: one-off jobs aren't monitored. +Runs that APScheduler skips because the job reached `max_instances` don't send check-ins. + ## Verify ```python @@ -63,7 +65,7 @@ Within a minute, a `send-report` cron monitor appears in Sentry with a failed ch ## Options - `monitor_jobs`: Send check-ins for scheduled jobs. Defaults to `False`. -- `exclude_jobs`: A list of monitor slugs or regular expressions for jobs that shouldn't be monitored. +- `exclude_jobs`: A list of monitor slugs or regular expressions for jobs that shouldn't be monitored. Each entry must match the end of the slug, so `cleanup` also excludes `nightly-cleanup`. Use `^cleanup` to match only `cleanup`. ```python APSchedulerIntegration(