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: src/platforms/python/guides/celery/index.mdx
+43-2Lines changed: 43 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -94,9 +94,14 @@ You can pass the following keyword arguments to `CeleryIntegration()`:
94
94
95
95
-`propagate_traces`
96
96
97
-
Propagate Sentry tracing information to the Celery task. This makes it possible to link errors in Celery tasks to the function that triggered the Celery task. If this is set to `False`, errors in Celery tasks can't be matched to the triggering function.
97
+
Propagate Sentry tracing information to the Celery task. This makes it possible to link Celery task errors to the function that triggered the task.
98
98
99
-
The default is `True`.
99
+
If this is set to `False`:
100
+
101
+
- errors in Celery tasks won't be matched to the triggering function.
102
+
- your Celery tasks will start a new trace and won't be connected to the trace in the calling function.
103
+
104
+
The default is `True`.
100
105
101
106
-`monitor_beat_tasks`:
102
107
@@ -115,3 +120,39 @@ You can pass the following keyword arguments to `CeleryIntegration()`:
115
120
See <PlatformLinkto="/crons/#celery-beat-auto-discovery">Celery Beat Auto Discovery</PlatformLink> to learn more.
116
121
117
122
The default is `None`.
123
+
124
+
## Distributed Traces
125
+
126
+
Distributed tracing extends the trace from the code that's running your Celery task so that it includes the code that initiated the task.
127
+
128
+
You can disable this globally with the `propagate_traces` parameter, documented above. If you set `propagate_traces` to `False`, all Celery tasks will start their own trace.
129
+
130
+
If you want to have more fine-grained control over trace distribution, you can override the `propagate_traces` option by passing the `sentry-propagate-traces` header when starting the Celery task:
131
+
132
+
```python
133
+
import sentry_sdk
134
+
135
+
# Enable global distributed traces (this is the default, just to be explicit.)
136
+
sentry_sdk.init(
137
+
dsn="___PUBLIC_DSN___",
138
+
integrations=[
139
+
CeleryIntegration(propagate_traces=True),
140
+
],
141
+
)
142
+
143
+
# This will propagate the trace:
144
+
my_task_a.delay("some parameter")
145
+
146
+
# This will propagate the trace:
147
+
my_task_b.apply_async(
148
+
args=("some_parameter", )
149
+
)
150
+
151
+
# This will NOT propagate the trace. (The task will start its own trace):
152
+
my_task_b.apply_async(
153
+
args=("some_parameter", ),
154
+
headers={"sentry-propagate-traces": False},
155
+
)
156
+
157
+
# Note: overriding the tracing behaviour using `task_x.delay()` is not possible.
0 commit comments