Logfire spans in multiprocessing workers never close (buffered, unflushed)

With logfire 2.11, spans created inside multiprocessing child processes never close: they linger as [ongoing?] in the live view long after the process finished. Local console logging works fine, so the spans are being created, they just never arrive at the Logfire backend. Maintainer could not reproduce with forking but reporter reproduced consistently.

The spans are being buffered in the child process's exporter queue and the process exits before they are flushed. The verified fix: call logfire.force_flush() at the end of the worker function, before the process exits. The reporter confirmed spans then arrive and close correctly. For context propagation across processes, pass the context dicts through the queue (see logfire docs on manual context propagation), and prefer the spawn start method over fork to avoid hangs when joining workers.

Source: https://github.com/pydantic/logfire/issues/741

Source: https://github.com/pydantic/logfire/issues/741