Langfuse CallbackHandler: LLM spans missing inside LangGraph nodes when running with multiple Uvicorn workers (ECS) #9236
Replies: 1 comment
-
This behavior is not expected—when you attach the Langfuse CallbackHandler at the graph level via with_config(callbacks=[CallbackHandler()]) during graph compilation, all internal LLM and retriever calls within the node functions should be traced and included as child spans under the main graph trace, regardless of the number of Uvicorn workers(1)(2). The documentation and integration examples show that tracing works as long as the CallbackHandler is present in the config, and there is no mention of worker count affecting callback propagation within a single request's execution(1)(2). The CallbackHandler is designed to ensure that all LangChain and LangGraph operations invoked within the graph (including LLMs) are traced as child spans when the handler is attached at the top level(1)(2). However, if you observe missing child spans only when running with multiple Uvicorn workers, this suggests a possible issue with context propagation across processes or threads, which is not explicitly documented as a limitation in the official sources(1)(2). Additionally, there are no documented requirements or caveats for special handling in multi-worker server setups(1)(2). A similar context/trace propagation issue is described for other environments where only events (not traces) appear in the UI when running under certain servers, but not specifically for LangGraph and CallbackHandler usage(3). In summary:
If this behavior persists, it may be an environment-specific or context propagation issue not covered in the current documentation. You may want to review your process/thread model or raise this as a potential bug or support request with the Langfuse team. 📚 Sources:
Have another question? Just tag @inkeep. |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
Uh oh!
There was an error while loading. Please reload this page.
-
Hi everyone,
We’ve noticed an issue where Langfuse traces look different depending on the number of Uvicorn workers.
Environment (local):
langfuse==3.2.1
langchain-core==0.3.69
langgraph==0.5.3
uvicorn==0.35.0
fastapi==0.116.1
Running on Windows 11 with --workers 1
Environment (ECS, production):
Same versions as above
Running on Linux in AWS ECS with --workers 3
Observed behavior:
With --workers 1 (local), we see full traces in Langfuse:
Graph trace
├─ Node: generate_response
└─ LLM span (ChatOpenAI.invoke ) (here its working and giving this trace)
With --workers 3 (ECS), we only see:
Graph trace
├─ Node: generate_response
└─ (no LLM span) (Here its not working)
The graph root + nodes are traced (since we attach with_config(callbacks=[CallbackHandler()]) at compile time), but internal LLM/retriever spans are missing.
Expectation:
Since all nodes in a graph execute within a single worker once the request is assigned, we’d expect child LLM calls to inherit the same callback and show up under the graph trace, regardless of worker count.
Question:
Is this expected behavior (callbacks not guaranteed to propagate in multi-process worker setups)?
Or should Langfuse’s CallbackHandler ensure child runnables (LLMs/retrievers) always get traced when attached at the graph level?
Would love your thoughts
Beta Was this translation helpful? Give feedback.
All reactions