## TL;DR

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).

## Steps

1. 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.

2. _Source: https://github.com/pydantic/logfire/issues/653 (Pydantic Logfire)_

## When to use

You are seeing this: Also note the docs hook logfire.instrument_celery() to the worker_init signal, not worker_process_init. _Source: https://github.com/pydantic/logfire/issues/653 (Pydantic Logfire)_ Use this skill when you run into "Logfire with Celery ingores `token`".

## When not to use

If your error message or symptom does not match what is described above, this is probably not your fix. Search for your exact error text instead of forcing this one to fit.

## Versions

Versions mentioned in the source: logfire 2.7.0. If you are on something much newer or older, the details may have shifted.

## Why this happens

The original report does not dig into a root cause. It documents the symptom and the fix that resolved it.

## Edge cases

- Also note the docs hook logfire.instrument_celery() to the worker_init signal, not worker_process_init. _Source: https://github.com/pydantic/logfire/issues/653 (Pydantic Logfire)_

## Sources

- https://github.com/pydantic/logfire/issues/653
