Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
45 changes: 45 additions & 0 deletions docs/platforms/python/integrations/rq/crons.mdx
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
---
title: Crons
description: "Learn how to monitor RQ cron jobs with Sentry Crons."
---

The RQ integration can monitor jobs scheduled with [RQ's cron scheduler](https://python-rq.org/docs/cron/) (`rq cron`) 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.

<Alert>
This is available from the next SDK release after `2.71.0`, and needs RQ 2.4 or newer.
</Alert>

## Configure

Monitoring is off by default. Set `monitor_cron_jobs=True` on `RqIntegration` in your cron configuration file, which `rq cron` loads on startup:

```python {filename:cron_config.py}
import sentry_sdk
from sentry_sdk.integrations.rq import RqIntegration
from rq import cron

from myapp import send_newsletter

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
RqIntegration(monitor_cron_jobs=True),
],
)

cron.register(send_newsletter, queue_name="email", cron="30 10 * * 2")
```

Your workers also need to initialize Sentry, as described on the <PlatformLink to="/integrations/rq/">RQ integration page</PlatformLink>. The scheduler sends a check-in when it enqueues a job, and the worker sends one when the job finishes or fails.

Each cron job gets a monitor, created the first time the job runs. The monitor slug is the cron job's `name`, which defaults to the function's import path, like `myapp.send_newsletter`.

The schedule comes from the cron job:

- `cron`: a crontab schedule in UTC. Crontabs with a seconds field aren't monitored.
- `interval`: an interval schedule. Intervals must be whole minutes.

## Supported Versions

- RQ: 2.4+
- Python: 3.9+
4 changes: 4 additions & 0 deletions docs/platforms/python/integrations/rq/index.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -190,6 +190,10 @@ If you run the RQ worker with `rq worker -c mysettings`, a transaction for the e

It takes a couple of moments for the data to appear in [sentry.io](https://sentry.io).

## Crons

To monitor jobs scheduled with `rq cron`, see <PlatformLink to="/integrations/rq/crons/">RQ Crons</PlatformLink>.

## The `--sentry-dsn` CLI option

The `--sentry-dsn` CLI option has been removed from RQ. Initialize the Sentry SDK directly in your worker settings file (e.g. `mysettings.py`) as shown above.
Expand Down
2 changes: 2 additions & 0 deletions platform-includes/crons/setup/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -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 **RQ's cron scheduler** (`rq cron`), see [RQ Crons](/platforms/python/integrations/rq/crons/).

## 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.
Expand Down
Loading