Skip to content

Commit be9c297

Browse files
Python: Getting Started celery (#7864)
* Python: Getting Started celery * Update src/platforms/python/guides/celery/index.mdx Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com> --------- Co-authored-by: Shana Matthews <shana.l.matthews@gmail.com>
1 parent e0e99e2 commit be9c297

File tree

1 file changed

+22
-17
lines changed

1 file changed

+22
-17
lines changed

src/platforms/python/guides/celery/index.mdx

Lines changed: 22 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -8,34 +8,34 @@ description: "Learn about using Sentry with Celery."
88

99
The Celery integration adds support for the [Celery Task Queue System](https://docs.celeryq.dev/).
1010

11-
Just add `CeleryIntegration()` to your `integrations` list:
11+
## Install
12+
13+
Install `sentry-sdk` from PyPI with the `celery` extra:
14+
15+
```bash
16+
pip install --upgrade 'sentry-sdk[celery]'
17+
```
18+
19+
## Configure
20+
21+
If you have the `celery` package in your dependencies, the Celery integration will be enabled automatically when you initialize the Sentry SDK.
22+
23+
Make sure that the **call to `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.
1224

1325
<SignInNote />
1426

1527
```python
1628
import sentry_sdk
17-
from sentry_sdk.integrations.celery import CeleryIntegration
1829

1930
sentry_sdk.init(
2031
dsn='___PUBLIC_DSN___',
21-
integrations=[
22-
CeleryIntegration(),
23-
],
24-
2532
# Set traces_sample_rate to 1.0 to capture 100%
2633
# of transactions for performance monitoring.
27-
# We recommend adjusting this value in production,
2834
traces_sample_rate=1.0,
2935
)
3036
```
3137

32-
Additionally, the Sentry Python SDK will set the transaction on the event to the task name, and it will improve the grouping for global Celery errors such as timeouts.
33-
34-
The integration will automatically report errors from all celery jobs.
35-
36-
Generally, make sure that the **call to `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.
37-
38-
## Standalone Setup
38+
### Standalone Setup
3939

4040
If you're using Celery standalone, there are two ways to set this up:
4141

@@ -51,16 +51,16 @@ If you're using Celery standalone, there are two ways to set this up:
5151
#@signals.worker_init.connect
5252
@signals.celeryd_init.connect
5353
def init_sentry(**_kwargs):
54-
sentry_sdk.init(dsn="...")
54+
sentry_sdk.init(...) # same as above
5555
```
5656

57-
## Setup With Django
57+
### Setup With Django
5858

5959
If you're using Celery with Django in a conventional setup, have already initialized the SDK in [your `settings.py` file](/platforms/python/guides/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.
6060

6161
## Verify
6262

63-
To verify if your SDK is initialized on worker start, you can pass `debug=True` to see extra output 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.
63+
To verify if your SDK is initialized on worker start, you can pass `debug=True` to `sentry_sdk.init()` to see extra output 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.
6464

6565
<Alert level="info" title="Note on distributed tracing">
6666

@@ -156,3 +156,8 @@ my_task_b.apply_async(
156156

157157
# Note: overriding the tracing behaviour using `task_x.delay()` is not possible.
158158
```
159+
160+
## Supported Versions
161+
162+
- Celery: 3.0+
163+
- Python: 2.7+ (Celery 3+), 3.6+ (Celery 5.0+), 3.7+ (Celery 5.1+)

0 commit comments

Comments
 (0)