{"slug": "llamaindex-observability-monitoring-with-opentelemetry", "title": "LlamaIndex Observability & Monitoring with OpenTelemetry", "summary": "SigNoz has released a new guide for enabling observability and monitoring in Python-based LlamaIndex applications using OpenTelemetry, allowing developers to trace AI-specific operations such as document ingestion, retrieval, querying, and text generation. The integration, which leverages the OpenInference standard, provides end-to-end visibility into RAG workflows by capturing detailed spans on request durations, model outputs, and retrieval scores, helping teams identify latency bottlenecks and improve production reliability.", "body_md": "Overview\n\nThis guide walks you through enabling observability and monitoring for your Python-based [LlamaIndex](https://www.llamaindex.ai/) application and streaming telemetry data to SigNoz Cloud using OpenTelemetry. By the end of this setup, you'll be able to monitor AI-specific operations such as document ingestion, document retrieval, user querying, text generation, and user feedback within LlamaIndex, with detailed spans capturing request durations, node and query inputs, model outputs, retrieval scores, metadata, and intermediate steps throughout the pipeline.\n\nInstrumenting your RAG workflows with telemetry enables full observability across the retrieval and generation pipeline. This is especially valuable when building production-grade developer-facing tools, where insight into model behavior, latency bottlenecks, and retrieval accuracy is essential. With SigNoz, you can trace each user question end-to-end, from prompt to response, and continuously improve performance and reliability.\n\nTo get started, check out our example LlamaIndex RAG Q&A bot, complete with OpenTelemetry-based monitoring (via OpenInference). View the full repository [here](https://github.com/SigNoz/llamaindex-rag-opentelemetry-demo).\n\nPrerequisites\n\n- A Python application using\n**Python 3.8+** - LlamaIndex integrated into your app, with document ingestion and query interfaces set up\n- Basic understanding of RAG (Retrieval-Augmented Generation) workflows\n- SigNoz setup (choose one):\n[SigNoz Cloud account](https://signoz.io/teams/)with an active ingestion key- Self-hosted SigNoz instance\n\n`pip`\n\ninstalled for managing Python packages- Internet access to send telemetry data to SigNoz Cloud\n*(Optional but recommended)*A Python virtual environment to isolate dependencies\n\nInstrument your LlamaIndex application\n\nTo capture detailed telemetry from LlamaIndex without modifying your core application logic, we use [OpenInference](https://arize.com/docs/ax/learn/tracing-concepts/what-is-openinference), a community-driven standard that provides pre-built instrumentation for popular AI frameworks like LlamaIndex, built on top of OpenTelemetry. This allows you to trace your LlamaIndex application with minimal configuration.\n\nCheck out detailed instructions on how to set up OpenInference instrumentation in your LlamaIndex application over [here](https://pypi.org/project/openinference-instrumentation-llama-index/).\n\nNo-code auto-instrumentation is recommended for quick setup with minimal code changes. It's ideal when you want to get observability up and running without modifying your application code and are leveraging standard instrumentor libraries.\n\n**Step 1:** Install the necessary packages in your Python environment.\n\n```\npip install \\\n  opentelemetry-distro \\\n  opentelemetry-exporter-otlp \\\n  opentelemetry-instrumentation-httpx \\\n  opentelemetry-instrumentation-system-metrics \\\n  llama-index \\\n  openinference-instrumentation-llama-index\n```\n\n**Step 2:** Add Automatic Instrumentation\n\n```\nopentelemetry-bootstrap --action=install\n```\n\n**Step 3:** Configure logging level\n\nTo ensure logs are properly captured and exported, configure the root logger to emit logs at the INFO level or higher:\n\n``` python\nimport logging\n\nlogging.getLogger().setLevel(logging.INFO)\n```\n\nThis sets the minimum log level for the root logger to INFO, which ensures that `logger.info()`\n\ncalls and higher severity logs (WARNING, ERROR, CRITICAL) are captured by the OpenTelemetry logging auto-instrumentation and sent to SigNoz.\n\n**Step 4:** Run an example\n\n``` python\nfrom llama_index.llms.openai import OpenAI\n\nllm = OpenAI(model=\"gpt-4o\")\n\nresponse = llm.complete(\"Hello, world!\")\nprint(response)\n```\n\n📌 Note: Ensure that the\n\n`OPENAI_API_KEY`\n\nenvironment variable is properly defined with your API key before running the code.\n\n**Step 5:** Run your application with auto-instrumentation\n\n```\nOTEL_RESOURCE_ATTRIBUTES=\"service.name=<service_name>\" \\\nOTEL_EXPORTER_OTLP_ENDPOINT=\"https://ingest.<region>.signoz.cloud:443\" \\\nOTEL_EXPORTER_OTLP_HEADERS=\"signoz-ingestion-key=<your-ingestion-key>\" \\\nOTEL_EXPORTER_OTLP_PROTOCOL=grpc \\\nOTEL_TRACES_EXPORTER=otlp \\\nOTEL_METRICS_EXPORTER=otlp \\\nOTEL_LOGS_EXPORTER=otlp \\\nOTEL_PYTHON_LOG_CORRELATION=true \\\nOTEL_PYTHON_LOGGING_AUTO_INSTRUMENTATION_ENABLED=true \\\nopentelemetry-instrument <your_run_command>\n```\n\nis the name of your service`<service_name>`\n\n`<region>`\n\n: Your[SigNoz Cloud region](https://signoz.io/docs/ingestion/signoz-cloud/overview/#endpoint)`<your-ingestion-key>`\n\n: Your SigNoz[ingestion key](https://signoz.io/docs/ingestion/signoz-cloud/keys/)- Replace\n`<your_run_command>`\n\nwith the actual command you would use to run your application. For example:`python main.py`\n\nUsing self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).\n\nCode-based instrumentation gives you fine-grained control over your telemetry configuration. Use this approach when you need to customize resource attributes, sampling strategies, or integrate with existing observability infrastructure.\n\n**Step 1:** Install OpenInference and OpenTelemetry related packages\n\n```\npip install openinference-instrumentation-llama-index \\\nopentelemetry-exporter-otlp \\\nopentelemetry-sdk \\\nllama-index\n```\n\n**Step 2:** Import the necessary modules in your Python application\n\n``` python\nfrom opentelemetry.exporter.otlp.proto.http.trace_exporter import OTLPSpanExporter\nfrom opentelemetry.sdk.trace import TracerProvider\nfrom opentelemetry.sdk.trace.export import BatchSpanProcessor\nfrom opentelemetry.sdk.resources import Resource\nfrom openinference.instrumentation.llama_index import LlamaIndexInstrumentor\n```\n\n**Step 3:** Set up the OpenTelemetry Tracer Provider to send traces directly to SigNoz Cloud\n\n```\nresource = Resource.create({\"service.name\": \"<service_name>\"})\nprovider = TracerProvider(resource=resource)\nspan_exporter = OTLPSpanExporter(\n    endpoint=\"https://ingest.<region>.signoz.cloud:443/v1/traces\",\n    headers={\"signoz-ingestion-key\": \"<your-ingestion-key>\"},\n)\nprovider.add_span_processor(BatchSpanProcessor(span_exporter))\n```\n\nis the name of your service`<service_name>`\n\n: Your SigNoz Cloud`<region>`\n\n**region**: Your SigNoz`<your-ingestion-key>`\n\n**ingestion key**\n\nUsing self-hosted SigNoz? Most steps are identical. To adapt this guide, update the endpoint and remove the ingestion key header as shown in [Cloud → Self-Hosted](https://signoz.io/docs/ingestion/cloud-vs-self-hosted/#cloud-to-self-hosted).\n\n**Step 4:** Instrument LlamaIndex using OpenInference and the configured Tracer Provider\n\nUse the `LlamaIndexInstrumentor`\n\nfrom OpenInference to automatically trace LlamaIndex operations with your OpenTelemetry setup:\n\n```\nLlamaIndexInstrumentor().instrument(tracer_provider=provider)\n```\n\n📌 Important: Place this code at the start of your application logic — before any LlamaIndex functions are called or used — to ensure telemetry is correctly captured.\n\n**Step 5:** Run an example\n\n``` python\nfrom llama_index.llms.openai import OpenAI\n\nllm = OpenAI(model=\"gpt-4o\")\n\nresponse = llm.complete(\"Hello, world!\")\nprint(response)\n```\n\n📌 Note: Ensure that the\n\n`OPENAI_API_KEY`\n\nenvironment variable is properly defined with your API key before running the code.\n\nYour LlamaIndex commands should now automatically emit traces, spans, and attributes.\n\nFinally, you should be able to view this data in Signoz Cloud under the traces tab:\n\nWhen you click on a trace ID in SigNoz, you'll see a detailed view of the trace, including all associated spans, along with their events and attributes.\n\nAdditional Resources\n\n- Read\n[Observing LlamaIndex Apps with OpenTelemetry + SigNoz](https://signoz.io/blog/opentelemetry-llamaindex/) - Set up\n[alerts](https://signoz.io/docs/alerts/)for high latency or error rates - Learn more about\n[querying traces](https://signoz.io/docs/userguide/traces/)", "url": "https://wpnews.pro/news/llamaindex-observability-monitoring-with-opentelemetry", "canonical_source": "https://signoz.io/docs/llamaindex-observability", "published_at": "2026-06-09 00:00:00+00:00", "updated_at": "2026-06-11 19:38:25.199167+00:00", "lang": "en", "topics": ["large-language-models", "generative-ai", "artificial-intelligence", "mlops", "ai-tools"], "entities": ["LlamaIndex", "SigNoz", "OpenTelemetry", "OpenInference", "Python"], "alternates": {"html": "https://wpnews.pro/news/llamaindex-observability-monitoring-with-opentelemetry", "markdown": "https://wpnews.pro/news/llamaindex-observability-monitoring-with-opentelemetry.md", "text": "https://wpnews.pro/news/llamaindex-observability-monitoring-with-opentelemetry.txt", "jsonld": "https://wpnews.pro/news/llamaindex-observability-monitoring-with-opentelemetry.jsonld"}}