mirror of
https://github.com/open-webui/open-webui.git
synced 2026-08-30 17:25:30 -05:00
[GH-ISSUE #20655] feat: Add ENABLE_OTEL_REDIS env var to disable Redis instrumentation #34780
Reference in New Issue
Block a user
Originally created by @hcnimi on GitHub (Jan 14, 2026).
Original GitHub issue: https://github.com/open-webui/open-webui/issues/20655
Check Existing Issues
Verify Feature Scope
Problem Description
When ENABLE_OTEL=true, all instrumentors are unconditionally enabled via manual calls in backend/open_webui/utils/telemetry/instrumentors.py:
RedisInstrumentor().instrument(request_hook=redis_request_hook)
SQLAlchemyInstrumentor().instrument(engine=self.db_engine)
... etc
This causes 10,000+ spans per trace in high-traffic deployments, primarily from Redis operations. Each chat message triggers hundreds of Redis calls (session management, websocket coordination, caching), and every call creates a span.
Why this is a problem
Evidence
Datadog APM trace showing ~10k spans, mostly Redis GET/SET operations:
Desired Solution you'd like
Add granular environment variables following the existing pattern:
In env.py
ENABLE_OTEL_REDIS = os.environ.get("ENABLE_OTEL_REDIS", "true").lower() == "true"
ENABLE_OTEL_SQLALCHEMY = os.environ.get("ENABLE_OTEL_SQLALCHEMY", "true").lower() == "true"
ENABLE_OTEL_HTTPX = os.environ.get("ENABLE_OTEL_HTTPX", "true").lower() == "true"
ENABLE_OTEL_REQUESTS = os.environ.get("ENABLE_OTEL_REQUESTS", "true").lower() == "true"
ENABLE_OTEL_AIOHTTP = os.environ.get("ENABLE_OTEL_AIOHTTP", "true").lower() == "true"
ENABLE_OTEL_LOGGING = os.environ.get("ENABLE_OTEL_LOGGING", "true").lower() == "true"
In instrumentors.py
if ENABLE_OTEL_REDIS:
RedisInstrumentor().instrument(request_hook=redis_request_hook)
if ENABLE_OTEL_SQLALCHEMY:
SQLAlchemyInstrumentor().instrument(engine=self.db_engine)
... etc
This follows the existing pattern of ENABLE_OTEL_TRACES, ENABLE_OTEL_METRICS, ENABLE_OTEL_LOGS.
Alternatives Considered
Alternatively, respect the standard OpenTelemetry environment variable OTEL_PYTHON_DISABLED_INSTRUMENTATIONS by checking it before calling each instrumentor.
Environment
Additional Context
No response
@tjbck commented on GitHub (Jan 14, 2026):
PR Welcome.