OpenTelemetry Valkey Instrumentation
raw JSON → 0.62b0 verified Mon Apr 27 auth: no python
Auto-instrumentation for Valkey (a Redis-compatible key-value store) via OpenTelemetry. Currently at version 0.62b0, released as part of the opentelemetry-python-contrib-external repository. Follows OpenTelemetry semantic conventions; compatible with Python >=3.9.
pip install opentelemetry-python-contrib-external-valkey Common errors
error No module named 'opentelemetry.instrumentation.valkey' ↓
cause Package not installed or wrong import path.
fix
Install with: pip install opentelemetry-python-contrib-external-valkey, then correct import to: from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
error ModuleNotFoundError: No module named 'valkey' ↓
cause Valkey client library not installed.
fix
Install valkey client: pip install valkey
error ValkeyInstrumentor not instrumenting calls ↓
cause Instrumentation was applied after creating the client instance.
fix
Move ValkeyInstrumentor().instrument() before any Valkey client instantiation.
Warnings
gotcha Ensure that the `valkey` Python client is installed separately; this package only provides instrumentation. ↓
fix pip install valkey
gotcha Instrumentation must be applied before creating any Valkey client instances to capture all spans. ↓
fix Call instrument() before instantiating client
deprecated The import path opentelemetry.contrib.valkey was deprecated in favor of opentelemetry.instrumentation.valkey. ↓
fix Use from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
Install
pip install opentelemetry-distro opentelemetry-exporter-otlp Imports
- ValkeyInstrumentor wrong
from opentelemetry.contrib.valkey import ValkeyInstrumentorcorrectfrom opentelemetry.instrumentation.valkey import ValkeyInstrumentor
Quickstart
from opentelemetry.instrumentation.valkey import ValkeyInstrumentor
from valkey import Valkey
# Instrument Valkey automatically
ValkeyInstrumentor().instrument()
# Create a Valkey client
client = Valkey(host='localhost', port=6379, db=0)
client.set('key', 'value')
print(client.get('key'))