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

Method build_error_attributes

redis/observability/attributes.py:216–251  ·  view source on GitHub ↗

Build error attributes. Args: is_internal: Whether the error is internal (e.g., timeout, network error) error_type: The exception that occurred Returns: Dictionary of error attributes

(
        error_type: Optional[Exception] = None,
        is_internal: Optional[bool] = None,
    )

Source from the content-addressed store, hash-verified

214
215 @staticmethod
216 def build_error_attributes(
217 error_type: Optional[Exception] = None,
218 is_internal: Optional[bool] = None,
219 ) -> Dict[str, Any]:
220 """
221 Build error attributes.
222
223 Args:
224 is_internal: Whether the error is internal (e.g., timeout, network error)
225 error_type: The exception that occurred
226
227 Returns:
228 Dictionary of error attributes
229 """
230 attrs: Dict[str, Any] = {}
231
232 if error_type is not None:
233 attrs[ERROR_TYPE] = error_type.__class__.__name__
234
235 if (
236 hasattr(error_type, "status_code")
237 and error_type.status_code is not None
238 ):
239 attrs[DB_RESPONSE_STATUS_CODE] = error_type.status_code
240 else:
241 attrs[DB_RESPONSE_STATUS_CODE] = "error"
242
243 if hasattr(error_type, "error_type") and error_type.error_type is not None:
244 attrs[REDIS_CLIENT_ERROR_CATEGORY] = error_type.error_type.value
245 else:
246 attrs[REDIS_CLIENT_ERROR_CATEGORY] = "other"
247
248 if is_internal is not None:
249 attrs[REDIS_CLIENT_ERROR_INTERNAL] = is_internal
250
251 return attrs
252
253 @staticmethod
254 def build_pubsub_message_attributes(

Callers 3

record_error_countMethod · 0.80

Calls

no outgoing calls

Tested by

no test coverage detected