This library provides OpenTelemetry tracing for applications built with LlamaIndex. It allows developers to observe the full lifecycle of LLM-based applications, including RAG pipelines, agents, and underlying LLM calls, by generating OpenTelemetry-compliant spans. The project is actively maintained with frequent releases, often aligning with the evolving OpenTelemetry GenAI semantic conventions.
pip install opentelemetry-instrumentation-llamaindex llama-index-core openaiVerified import paths — ran on the pinned version, not inferred.
This quickstart demonstrates how to set up OpenTelemetry to collect traces from a LlamaIndex application. It initializes a `TracerProvider` with a `ConsoleSpanExporter` (for easy demonstration), then enables the `LlamaIndexInstrumentor`. A simple LlamaIndex query is performed, and its operations are traced and printed to the console. Remember to install `llama-index-core` and an LLM provider like `openai`.
Review the latest OpenTelemetry GenAI semantic conventions documentation and update any custom dashboards, alerts, or queries that rely on specific span attribute names. You might need to adjust your observability backend's processing rules.
For complete end-to-end tracing of your LLM application, ensure you also install and enable specific OpenTelemetry instrumentations for your LLM providers (e.g., `opentelemetry-instrumentation-openai`) if you interact with them directly.
If data privacy is a concern, consult the OpenTelemetry documentation for how to configure redaction or filtering of sensitive attributes. For `opentelemetry-instrumentation-llamaindex`, check for configuration options to disable or mask specific attribute collection if available, or implement custom `SpanProcessor` logic.
Always ensure your application code initializes and configures the OpenTelemetry SDK components before enabling any instrumentations. Refer to the OpenTelemetry Python SDK documentation for proper setup of `TracerProvider`, `Resource`, `SpanProcessor`, and an appropriate `SpanExporter` (e.g., OTLP, Jaeger, Zipkin).