Overview
OpenTelemetry integration provides:- Distributed Tracing - Track requests across services and workers
- Metrics Collection - Monitor performance, usage, and system health
- Structured Logging - Centralized log aggregation and analysis
- Auto-Instrumentation - Automatic instrumentation of FastAPI, SQLAlchemy, Redis, and HTTP clients
Configuration
Enable OpenTelemetry
Set these environment variables to enable observability:OTLP Exporter Configuration
Configure the OpenTelemetry Protocol (OTLP) endpoint:Transport Protocol
Choose between HTTP and gRPC:Authentication
For authenticated endpoints:Resource Attributes
Add custom resource attributes:Sampling Configuration
Observability Backend Integration
Datadog
New Relic
Honeycomb
Grafana Cloud
Self-Hosted OpenTelemetry Collector
Docker Compose with OpenTelemetry Collector
OpenTelemetry Collector Configuration
otel-collector-config.yaml:
Auto-Instrumented Components
Open WebUI automatically instruments:FastAPI
- HTTP request/response traces
- Endpoint latency metrics
- Error rates and status codes
- Request attributes (method, path, status)
SQLAlchemy
- Database query traces
- Query execution time
- Connection pool metrics
- Database type and operations
Redis
- Redis command traces
- Command execution time
- Connection metrics
- Cache hit/miss rates
HTTP Clients (httpx, aiohttp, requests)
- External API call traces
- Request/response attributes
- Latency and error tracking
Custom Instrumentation
Add custom spans and metrics in your code:Structured Logging
Enable JSON-formatted logs for centralized log aggregation:Metrics
Key metrics collected:-
HTTP Metrics
http.server.duration- Request latencyhttp.server.active_requests- Concurrent requestshttp.server.request.size- Request body sizehttp.server.response.size- Response body size
-
Database Metrics
db.client.connections.usage- Connection pool usagedb.client.operation.duration- Query execution time
-
Redis Metrics
redis.command.duration- Command execution timeredis.connections- Active connections
Troubleshooting
Traces Not Appearing
Check:ENABLE_OTEL=trueandENABLE_OTEL_TRACES=true- Collector endpoint is reachable:
telnet otel-collector 4317 - Check collector logs for connection errors
- Verify authentication credentials
High Overhead
Reduce sampling:Collector Connection Refused
For gRPC:TLS Certificate Errors
Implementation Details
- Telemetry setup:
backend/open_webui/utils/telemetry/setup.py - Metrics configuration:
backend/open_webui/utils/telemetry/metrics.py - Logs configuration:
backend/open_webui/utils/telemetry/logs.py - Auto-instrumentation:
backend/open_webui/utils/telemetry/instrumentors.py - Uses OpenTelemetry SDK 1.39.1 with OTLP exporters
Security Considerations
Next Steps
- Horizontal Scaling - Scale with load balancers and Redis
- RBAC - Monitor user access patterns
- Enterprise Overview - Full enterprise feature set