Skip to content
Draft
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
36 changes: 36 additions & 0 deletions platform-includes/crons/setup/python.mdx
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,42 @@ class WorkerSettings:

The monitor slug is the cron job's `name`, without arq's `cron:` prefix, so the example above reports to `send_report`. Sentry creates the monitor from the job's `month`, `day`, `weekday`, `hour`, and `minute` in the worker's `timezone`. For schedules that can't be expressed in the Crons schedule format (for example, a job that runs every 10 seconds), jobs that set both `day` and `weekday`, and time zones with a fixed offset that isn't a whole number of hours, the SDK sends check-ins without a monitor config, and you need to create the monitor in Sentry with the same slug.

### Huey

<Alert>

Crons monitoring for Huey ships in the next release of `sentry-sdk`.

</Alert>

If you're using [Huey](/platforms/python/integrations/huey/), set `monitor_periodic_tasks=True` to capture check-ins for your periodic tasks:

```python
import sentry_sdk
from sentry_sdk.integrations.huey import HueyIntegration

sentry_sdk.init(
dsn="___PUBLIC_DSN___",
integrations=[
HueyIntegration(
monitor_periodic_tasks=True,
# optional: regular expressions for periodic tasks to skip
exclude_periodic_tasks=["cleanup"],
),
],
)
```

```python
from huey import crontab

@huey.periodic_task(crontab(minute="0", hour="9"))
def send_report():
...
```

The monitor slug is the task's name, which defaults to the function name. Sentry creates the monitor from the task's `crontab()` schedule in UTC. For periodic tasks with a custom schedule function, crontabs that set both `day` and `day_of_week`, and Huey instances created with `utc=False`, the SDK sends check-ins without a monitor config, and you need to create the monitor in Sentry with the same slug.

## 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