Haystack

Deepset created Haystack as a modular Python framework for constructing production-grade LLM applications. The architecture supports custom pipeline configurations for retrieval-augmented generation, advanced search systems, and other LLM workflows. Haystack connects with Hugging Face Transformers, Elasticsearch, OpenSearch, OpenAI, Cohere, Anthropic, and numerous other services.

This guide covers capturing telemetry from Haystack applications using InteractiveAI and OpenTelemetry instrumentation.

Prerequisites

  • InteractiveAI account with API credentials

  • OpenAI API key

  • SerperDev API key (for web search functionality)


Installation

pip install haystack-ai interactiveai openinference-instrumentation-haystack

Configuration

Set your API credentials as environment variables:

import os

# InteractiveAI credentials
# Obtain keys from Settings > API Keys in the dashboard
os.environ["INTERACTIVEAI_PUBLIC_KEY"] = "pk-ia-..."
os.environ["INTERACTIVEAI_SECRET_KEY"] = "sk-ia-..."
os.environ["INTERACTIVEAI_HOST"] = "https://app.interactiveai.com"

# Model and tool provider credentials
os.environ["OPENAI_API_KEY"] = "sk-proj-..."
os.environ["SERPERDEV_API_KEY"] = "..."

Initialize the client and confirm connectivity:


Enabling Trace Capture

Haystack has a dedicated OpenInference instrumentor that captures pipeline operations automatically:

Once activated, all pipeline components and model calls generate spans that route to InteractiveAI.


Running a Haystack Application

Here's a working example using an agent with web search capabilities:


Enriching Traces with Context

Combine OpenInference instrumentation with the InteractiveAI SDK to attach identifiers and metadata:


Trace Visibility

The InteractiveAI dashboard displays:

  • Pipeline execution flow and component interactions

  • Model requests with prompts and completions

  • Tool invocations and search results

  • Token consumption and latency for each step

Last updated

Was this helpful?