Skip to main content
OpenLLMetry is Traceloop’s open-source set of OpenTelemetry instrumentations for 20+ LLM providers and frameworks. The Traceloop SDK (traceloop-sdk) is the Traceloop.init() wrapper that activates those instrumentations, so this page covers both. The openinference-instrumentation-openllmetry span processor converts OpenLLMetry’s spans to OpenInference semantic conventions before they’re exported to Phoenix.

Install

traceloop-sdk imports httpx without declaring it as a dependency, so install it explicitly.

Setup

Set your API keys as environment variables:
Pass the OpenInference span processor and a Phoenix exporter to Traceloop.init(). The conversion processor must come before the exporting processor:
instrumentation.py
OpenLLMetry instruments every provider it supports the same way. To trace a different provider, swap the OpenAI client below for another supported provider and keep the setup unchanged.
Prefer individual instrumentors to the Traceloop SDK? Install the specific OpenLLMetry instrumentor, such as opentelemetry-instrumentation-openai, and instrument it against a Phoenix tracer provider that has OpenInferenceSpanProcessor() added before the exporter. The conversion step is the same.

Run OpenLLMetry

example.py

Observe

Open the openllmetry project in Phoenix. The trace contains an openai.chat span with its span kind set to LLM, the prompt and response, the model name, and token usage.

Resources