DocumentationAPI Reference📓 Tutorials🧑‍🍳 Cookbook🤝 Integrations💜 Discord🎨 Studio
Documentation

Debugging Pipelines

Learn how to debug and troubleshoot your Haystack pipelines.

There are several options available to you to debug your pipelines:

Inspecting Component Outputs

To see the outputs of specific components in your pipeline, include the include_outputs_from parameter during execution. Set this parameter to the component names whose outputs you want to be included in the pipeline's result.

For example, here’s how you can print the output of PromptBuilder in this pipeline:

from haystack import Pipeline, Document
from haystack.utils import Secret
from haystack.components.generators import OpenAIGenerator
from haystack.components.builders.prompt_builder import PromptBuilder

documents = [Document(content="Joe lives in Berlin"), Document(content="Joe is a software engineer")]
prompt_template = """
    Given these documents, answer the question.\\nDocuments:
    {% for doc in documents %}
        {{ doc.content }}
    {% endfor %}

    \\nQuestion: {{query}}
    \\nAnswer:
    """

p = Pipeline()
p.add_component(instance=PromptBuilder(template=prompt_template), name="prompt_builder")
p.add_component(instance=OpenAIGenerator(api_key=Secret.from_env_var("OPENAI_API_KEY")), name="llm")
p.connect("prompt_builder", "llm")

question = "Where does Joe live?"

# We are adding `include_outputs_from` here to view the prompt template created by PromptBuilder
result = p.run({"prompt_builder": {"documents": documents, "query": question}},
               include_outputs_from={"prompt_builder"})

print(result)

Logging

Adjust the logging format according to your debugging needs. See our Logging documentation for details.

Real-Time Pipeline Logging

Use Haystack's LoggingTracer logs to inspect the data that's flowing through your pipeline in real-time.

This feature is particularly helpful during experimentation and prototyping, as you don’t need to set up any tracing backend beforehand.

Here’s how you can enable this tracer. In this example, we are adding color tags (this is optional) to highlight the components' names and inputs:

import logging
from haystack import tracing
from haystack.tracing.logging_tracer import LoggingTracer

logging.basicConfig(format="%(levelname)s - %(name)s -  %(message)s", level=logging.WARNING)
logging.getLogger("haystack").setLevel(logging.DEBUG)

tracing.tracer.is_content_tracing_enabled = True # to enable tracing/logging content (inputs/outputs)
tracing.enable_tracing(LoggingTracer(tags_color_strings={"haystack.component.input": "\x1b[1;31m", "haystack.component.name": "\x1b[1;34m"}))

Here’s what the resulting log would look like when a pipeline is run:

Tracing

To get a bigger picture of the pipeline’s performance, try tracing it with Langfuse.

Our Tracing page has more about other tracing solutions for Haystack.

Monitoring Tools

Take a look at available tracing and monitoring integrations for Haystack pipelines, such as Arize AI or Arize Phoenix.