Skip to main content

Respan instrumentation plugin for LlamaIndex

Project description

respan-instrumentation-llama-index

Respan instrumentation plugin for LlamaIndex. It registers native LlamaIndex instrumentation handlers and emits Respan-compatible OpenTelemetry spans through the Respan tracing pipeline.

Configuration

1. Install

pip install respan-instrumentation-llama-index

2. Set Environment Variables

Variable Required Description
RESPAN_API_KEY Yes Your Respan API key. Authenticates both proxy and tracing.
RESPAN_BASE_URL No Defaults to https://api.respan.ai/api.

All vendor-specific variables are derived from these in your application code.

Quickstart

3. Run Script

import os

from dotenv import load_dotenv
from llama_index.core import Document, SummaryIndex, Settings
from llama_index.llms.openai import OpenAI
from respan import Respan
from respan_instrumentation_llama_index import LlamaIndexInstrumentor

load_dotenv()

respan_api_key = os.environ["RESPAN_API_KEY"]
respan_base_url = os.getenv("RESPAN_BASE_URL", "https://api.respan.ai/api")

os.environ["OPENAI_API_KEY"] = respan_api_key
os.environ["OPENAI_BASE_URL"] = respan_base_url
os.environ["OPENAI_API_BASE"] = respan_base_url

respan = Respan(
    api_key=respan_api_key,
    base_url=respan_base_url,
    app_name="llama-index-quickstart",
    instrumentations=[LlamaIndexInstrumentor()],
)

Settings.llm = OpenAI(
    model="gpt-4o-mini",
    api_key=respan_api_key,
    api_base=respan_base_url,
)
index = SummaryIndex.from_documents(
    [Document(text="Respan captures traces from LlamaIndex applications.")]
)
query_engine = index.as_query_engine()

response = query_engine.query("What does Respan capture?")
print(response)

respan.flush()

4. View Dashboard

After running the script, traces appear on your Respan dashboard.

Further Reading

See the python/tracing/llama-index examples for runnable scripts covering hello world, gateway routing, workflow spans, Respan parameters, and tool use.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

respan_instrumentation_llama_index-0.1.0.tar.gz (10.4 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

File details

Details for the file respan_instrumentation_llama_index-0.1.0.tar.gz.

File metadata

File hashes

Hashes for respan_instrumentation_llama_index-0.1.0.tar.gz
Algorithm Hash digest
SHA256 84da3fd7ae0324622b80835c88a012e742e1c82bcca6f38b8b343890c62c7324
MD5 c2007485570539bbb7e729cdf09ef14c
BLAKE2b-256 7acc886ce762903445a62a6ad94f794cf8a9f3debb865eb1bd702950174a76af

See more details on using hashes here.

File details

Details for the file respan_instrumentation_llama_index-0.1.0-py3-none-any.whl.

File metadata

File hashes

Hashes for respan_instrumentation_llama_index-0.1.0-py3-none-any.whl
Algorithm Hash digest
SHA256 87fed668bdfb03cfd78e780aad244faa17a6191bdb1bbf289827c7a74c0ecc57
MD5 c0668b971a1d802b05e9633ddeadb0cf
BLAKE2b-256 61c48ead95faf6cf4ee72d36434e4939df8ebbd04ed85927834d1ca4a4ec207d

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page