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/integrations/celery/crons.mdx
+5-5Lines changed: 5 additions & 5 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -10,10 +10,10 @@ Sentry Crons allows you to monitor the uptime and performance of any scheduled,
10
10
Use the Celery integration to monitor your [Celery periodic tasks](https://docs.celeryq.dev/en/stable/userguide/periodic-tasks.html) and get notified when a 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.
11
11
12
12
<Note>
13
-
Please note that monitors will only be created on the task's first run.
13
+
Please note that a cron monitor will only be created the first time your task runs.
14
14
</Note>
15
15
16
-
First, set up your Celery beat schedule:
16
+
Get started by setting up your Celery beat schedule:
17
17
18
18
```python {filename:tasks.py}
19
19
# tasks.py
@@ -31,11 +31,11 @@ app.conf.beat_schedule = {
31
31
```
32
32
33
33
<Note>
34
-
Please note that only crontab parseable schedules will be successfully
35
-
upserted.
34
+
Please note that only schedules that can be parsed by crontab will be successfully
35
+
updated or inserted.
36
36
</Note>
37
37
38
-
Next, we need to initialize Sentry. Where to do this depends on how you run beat:
38
+
Next, initialize Sentry. Where to do this depends on how you run beat:
39
39
40
40
- If beat is running in your worker process (that is, you're running your worker with the `-B`/`--beat` option), initialize Sentry in either the `celeryd_init` or `beat_init` signal.
41
41
- If beat is running in a separate process, you need to initialize Sentry in _both_ the `celeryd_init` and `beat_init` signal.
If you have the `celery` package in your dependencies, the Celery integration will be enabled automatically when you initialize the Sentry SDK.
19
19
20
-
Make sure that the **call to `sentry_sdk.init()` is loaded on worker startup**, and not only in the module where your tasks are defined. Otherwise, the initialization happens too late and events might end up not being reported.
20
+
<Alert>
21
+
Make sure that the call to `sentry_sdk.init()` is loaded on worker startup and not only in the module where your tasks are defined. Otherwise, the initialization may happen too late and events might not get reported.
22
+
</Alert>
21
23
22
-
### Setup Celery (Without Django)
24
+
### Set Up Celery Without Django
23
25
24
-
To get the most out of Sentry make sure to initialize the Sentry SDK in your Celery worker processes as well as your application that is sending messages to Celery.
26
+
When using Celery without Django, you'll need to initialize the Sentry SDK in both your application and the Celery worker process.
25
27
26
28
In addition to capturing errors, you can monitor interactions between multiple services or applications by [enabling tracing](/concepts/key-terms/tracing/). You can also collect and analyze performance profiles from real users with [profiling](/product/explore/profiling/).
27
29
28
30
Select which Sentry features you'd like to install in addition to Error Monitoring to get the corresponding installation and configuration instructions below.
The [`celeryd_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#celeryd-init) signal is triggered when the Celery deamon is started, before the worker processes are spawned. You can use the [`worker_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#worker-init) signal instead if you want to initialize Sentry on start of each worker process.
65
+
The [`celeryd_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#celeryd-init) signal is triggered when the Celery deamon starts, before the worker processes are spawned. If you need to initialize Sentry for each individual worker process, us the [`worker_init`](https://docs.celeryq.dev/en/stable/userguide/signals.html?#worker-init) signal instead.
64
66
65
67
#### Setup in Your Application
66
68
@@ -93,13 +95,13 @@ if __name__ == "__main__":
93
95
main()
94
96
```
95
97
96
-
### Setup Celery With Django
98
+
### Set Up Celery With Django
97
99
98
-
If you're using Celery with Django in a conventional setup, have already initialized the SDK in your `settings.py` file as described in the [Django integration documentation](/platforms/python/integrations/django/#configure), and have Celery using the same settings with[`config_from_object`](https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html), you don't need to initialize the SDK separately for Celery.
100
+
If you're using Celery with Django in a typical setup, have initialized the SDK in your `settings.py` file (as described in the [Django integration documentation](/platforms/python/integrations/django/#configure)), and have your Celery configured to use the same settings as[`config_from_object`](https://docs.celeryq.dev/en/stable/django/first-steps-with-django.html), there's no need to initialize the Celery SDK separately.
99
101
100
102
## Verify
101
103
102
-
To verify if your SDK is initialized on worker start, you can pass `debug=True` to `sentry_sdk.init()` to see extra output in your Celery logs when the SDK is initialized. If the output appears during worker startup and not only after a task has started, then it's working properly.
104
+
To confirm that your SDK is initialized on worker start, pass `debug=True` to `sentry_sdk.init()`. This will add extra output to your Celery logs when the SDK is initialized. If you see the output during worker startup, and not just after a task has started, then it's working correctly.
103
105
104
106
<Alertlevel="info"title="Note on distributed tracing">
0 commit comments