Registry /
observability / opentelemetry-instrumentation-redis
Install & Compatibility
Where this runs
tested against v0.65b0 · pip install
no network on importno background threads
Install × environment matrix
Each cell = how many times install + import succeeded across repeated harness runs. Partial = flaky.
glibc = Debian/Ubuntu slim · musl = Alpine Linux
muslpy 3.10–3.95 runs
installs and imports cleanly · install 0.0s · import 0.614s · 27.8MB
glibcpy 3.10–3.95 runs
installs and imports cleanly · install 3.0s · import 0.552s · 28MB
26MB installed
● package 26MB
Code
Verified usage
Verified import paths — ran on the pinned version, not inferred.
RedisInstrumentor
✓ from opentelemetry.instrumentation.redis import RedisInstrumentor
suppress_instrumentation
✓ from opentelemetry.instrumentation.utils import suppress_instrumentation
Used to temporarily disable instrumentation for specific code blocks.
This quickstart demonstrates how to set up OpenTelemetry with the Redis instrumentation. It configures a simple `TracerProvider` with a `ConsoleSpanExporter` (for demonstration purposes), then enables Redis instrumentation globally using `RedisInstrumentor().instrument()`. Any subsequent Redis client operations will generate spans. Ensure a Redis server is running at `localhost:6379` or configure environment variables `REDIS_HOST` and `REDIS_PORT`.
import os
from opentelemetry import trace
from opentelemetry.sdk.resources import Resource, SERVICE_NAME
from opentelemetry.sdk.trace import TracerProvider
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter
from opentelemetry.instrumentation.redis import RedisInstrumentor
import redis
# 1. Configure OpenTelemetry TracerProvider
resource = Resource.create({"service.name": os.environ.get('OTEL_SERVICE_NAME', 'redis-app')})
tracer_provider = TracerProvider(resource=resource)
tracer_provider.add_span_processor(
BatchSpanProcessor(ConsoleSpanExporter())
)
trace.set_tracer_provider(tracer_provider)
# 2. Instrument Redis
RedisInstrumentor().instrument()
# 3. Use Redis client (operations will be traced)
try:
client = redis.StrictRedis(host=os.environ.get('REDIS_HOST', 'localhost'), port=int(os.environ.get('REDIS_PORT', 6379)), db=0)
client.ping()
print("Successfully connected to Redis.")
client.set("mykey", "myvalue")
value = client.get("mykey")
print(f"Retrieved from Redis: {value.decode('utf-8')}")
client.delete("mykey")
except redis.exceptions.ConnectionError as e:
print(f"Could not connect to Redis: {e}. Please ensure Redis is running.")
# Example of suppressing instrumentation for a specific call
# from opentelemetry.instrumentation.utils import suppress_instrumentation
# with suppress_instrumentation():
# client.get("untraced-key")
opentelemetry-instrument --version
Debug
Known issues
betaThis instrumentation library is currently in beta. The API and behavior may change in future versions, and it should generally not be used in production environments without careful consideration.fixMonitor `opentelemetry-python-contrib` releases for stable versions and breaking changes. Review your code when upgrading to newer beta versions.
affects: All versions up to 0.61b0
gotchaBy default, `RedisInstrumentor().instrument()` instruments *all* `redis` client instances created *after* the `instrument()` call. If you only want to instrument specific Redis clients, use `RedisInstrumentor().instrument_client(client_instance)` instead.fixFor granular control, explicitly call `instrument_client()` on the desired `redis.Redis` or `redis.StrictRedis` objects. Alternatively, use `suppress_instrumentation()` for operations that should not be traced.
affects: All versions
gotchaThe instrumentation records Redis commands in the `db.statement` attribute. While efforts are made to obfuscate sensitive arguments by default, be cautious about logging or exposing this attribute, especially if sensitive data could be part of Redis commands.fixReview the configuration options for `db.statement` serialization (if available, consult documentation for specific options) or implement custom hooks to further filter or mask sensitive data before it's recorded in spans.
affects: All versions
gotchaOpenTelemetry auto-instrumentation adds performance overhead. While generally optimized, it's crucial to benchmark your application with instrumentation enabled to understand its impact on CPU and memory usage, especially in high-throughput scenarios.fixRegularly benchmark your application with and without OpenTelemetry instrumentation. Use sampling strategies to reduce the volume of traces if overhead is a concern.
affects: All versions
breakingOpenTelemetry SDK and API packages are not installed or are not discoverable. This error typically occurs when `opentelemetry-api` and `opentelemetry-sdk` are missing from the environment, which are essential for any OpenTelemetry application.fixEnsure that `opentelemetry-api` and `opentelemetry-sdk` are installed in your environment. For example, run `pip install opentelemetry-api opentelemetry-sdk` or include them in your project's dependency management file.
affects: All versions
breakingThe application failed to run due to a `ModuleNotFoundError` for `opentelemetry.sdk`. This indicates that the core OpenTelemetry SDK package was not installed or is not accessible in the environment. All OpenTelemetry applications require the `opentelemetry-sdk` package for basic functionality.fixEnsure that `opentelemetry-sdk` is explicitly installed in your environment (e.g., `pip install opentelemetry-sdk`) or that your dependency management correctly includes it. Verify that all necessary OpenTelemetry core and instrumentation packages are present.
affects: All versions
Upgrade
Version history
0.65b0latest on PyPI · released Jul 16, 2026
Audit
Dependencies
redisrequiredThis instrumentation library wraps the `redis` Python client, so `redis` must be installed separately.
opentelemetry-apirequiredCore OpenTelemetry API for defining telemetry.
opentelemetry-sdkrequiredOpenTelemetry SDK for processing and exporting telemetry.