You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: docs/platforms/python/crons/index.mdx
+65Lines changed: 65 additions & 0 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,71 @@ Sentry Crons allows you to monitor the uptime and performance of any scheduled,
12
12
13
13
<PlatformContentincludePath="crons/setup" />
14
14
15
+
## Configuring Cron Monitors
16
+
17
+
You can create and update your monitors programmatically with code rather than [creating and configuring them in Sentry.io](https://sentry.io/crons/create/). If the monitor doesn't exist in Sentry yet, it will be created.
18
+
19
+
To create or update a monitor, use `monitor` as outlined above and pass in your monitor configuration as `monitor_config`. This requires SDK version `1.45.0` or higher.
If you're using [manual check-ins](#check-ins), you can pass your `monitor_config` to the `capture_checkin` call:
46
+
47
+
```python
48
+
check_in_id = capture_checkin(
49
+
monitor_slug='<monitor-slug>',
50
+
status=MonitorStatus.IN_PROGRESS,
51
+
monitor_config=monitor_config,
52
+
)
53
+
```
54
+
55
+
## Manual Check-Ins
56
+
57
+
Check-in monitoring allows you to track a job's progress by capturing two check-ins: one at the start of your job and another at the end of your job. This two-step process allows Sentry to notify you if your job didn't start when expected (missed) or if it exceeded its maximum runtime (failed).
58
+
59
+
If you use the `monitor` decorator/context manager, the SDK will create check-ins for the wrapped code automatically.
60
+
61
+
```python
62
+
from sentry_sdk.crons import capture_checkin
63
+
from sentry_sdk.crons.consts import MonitorStatus
64
+
65
+
check_in_id = capture_checkin(
66
+
monitor_slug='<monitor-slug>',
67
+
status=MonitorStatus.IN_PROGRESS,
68
+
)
69
+
70
+
# Execute your task here...
71
+
72
+
capture_checkin(
73
+
monitor_slug='<monitor-slug>',
74
+
check_in_id=check_in_id,
75
+
status=MonitorStatus.OK,
76
+
)
77
+
```
78
+
79
+
15
80
## Alerts
16
81
17
82
When your recurring job fails to check in (missed), runs beyond its configured maximum runtime (failed), or manually reports a failure, Sentry will create an error event with a tag to your monitor.
0 commit comments