> ## Documentation Index
> Fetch the complete documentation index at: https://docs.honeyhive.ai/llms.txt
> Use this file to discover all available pages before exploring further.

# How to trace LlamaIndex with HoneyHive

> Trace LlamaIndex query engines, retrieval, embeddings, and agents with HoneyHive. Add four lines of setup and use OpenInference to capture RAG workflows.

To trace LlamaIndex with HoneyHive, install `honeyhive`, `openinference-instrumentation-llama-index`, and `llama-index`, call `HoneyHiveTracer.init()`, run `LlamaIndexInstrumentor().instrument(tracer_provider=tracer.provider)`, and use your existing LlamaIndex code unchanged. See the [tracing quickstart](/v2/introduction/tracing-quickstart) and [tracer initialization](/v2/tracing/tracer-initialization) guides for setup details.

[LlamaIndex](https://docs.llamaindex.ai/) is a data framework for building LLM applications with retrieval-augmented generation (RAG), agents, and structured data extraction. It provides query engines, retrievers, and composable pipelines. HoneyHive integrates with LlamaIndex via the OpenInference instrumentor, automatically capturing query engine operations, LLM calls, retrieval, embeddings, and more.

## How do I trace LlamaIndex with HoneyHive?

<Tip>
  To see where to initialize the tracer for your environment, including AWS Lambda and long-running servers, see [Tracer Initialization](/v2/tracing/tracer-initialization).
</Tip>

```bash theme={null}
uv pip install honeyhive openinference-instrumentation-llama-index llama-index
```

```python theme={null}
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.llama_index import LlamaIndexInstrumentor

tracer = HoneyHiveTracer.init(api_key=os.getenv("HH_API_KEY"))
LlamaIndexInstrumentor().instrument(tracer_provider=tracer.provider)
```

Set `HH_API_KEY`. The example below also needs `OPENAI_API_KEY`.

## RAG example

Create a small source file before running the example:

```bash theme={null}
echo "Key finding: HoneyHive traces LlamaIndex query engines." > data.txt
```

```python theme={null}
import os
from honeyhive import HoneyHiveTracer
from openinference.instrumentation.llama_index import LlamaIndexInstrumentor
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader, Settings
from llama_index.embeddings.openai import OpenAIEmbedding
from llama_index.llms.openai import OpenAI

tracer = HoneyHiveTracer.init(api_key=os.getenv("HH_API_KEY"))
LlamaIndexInstrumentor().instrument(tracer_provider=tracer.provider)

Settings.llm = OpenAI(model="gpt-4o-mini")
Settings.embed_model = OpenAIEmbedding(model="text-embedding-3-small")

documents = SimpleDirectoryReader(input_files=["data.txt"]).load_data()
index = VectorStoreIndex.from_documents(documents)

query_engine = index.as_query_engine()
response = query_engine.query("What are the key findings?")
print(response)
```

HoneyHive shows the query engine call, embedding calls, retrieval with document nodes, and LLM synthesis.

***

## Troubleshooting

### Traces not appearing

* Call `instrument()` before creating LlamaIndex indexes, retrievers, or query engines.
* Pass `tracer_provider=tracer.provider`, especially if your app uses multiple OpenTelemetry providers or instrumentors.
* Confirm `HH_API_KEY` is set. For OpenAI-backed examples, confirm `OPENAI_API_KEY` is set.

***

## Resources

* [OpenInference LlamaIndex Instrumentor](https://github.com/Arize-ai/openinference/tree/main/python/instrumentation/openinference-instrumentation-llama-index)
* [LlamaIndex Documentation](https://docs.llamaindex.ai/)
