MCPcopy
hub / github.com/redis/redis-py / build_base_attributes

Method build_base_attributes

redis/observability/attributes.py:98–128  ·  view source on GitHub ↗

Build base attributes common to all Redis operations. Args: server_address: Redis server address (FQDN or IP) server_port: Redis server port db_namespace: Redis database index Returns: Dictionary of base attributes

(
        server_address: Optional[str] = None,
        server_port: Optional[int] = None,
        db_namespace: Optional[int] = None,
    )

Source from the content-addressed store, hash-verified

96
97 @staticmethod
98 def build_base_attributes(
99 server_address: Optional[str] = None,
100 server_port: Optional[int] = None,
101 db_namespace: Optional[int] = None,
102 ) -> Dict[str, Any]:
103 """
104 Build base attributes common to all Redis operations.
105
106 Args:
107 server_address: Redis server address (FQDN or IP)
108 server_port: Redis server port
109 db_namespace: Redis database index
110
111 Returns:
112 Dictionary of base attributes
113 """
114 attrs: Dict[str, Any] = {
115 DB_SYSTEM: "redis",
116 REDIS_CLIENT_LIBRARY: f"redis-py:v{redis.__version__}",
117 }
118
119 if server_address is not None:
120 attrs[SERVER_ADDRESS] = server_address
121
122 if server_port is not None:
123 attrs[SERVER_PORT] = server_port
124
125 if db_namespace is not None:
126 attrs[DB_NAMESPACE] = str(db_namespace)
127
128 return attrs
129
130 @staticmethod
131 def build_operation_attributes(

Calls

no outgoing calls

Tested by

no test coverage detected