LlamaIndex
Retrievers, query engines, and chat engines produce a span tree with retrieval and LLM children.
Install the instrumentor alongside llama-index and every retriever, query, and chat call inside wrap your agent emits spans. LlamaIndex is Python-first; a Node instrumentor (@opentelemetry/instrumentation-llamaindex) is also available.
What's captured
| Construct | Span kind | Auto-extracted |
|---|---|---|
VectorIndexRetriever.retrieve | retrieval | query, doc count, doc ids |
QueryEngine.query | agent | wraps retrieval + synthesis |
ChatEngine.chat | agent | wraps retrieval + LLM + memory |
ResponseSynthesizer | llm | model, tokens |
| Embeddings | llm | model, tokens |
Install
pip install llama-index opentelemetry-instrumentation-llamaindexMinimal example — RAG query
import os, trodo
from llama_index.core import VectorStoreIndex, SimpleDirectoryReader
trodo.init(site_id=os.environ['TRODO_SITE_ID'])
documents = SimpleDirectoryReader('./docs').load_data()
index = VectorStoreIndex.from_documents(documents)
query_engine = index.as_query_engine()
with trodo.wrap_agent('llamaindex-rag') as run:
run.set_input({'q': 'What is HNSW?'})
response = query_engine.query('What is HNSW?')
run.set_output(str(response))The resulting tree nests retrieval and the LLM synthesis under one agent span:
run (wrap_agent)
└─ agent QueryEngine.query
├─ retrieval VectorIndexRetriever.retrieve
└─ llm ResponseSynthesizer (gpt-4o-mini)For multi-turn chat engines, pass conversation_id to wrap_agent to stitch turns into a conversation.