LlamaIndex (tracing)
LlamaIndex (tracing)
LlamaIndex is a framework for building LLM applications with your own data. It provides indexes, query engines, retrievers, and agents for retrieval-augmented generation. Respan captures LlamaIndex spans through respan-tracing, including index construction, retrieval, LLM calls, embeddings, and agent tool use.
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 LlamaIndex gateway setup to route this integration through the Respan gateway.
Example projects
- Example repo root:
respan-example-projects/python/tracing/llama-index
Setup
Set environment variables
OPENAI_API_KEY is used for the LlamaIndex OpenAI LLM. RESPAN_API_KEY exports traces to Respan.
View your trace
Open the Traces page to see your workflow with index, retrieval, LLM, embedding, and tool spans.
Configuration
Attributes
In Respan()
Set defaults at initialization. These apply to all spans emitted by the LlamaIndex instrumentor.
With propagate_attributes
Override per request using a context scope.
Decorators (optional)
Decorators are not required for LlamaIndex instrumentation. Query engines, retrievers, agents, tools, embeddings, and LLM calls are captured by LlamaIndexInstrumentor. Use @workflow and @task when you want to group several LlamaIndex operations into one named trace tree.
Examples
Query engine
Query engines are captured with nested retriever, synthesizer, and LLM spans.
Embeddings
Embedding calls are captured as embedding logs. Vector values are summarized instead of recording the full embedding array.
Tool-use agent
LlamaIndex ReAct agents emit agent, tool, and LLM spans in the same trace tree.