Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

OpenTelemetry LlamaIndex Instrumentation

pypi

This package contains OpenTelemetry instrumentation for LlamaIndex.

It emits invoke_workflow spans for AgentWorkflow runs, invoke_agent spans for standalone and workflow-member FunctionAgent and ReActAgent executions, and execute_tool spans when LlamaIndex executes tools. It also emits retrieval spans for synchronous and asynchronous BaseRetriever operations. Model calls delegated to provider SDKs are intentionally left to those SDKs’ OpenTelemetry instrumentations.

Installation

pip install opentelemetry-instrumentation-genai-llama-index

Usage

from opentelemetry.instrumentation.genai.llama_index import (
    LlamaIndexInstrumentor,
)

LlamaIndexInstrumentor().instrument()

How instrumentation works

The instrumentor registers a LlamaIndex span handler with its dispatcher. The handler observes LlamaIndex-owned operations and delegates span creation and completion to opentelemetry-util-genai. Provider model calls are left to the provider’s instrumentation, so they can be composed without duplicate inference spans.

flowchart TD
    A[LlamaIndexInstrumentor.instrument] --> B[LlamaIndex dispatcher]
    B --> C{Span callback}
    C -->|AgentWorkflow.run| D[workflow invocation]
    C -->|BaseWorkflowAgent.run / run_agent_step| E[agent invocation]
    C -->|call_tool / FunctionTool.call| F[tool invocation]
    C -->|BaseRetriever.retrieve / aretrieve| G[retrieval invocation]
    D --> H[TelemetryHandler.workflow]
    E --> I[TelemetryHandler.invoke_local_agent]
    F --> J[TelemetryHandler.tool]
    G --> K[TelemetryHandler.retrieval]
    H --> L[Start OTel span]
    I --> L
    J --> L
    K --> L
    L --> M[Dispatcher exit or error callback]
    M --> N[Set attributes and stop/fail invocation]
    P[Provider SDK instrumentation] -. model calls .-> Q[inference spans]

Configuration

Content capture is controlled through the OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT environment variable. Supported values are NO_CONTENT, SPAN_ONLY, EVENT_ONLY, and SPAN_AND_EVENT.

Prompts and completions can also be redirected via a completion hook by setting OTEL_INSTRUMENTATION_GENAI_COMPLETION_HOOK=upload together with OTEL_INSTRUMENTATION_GENAI_UPLOAD_BASE_PATH, or by passing a custom hook directly with instrument(completion_hook=...). See examples/manual/custom_hook.py for a programmatic example.

References

Release files for opentelemetry-instrumentation-genai-llama-index 1.2b0

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for opentelemetry-instrumentation-genai-llama-index 1.2b0
File Size Uploaded
opentelemetry_instrumentation_genai_llama_index-1.2b0.tar.gz 37.3 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for opentelemetry-instrumentation-genai-llama-index 1.2b0
File Interpreter ABI Platform
opentelemetry_instrumentation_genai_llama_index-1.2b0-py3-none-any.whl Python 3 none any Details

Total release size: 57.4 kB

Release files / opentelemetry_instrumentation_genai_llama_index-1.2b0.tar.gz

Download URL opentelemetry_instrumentation_genai_llama_index-1.2b0.tar.gz
Size 37.3 kB
Tags Source
SHA-256 checksum
How to use checksums
cfadd5428f4dee30f3788470c4667f28dc2d8c93cfd0e2df5795c7e06270c7fe
BLAKE2b-256 checksum
How to use checksums
602e149aac8e68e1d097241db2bd8419c01d95cfd5037a3367bb368469658f76
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release files / opentelemetry_instrumentation_genai_llama_index-1.2b0-py3-none-any.whl

Download URL opentelemetry_instrumentation_genai_llama_index-1.2b0-py3-none-any.whl
Size 20.2 kB
Tags Python 3
SHA-256 checksum
How to use checksums
58f65d29492f7d55c05c06db1264ec5f912bf45438cf57d45ae38286f25ae849
BLAKE2b-256 checksum
How to use checksums
a58cd5f9922d7c44fba27004b02a4afa3ce7793cb9fda1670b442509cfb5389e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 24, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

1.2b0 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page