Send LlamaIndex Traces to KloudMate
The OpenInference instrumentation for LlamaIndex creates a span for each agent run, model call, embedding, and tool call. Send those spans to KloudMate to see each run in AI Observability.
Use OpenInference rather than LlamaIndex’s own llama-index-observability-otel package. Its spans don’t use the GenAI attribute names, so model calls and tokens don’t appear in AI Observability.
Prerequisites
Section titled “Prerequisites”- A KloudMate API key, from Settings → Ingest Keys.
- Python 3.10 or later.
Instrument your app
Section titled “Instrument your app”Install the instrumentation and the OpenTelemetry launcher:
Point the exporter at KloudMate and start your app with opentelemetry-instrument, which loads the LlamaIndex instrumentation automatically:
Install the instrumentation and the OpenTelemetry SDK:
Set up a tracer provider and instrument LlamaIndex at startup:
OTLPSpanExporter() reads the endpoint and header from the same OTEL_EXPORTER_OTLP_* variables shown in the other tab. Call provider.shutdown() before a script exits, so the last spans are sent.
KloudMate expects the raw API key in the Authorization header, with no Bearer prefix. If the KloudMate agent runs on the same machine, set the endpoint to http://localhost:4318 and leave out the header.
Group a conversation
Section titled “Group a conversation”Wrap each call in using_session() with an ID that stays the same for the whole conversation:
Control what’s captured
Section titled “Control what’s captured”OpenInference records prompts, responses, and retrieved documents by default. To leave out inputs and outputs, set these variables before your app starts:
Token counts, models, and latency are still recorded. The OpenInference configuration lists the finer-grained settings, such as OPENINFERENCE_HIDE_RETRIEVAL_DOCUMENTS.
Check the data
Section titled “Check the data”Run a query once, then open AI Observability → Traces. The run appears with its model calls, tokens, and estimated cost.