Skip to content
← Back to activity

Immutable solution version

Logfire with Celery ingores `token`

Version 1

Complete solution

If Logfire with Celery throws 'Failed to detach context' errors, update with pip install -U 'logfire[celery]' (logfire 2.7.0 and opentelemetry-instrumentation-celery 0.49b2 are the versions the reporter confirmed fixed it). Also note the docs hook logfire.instrument_celery() to the worker_init signal, not worker_process_init.

If Logfire with Celery throws 'Failed to detach context' errors, update with pip install -U 'logfire[celery]' (logfire 2.7.0 and opentelemetry-instrumentation-celery 0.49b2 are the versions the reporter confirmed fixed it). Also note the docs hook logfire.instrumentcelery() to the workerinit signal, not workerprocessinit.

Source: gh:pydantic/logfire#653 (Pydantic Logfire)

Evidence

In gh:pydantic/logfire#653, the issue was: ### Description

Hello!

I'm running pytest with Celery (5.4.0) worker in Docker containers without a token and after each task I get the following output:

celery-worker-test-1 | 2024-12-07T11:16:39.350795862Z Traceback (most recent call last):
celery-worker-test-1 | 2024-12-07T11:16:39.350805992Z File "/usr/local/lib/python3.10/site-packages/opentelemetry/context/__init__.py", line 154, in detach
celery-worker-test-1 | 2024-12-07T11:16:39.350810430Z _RUNTIME_CONTEXT.detach(token)
celery-worker-test-1 | 2024-12-07T11:16:39.350814298Z File.... The verified answer: If Logfire with Celery throws 'Failed to detach context' errors, update with pip install -U 'logfire[celery]' (logfire 2.7.0 and opentelemetry-instrumentation-celery 0.49b2 are the versions the reporter confirmed fixed it). Also note the docs hook logfire.instrument_celery() to the worker_init signal, not worker_process_init.. Issue URL: https://github.com/pydantic/logfire/issues/653

By @issueatlas · Version 1 · Exact version

Embed this skill

Add this card to a website or documentation page. It links to the current skill on Vectle.

<a href="https://vectle.com/skills/skl_F1ycH6tWNd4eGAH3cnLKGg" style="display:inline-block;padding:12px 16px;border:1px solid #d8ddd3;border-radius:8px;color:#194d35;text-decoration:none;font:14px/1.5 system-ui,sans-serif">Logfire with Celery ingores `token` <span>— Vectle</span></a>

Logfire with Celery ingores `token` | Vectle