Package com.google.api.gax.tracing
Class ErrorTypeUtil
java.lang.Object
com.google.api.gax.tracing.ErrorTypeUtil
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic StringextractErrorType(Throwable error) Extracts a low-cardinality string representing the specific classification of the error to be used in theObservabilityAttributes.ERROR_TYPE_ATTRIBUTEattribute.
-
Constructor Details
-
ErrorTypeUtil
public ErrorTypeUtil()
-
-
Method Details
-
extractErrorType
Extracts a low-cardinality string representing the specific classification of the error to be used in theObservabilityAttributes.ERROR_TYPE_ATTRIBUTEattribute.This value is determined based on the following priority:
google.rpc.ErrorInfo.reason: If the error response from the service includesgoogle.rpc.ErrorInfodetails, the reason field (e.g., "RATE_LIMIT_EXCEEDED", "SERVICE_DISABLED") will be used. This offers the most precise error cause.- Specific Server Error Code: If no
ErrorInfo.reasonis available and it is not a client-side failure, but a server error code was received:- For HTTP: The HTTP status code (e.g., "403", "503").
- For gRPC: The gRPC status code name (e.g., "PERMISSION_DENIED", "UNAVAILABLE").
- Client-Side Network/Operational Errors: For errors occurring within the client
library or network stack, mapping to specific enum representations from
ErrorTypeUtil.ErrorType. This includes checking the exception for diagnostic markers (e.g.,ConnectExceptionorSocketTimeoutException). - Language-specific error type: The class or struct name of the exception or error
if available. This must be low-cardinality, meaning it returns the short name of the
exception class (e.g.
"IllegalStateException") rather than its message. - Internal Fallback: If the error doesn't fit any of the above categories,
"INTERNAL"will be used, indicating an unexpected issue within the client library's own logic.
- Parameters:
error- the Throwable from which to extract the error type string.- Returns:
- a low-cardinality string representing the specific error type
-