OpenTelemetry Instrumentation for Redis
Automatic distributed tracing for Python's redis client, including async and sync APIs
Repository Health
Technical Analysis
opentelemetry-instrumentation-redis automatically instruments the redis Python client so every Redis command (GET, SET, pipelines, pub/sub) creates an OpenTelemetry span, with no changes needed at the call site. It supports both the synchronous redis.StrictRedis client and the async redis.asyncio.Redis client via one RedisInstrumentor().instrument() call, or per-client instrumentation via instrument_client().
Spans include Redis semantic-convention attributes such as the database system, command name, and (optionally) the command arguments, and support request/response hooks for adding custom span attributes around each Redis call.
What You Get
- A
RedisInstrumentorthat instruments all Redis client instances with one.instrument()call - Support for both sync (
redis.StrictRedis) and async (redis.asyncio.Redis) clients - Per-client instrumentation via
instrument_client()for selective tracing - Redis semantic-convention span attributes (db system, command name, and optionally command arguments)
- Request/response hook support for adding custom span attributes around each command
Common Use Cases
- Tracing cache reads/writes in a service that uses Redis as an application cache
- Correlating Redis command latency with the rest of a request’s distributed trace
- Debugging slow or failing Redis pipelines and pub/sub operations with span-level detail
- Auditing Redis command patterns in a service for capacity planning or query optimization
Under The Hood
Architecture — the instrumentor subclasses BaseInstrumentor and wraps the command-execution entry points of both redis.StrictRedis and redis.asyncio.Redis (src/opentelemetry/instrumentation/redis/__init__.py, ~810 lines) so every command dispatched through either client creates a span with database semantic-convention attributes, restoring the original methods on _uninstrument(); a separate instrument_client() path allows instrumenting one client instance rather than patching the client classes globally. Tech Stack — pure Python, depending on opentelemetry-api, opentelemetry-instrumentation, and opentelemetry-semantic-conventions from the same monorepo plus redis as the instrumented target; built with hatchling and versioned in lockstep with the rest of the contrib release train. Code Quality — covered by a single but extensive test_redis.py file (1,751 lines) exercising sync and async clients, pipelines, and hook behavior, reflecting the breadth of the Redis command surface being instrumented. API Design — RedisInstrumentor().instrument() covers the common case in one line for both sync and async clients, while instrument_client() and request/response hooks give finer-grained control without requiring a different instrumentor per client type.
Used by 7 apps in this directory
Baserow
No Code Platforms · Databases
Open-source no-code platform to build databases, apps, automations, and AI agents — self-hosted or cloud, with full data ownership.
Dify
No Code Platforms · AI Development · Developer Tools
Visual LLM workflow platform with RAG pipelines, agent capabilities, and model management for building production AI applications.
highlight.io
Developer Tools · Analytics · Monitoring
Open-source full-stack monitoring that unifies session replay, error tracking, logging, and distributed tracing so you can stop context-switching between tools.
Open WebUI
AI Assistants · AI Agents
The extensible, privacy-first AI platform that runs Ollama, OpenAI, and any LLM backend behind a polished, feature-packed web interface.
PostHog
Analytics · Monitoring · Developer Tools
The all-in-one open source product platform combining analytics, session replay, feature flags, error tracking, AI observability, and a built-in data warehouse in a single self-hostable stack.
SurfSense
Search · AI Assistants
The open-source, unlimited NotebookLM alternative with real-time collaboration, a desktop app, and no vendor lock-in.
Weblate
Developer Tools
Continuous localization platform that commits translations directly into your version control system with full translator attribution.