Skip to main content

Install

Instrument

instrument_haystack wraps a single Pipeline instance. Call it after the pipeline is built, before run().

What gets captured

  • A pipeline root span around every Pipeline.run() call, with data as input and the final result dict as output.
  • One child span per component in the pipeline (retrievers, generators, rankers, converters) with that component’s input and output attached.
  • Generator components’ LLM calls appear as llm spans with token counts and model metadata.

Known gotchas

  • Haystack v2 only. The legacy Haystack v1 API (BaseComponent) is not supported.
  • Component names matter. Span names come from the name passed to pipe.add_component(...) — use descriptive names (retriever, reranker) to make the waterfall readable.
  • run_async works. The async pipeline path is instrumented via the same function — one call covers both.