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
{{ message }}
Repository navigation
Commit 66ee86f
Browse filesBrowse the repository at this point in the historyBrowse files
`_set_trace` and `gevent_timeout` already exist in this module / `app/celery/utils.py` — reuse
32
+
them, don't reinvent. Enqueue through a `start_*` helper in `app/celery/utils.py`, which calls
33
+
plain `task.apply_async(kwargs={...})`.
36
34
37
35
## Queue and priority choice — be explicit
38
36
@@ -61,7 +59,7 @@ inherits its priority unless you override it.
61
59
-**`bind=True`** so you have `self` (the task instance) for retries, IDs, etc.
62
60
-**Always pass an explicit `queue` (`"default"` or `"evaluations"`) and `priority`.** Only fast-eval chunk/aggregate tasks use `"evaluations"`; everything else uses `"default"`.
63
61
-**Pass `trace_id` explicitly** as a parameter and call `_set_trace(trace_id)` first thing. This wires `asgi_correlation_id` so logs from inside the task match the originating request.
64
-
-**Wrap the work in `_run_with_otel_parent(self, lambda: ...)`** so OpenTelemetry parent context propagates from the enqueueing process.
62
+
-**Don't propagate trace context by hand.** OTel's `CeleryInstrumentor` already parents the worker's `run/...` span to the enqueue span. Injecting headers on enqueue or attaching an extracted context in the task reparents the task's spans to the API request, and Sentry splits them into separate transactions.
65
63
-**Delegate to a service.** The task body should be a thin shim over `app/services/<domain>/`. No DB queries, no external HTTP, no business logic inside the task itself.
66
64
-**Late-import the service inside the function body** (as the canonical pattern does). Celery workers boot faster and you avoid model-import cycles.
0 commit comments