LiteLLM is a proxy server for LLM traffic. At its core, it manages configurations for several LLM providers and exposes supported models through Anthropic API-compatible or OpenAI API-compatible wrappers. When LLM traffic passes through the proxy server, additional features become available, including rate limiting, budget control, model aliases, intelligent routing, and comprehensive metrics and trace collection.
Part of an ongoing blog series about LiteLLM, this article shows how to tap into its rich observability capabilities. It explains which metrics are recorded, explores traces as fine-grained records of LLM invocations, and shows how to visualize them.
The technical context of this article is LiteLLM v1.94.1, published on 2026-07-31. The setup and configuration examples should also work with newer versions.
The background material for this article comes from the official LiteLLM documentation, specifically the pages on Prometheus metrics and OpenTelemetry v2.
While I am fascinated by the capabilities of artificial intelligence tools and applications, crafting blog articles remains a personal skill. Every character, number, and symbol in this article was typed manually, with the exception of verbatim copies of log messages and screenshots.
Observability Features
LiteLLM’s core observability features fall into two categories: internal metrics collection and instrumentation of LLM traffic with OpenTelemetry. The following sections explore both aspects.
LiteLLM Internal Metrics
The proxy exposes a Prometheus-compatible metrics endpoint that provides several gateway metrics. These can be grouped as follows:
- Health: Availability of the proxy server and model deployments
- Success and error rates: Total number of requests, successful versus failed calls, and error categories
- Latency: Upstream latency when making LLM calls and downstream latency when forwarding results to the requesting client
- Tokens: Fine-grained timing statistics for input and output tokens
- Budgets and rate limits: Remaining amounts, saturation, and accumulation
- Infrastructure: In enterprise-grade deployments, additional metrics about the operational health and performance of connected Redis, PostgreSQL, and other services
OpenTelemetry
The OpenTelemetry standard describes an independent framework for how operational components of a system emit telemetry data and how that data is delivered and propagated to receiving systems. Within this framework, instrumented clients emit signals such as metrics and traces, along with baggage. Following defined semantic conventions and protocols, clients emit signals to collectors, which forward them to backends. The OpenTelemetry standard itself does not provide implementations for specific programming languages (clients), collectors, or backends, with the exception of the OpenTelemetry Collector reference project.
LiteLLM supports OpenTelemetry for recording traces during LLM invocations. When configured, a single client-server request to complete a chat message is broken down into individual processing steps: the HTTP call, LiteLLM authentication, input guardrails, the LLM invocation (treated as a black box), output guardrails, and the response to the client.
Two versions of the OpenTelemetry integration can be enabled: v1 and v2. They differ in trace granularity: in v1, processing steps emit individual traces; in v2, one end-to-end trace is created.
The content of each trace is particularly relevant here. LiteLLM follows the GenAI semantic conventions. Model and agent spans contain attributes such as gen_ai.operation.name, gen_ai.conversation.id, gen_ai.request.model, gen_ai.usage.input_tokens, gen_ai.usage.output_tokens, and gen_ai.output.messages.
Enabling LiteLLM to produce these spans involves two steps. First, the environment variables LITELLM_OTEL_INTEGRATION_ENABLE_METRICS and LITELLM_OTEL_V2 must be set for the proxy process. Second, because OpenTelemetry v2 records only metadata by default, logging of prompts and LLM responses must be enabled explicitly with OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT. When using this in production, check your governance rules for capturing end-user messages in this way.
Callbacks
Callbacks provide a low-level but powerful way to emit logs to external services. Three lifecycle phases can be distinguished:
- Input: The LiteLLM proxy receives an input message and applies its guardrails; the callback runs immediately before the configured LLM provider is called
- Success: The callback runs when the LLM provider’s response arrives with an HTTP status code indicating success, before guardrails sanitize the output
- Failure: The callback runs when the LLM provider’s response arrives with an HTTP status code indicating failure
For each lifecycle phase, you can register a callback that does one of the following:
- References a built-in integration, such as
langfuse - Executes a custom Python function that receives the event log object and implements arbitrary data-handling logic
- Executes a custom Python instance of the built-in
CustomLoggerclass, which exposes framework-related logic
Set Up OpenTelemetry Tracing
To set up and view GenAI traces with LiteLLM, use the following components:
- Trace backend: Several tracing backends are available, including Grafana Tempo from the Grafana ecosystem, which supports multiple open-source tracing protocols, including OpenTelemetry
- Trace visualization: While specialized systems such as Langfuse provide rich visualizations, this article uses a simple proof of concept with Grafana dashboards to display trace information
With the application stack defined, follow these steps.
Configure Grafana Tempo
tempo:
image: grafana/tempo:3.0.3
container_name: tempo
command: ["-config.file=/etc/tempo.yaml"]
ports:
- "3200:3200" # Tempo query API
- "4317:4317" # OTLP gRPC (traces)
- "4318:4318" # OTLP HTTP (traces)
volumes:
- ./config/tempo.yaml:/etc/tempo.yaml
- tempo_data:/var/tempo
...
volumes:
tempo_data:
name: litellm_tempo_data
Use the following configuration file:
# tempo.yaml
server:
http_listen_port: 3200
distributor:
receivers:
otlp:
protocols:
grpc:
endpoint: 0.0.0.0:4317
http:
endpoint: 0.0.0.0:4318
storage:
trace:
backend: local
wal:
path: /var/tempo/wal
local:
path: /var/tempo/blocks
Configure Grafana
Set up a Grafana instance:
grafana:
image: grafana/grafana:13.2.2
container_name: grafana
ports:
- "3000:3000"
environment:
- GF_SECURITY_ADMIN_PASSWORD=admin
volumes:
- grafana-data:/var/lib/grafana
- ./grafana-datasources.yaml:/etc/grafana/provisioning/datasources/datasources.yaml:ro
depends_on:
- tempo
- prometheus
Use the following configuration file:
apiVersion: 1
datasources:
- name: tempo
type: tempo
access: proxy
url: http://tempo:3200
isDefault: false
editable: true
jsonData:
httpMethod: GET
tracesToLogs:
datasourceUid: ""
serviceMap:
datasourceUid: "prometheus"
- name: prometheus
type: prometheus
access: proxy
url: http://prometheus:9090
isDefault: true
editable: true
jsonData:
timeInterval: "15s"
httpMethod: POST
Update the Prometheus Scrape Configuration
Extend the Prometheus configuration to scrape metrics from these services:
scrape_configs:
# ...
- job_name: "prometheus"
static_configs:
- targets: ["localhost:9090"]
- job_name: "tempo"
static_configs:
- targets: ["tempo:3200"]
Configure LiteLLM
To expose the /metrics endpoint, add the following to the LiteLLM configuration file:
litellm_settings:
success_callback:
- prometheus
require_auth_for_metrics_endpoint: false
To emit traces and configure the destination endpoint, add the following environment variables to the LiteLLM stack:
LITELLM_OTEL_V2: "true"
LITELLM_OTEL_INTEGRATION_ENABLE_METRICS: "true"
OTEL_EXPORTER_OTLP_ENDPOINT: http://0.0.0.0:4317
OTEL_EXPORTER_OTLP_PROTOCOL: grpc
OTEL_INSTRUMENTATION_GENAI_CAPTURE_MESSAGE_CONTENT: span_and_event
OTEL_RESOURCE_ATTRIBUTES: deployment.environment=production
OTEL_SERVICE_NAME: litellm-proxy
Restart the LiteLLM container to apply these changes.
Visualize Metrics and Traces
To check the setup, inspect the log files of the respective services. The following excerpt shows Tempo query activity:
tempo | level=info ts=2026-09-27T10:19:00.448124174Z caller=metrics_query_range_handler.go:236 msg="query range response" tenant=single-tenant traceID= query="{nestedSetParent<0 && true} | histogram_over_time(duration) with(sample=true)" range_nanos=1800000000000 max_series=0 duration_seconds=0.00372407 request_throughput=0 total_requests=1 total_blockBytes=0 total_blocks=0 completed_requests=1 inspected_bytes=0 inspected_traces=0 inspected_spans=0 partial_status=COMPLETE partial_message= num_response_series=0 error=null
tempo | level=info ts=2026-09-27T10:19:00.448220925Z caller=metrics_query_range_handler.go:236 msg="query range response" tenant=single-tenant traceID= query="{nestedSetParent<0 && true && status=error} | rate() with(sample=true)" range_nanos=1792000000000 max_series=0 duration_seconds=0.005468544 request_throughput=0 total_requests=1 total_blockBytes=0 total_blocks=0 completed_requests=1 inspected_bytes=0 inspected_traces=0 inspected_spans=0 partial_status=COMPLETE partial_message= num_response_series=0 error=null
tempo | level=info ts=2026-09-27T10:19:00.448261473Z caller=handler.go:135 msg="query stats" tenant=single-tenant method=GET traceID= url="/api/metrics/query_range?start=1790502504000000000&end=1790504296000000000&step=28s&mode=&blockID=&startPage=0&pagesToSearch=0&version=&encoding=none&size=0&footerSize=0&q=%7BnestedSetParent%3C0+%26%26+true+%26%26+status%3Derror%7D+%7C+rate%28%29++with%28sample%3Dtrue%29&exemplars=100&maxSeries=0&instant=false" duration=5.509188ms response_size=57 status=200
tempo | level=info ts=2026-09-27T10:19:00.448250595Z caller=handler.go:135 msg="query stats" tenant=single-tenant method=GET traceID= url="/api/metrics/query_range?start=1790502450000000000&end=1790504250000000000&step=1m15s&mode=&blockID=&startPage=0&pagesToSearch=0&version=&encoding=none&size=0&footerSize=0&q=%7BnestedSetParent%3C0+%26%26+true%7D+%7C+histogram_over_time%28duration%29+with%28sample%3Dtrue%29&exemplars=100&maxSeries=0&instant=false" duration=3.851807ms response_size=57 status=200
To view metrics:
- Open the main menu and click “Drilldown”
- Select the “Metrics” tile
- In the dashboard, select the “prometheus” data source

To view trace information:
- Open the main menu and click “Drilldown”
- Select the “Traces” tile
- In the dashboard, select the “tempo” data source
Here is the resulting page:

Conclusion
LiteLLM is a proxy server for LLM traffic, enabling gathering rich metrics and traces about LLM invocation. In this introductionary article, you learned a) which internal metrics LiteLLM provides, b) what the OpenTelemetry standard encompasesse, c) how LiteLLM callbacks allow fine-granulary, customized logging, and d) how to setup a docker compose stack to run LiteLLM, capture metrics with prometheus, traces with Grafa Tempo, and visualize them with Grafana.