Haystack (tracing)
Haystack (tracing)
Haystack is a Python framework for building production-ready LLM pipelines with retrieval, generation, routing, and evaluation components. Respan traces Haystack runs with respan-instrumentation-haystack, which activates the OpenInference Haystack instrumentor and exports pipeline, component, and LLM spans through the Respan tracing pipeline.
Set up Respan
Create an account at platform.respan.ai and grab an API key.
Run npx @respan/cli setup to set up with your coding agent.
Use Respan Gateway
See Haystack gateway setup to route this integration through the Respan gateway.
Example projects
Setup
Set environment variables
OPENAI_API_KEY is used by Haystack’s OpenAI component. RESPAN_API_KEY exports traces to Respan. HAYSTACK_CONTENT_TRACING_ENABLED lets Haystack include prompt and response content in spans.
View your trace
Open the Traces page to see your pipeline run with pipeline spans, component spans, LLM calls, and inputs/outputs.
Configuration
HaystackInstrumentor(**kwargs) passes keyword arguments through to the underlying OpenInference Haystack instrumentor.
Attributes
In Respan()
Set defaults at initialization. These apply to all spans.
With propagate_attributes
Override per-request using a context scope.
Decorators (optional)
Decorators are not required. Pipeline runs, components, and LLM calls are auto-traced by the instrumentor. Use @workflow and @task when you want to group multiple Haystack runs or add application-level steps around a pipeline.
Examples
RAG pipeline
Retrieval and generation components are captured as separate spans.