Technology
OpenLLMetry
OpenTelemetry-native observability for LLM applications with automatic instrumentation for all major AI providers
Overview
OpenLLMetry
OpenLLMetry is a lightweight, open-source OpenTelemetry-based observability SDK for LLM applications. Developed by Traceloop, it provides automatic instrumentation for various LLM providers (OpenAI, Anthropic, Cohere, and more), vector databases, and frameworks with minimal configuration.
OpenLLMetry automatically captures key metrics like latency, token usage, costs, and full prompt/response pairs without requiring manual span creation or extensive code changes. It's designed to work seamlessly with the OpenTelemetry ecosystem, making it easy to integrate with existing observability platforms like Dash0.
Use Cases
- Monitor LLM API calls across multiple providers (Anthropic, OpenAI, Cohere) with automatic instrumentation
- Track token usage and costs for every LLM request to understand resource consumption and optimize spending
- Analyze latency patterns to identify performance bottlenecks in AI-powered applications
- Capture full conversation context including prompts, responses, and model parameters for debugging and quality assurance
- Correlate LLM calls with application traces to understand how AI interactions affect overall system performance
- Monitor vector database operations (Pinecone, Chroma, Weaviate) alongside LLM calls for RAG applications
- Track streaming responses with automatic instrumentation for streaming API calls
- Measure model performance across different providers and models to optimize selection
Setup
Overview
OpenLLMetry (Traceloop SDK) provides automatic OpenTelemetry instrumentation for LLM applications. It automatically detects and instruments LLM provider SDKs (like Anthropic, OpenAI), vector databases, and AI frameworks without requiring manual span creation.
This guide shows how to set up OpenLLMetry to send traces to Dash0 via the OpenTelemetry Protocol (OTLP).
Prerequisites
- Python 3.9 or higher
- An LLM provider SDK installed (e.g.,
anthropic,openai,cohere) - An OpenTelemetry Collector endpoint (Dash0 ingress or local collector)
- Dash0 authentication token
Installation
Install OpenLLMetry (Traceloop SDK) alongside your LLM provider SDK:
pip install traceloop-sdk anthropicOr for other providers:
pip install traceloop-sdk openai # OpenAI
pip install traceloop-sdk cohere # Cohere
pip install traceloop-sdk langchain # LangChainConfiguration
Option 1: Via OpenTelemetry Collector (Recommended)
For production deployments, route traces through an OpenTelemetry Collector:
from traceloop.sdk import Traceloop
Traceloop.init(
app_name="your-app-name",
api_endpoint="http://otel-collector:4318",
disable_batch=False,
)The collector will forward traces to Dash0. For collector setup, see:
Option 2: Direct to Dash0
For simpler setups, send traces directly to Dash0:
from traceloop.sdk import Traceloop
Traceloop.init(
app_name="your-app-name",
api_endpoint="https://{{endpoint_otlp_http_hostname}}:{{endpoint_otlp_http_port}}",
headers={
"Authorization": "Bearer {{token}}",
"Dash0-Dataset": "{{dataset}}",
},
disable_batch=False,
)Using OpenLLMetry in Your Application
Once initialized, OpenLLMetry automatically instruments all supported LLM calls:
from anthropic import Anthropic
# No additional instrumentation needed!
client = Anthropic(api_key="your-api-key")
response = client.messages.create(
model="claude-sonnet-4-20250514",
max_tokens=1024,
messages=[
{"role": "user", "content": "What is OpenTelemetry?"}
]
)Configuration Options
Privacy and Security
Control what data is captured in traces:
Traceloop.init(
app_name="your-app-name",
disable_batch=False,
# Privacy options
should_enrich_metrics=True, # Include token usage metrics
trace_content=True, # Capture prompts/responses (default: True)
# Set to False to exclude prompt/response content from traces
)Verification
After running your application with OpenLLMetry:
- Navigate to Traces in your Dash0 dashboard
- Filter by
service.namematching yourapp_name - Look for traces with spans containing
gen_ai.*attributes - Verify that LLM calls show:
- Complete timing information
- Token usage metrics
- Model and provider details
- Prompt and response content (if enabled)
Supported Libraries
For the latest list of supported integrations, see the OpenLLMetry documentation.