Skip to content

AsyncPipeline Creates Multiple Traces Instead of a Single Unified Trace in Langfuse #1604

Closed
@immortal3

Description

@immortal3

Describe the Bug:
When using the AsyncPipeline instead of the synchronous Pipeline, multiple trace entries are created in Langfuse for what should be a single execution of the pipeline. This behavior makes it difficult to get a unified view of the request flow.

Additionally, the following warning is logged during execution:

WARNING: 2025-04-03,17:49:55: tracer.py:243: Creating a new trace without a parent span is not recommended for operation 'haystack.async_pipeline.run'.

This suggests that the trace context is not being properly propagated across async components or pipeline runs.


Code to Reproduce:

from haystack import AsyncPipeline
from haystack_integrations.components.tracers.langfuse import LangfuseConnector

pipeline = AsyncPipeline()

# Add components (simplified example)
pipeline.add_component("tracer", LangfuseConnector(name="Async Pipeline"))
pipeline.add_component("retriever", SomeRetrieverComponent())
pipeline.add_component("generator", SomeGeneratorComponent())

# Define connections
pipeline.connect("retriever", "generator")

# Run the async pipeline
await pipeline.run({"retriever": {"query": "What is Haystack?"}})

Observed Behavior:

  • Multiple traces appear in Langfuse for a single pipeline run.
  • The LangfuseConnector logs a warning about missing parent span context.
  • Lack of unified tracing breaks end-to-end visibility for async workflows.

Expected Behavior:
A single trace should be created and propagated throughout the entire async pipeline execution, just like in the synchronous Pipeline. This would ensure consistent observability and debugging in Langfuse.

Image

Describe your environment (please complete the following information):

  • OS: Linux, WSL
  • haystack-ai==2.12.0
  • langfuse-haystack==0.8.0

Metadata

Metadata

Assignees

Labels

P1bugSomething isn't working

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions