Open Grey-Fox opened 1 month ago
Here's a workaround:
from opentelemetry.instrumentation.redis import (
RedisInstrumentor,
_set_connection_attributes,
)
def _redis_request_hook(span, conn, args, kwargs):
if hasattr(conn, "connection_pool") or not span.is_recording():
return
if hasattr(conn, "nodes_manager"): # means we're working with RedisCluster
_set_connection_attributes(
span, conn.nodes_manager.default_node.redis_connection
)
RedisInstrumentor().instrument(request_hook=_redis_request_hook)
edit: actually you should use the response_hook. Otherwise commands that use a ClusterPipeline (like set_many) will still have missing attributes since the ClusterPipeline.execute_command wrapper doesn't call request_hook.
Spans from redis instrumentation don't contain a lot of attributes, such as "db.system", "net.transport" and so on. It happens because RedisCluster instance doesn't have connection_pool attribute.
Describe your environment Ubuntu 22.04 Python 3.10.13
Packages:
Steps to reproduce
main.py
file:docker-compose.yaml
for Redis Cluster:Run Redis Cluster:
Run
main.py
:What is the expected behavior? There are "db.system" and other attributes in span.
What is the actual behavior?