File tree Expand file tree Collapse file tree 3 files changed +7
-10
lines changed
sdk-platform-java/gax-java/gax/src
main/java/com/google/api/gax/tracing
test/java/com/google/api/gax/tracing Expand file tree Collapse file tree 3 files changed +7
-10
lines changed Original file line number Diff line number Diff line change @@ -119,12 +119,12 @@ enum ErrorType {
119119 // Requirement source: go/clo:product-requirements-v1
120120 public static String extractErrorType (@ Nullable Throwable error ) {
121121 if (error == null ) {
122- // No information about the error; we default to INTERNAL .
123- return ErrorType . INTERNAL . toString () ;
122+ // No information about the error; This attribute should not be recorded .
123+ return null ;
124124 }
125125
126126 // 1. Unwrap standard wrapper exceptions if present
127- Throwable realError = getRealCause (error );
127+ Throwable realError = unwrapError (error );
128128
129129 // 2. Attempt to extract specific error type from the main exception
130130 String specificError = extractSpecificErrorType (realError );
@@ -143,7 +143,7 @@ public static String extractErrorType(@Nullable Throwable error) {
143143 }
144144
145145 /** Unwraps standard execution wrappers to find the real cause. */
146- private static Throwable getRealCause (Throwable t ) {
146+ private static Throwable unwrapError (Throwable t ) {
147147 if (t .getCause () == null ) {
148148 return t ;
149149 }
Original file line number Diff line number Diff line change @@ -54,8 +54,7 @@ class ErrorTypeUtilTest {
5454
5555 @ Test
5656 void testExtractErrorType_null () {
57- assertThat (ErrorTypeUtil .extractErrorType (null ))
58- .isEqualTo (ErrorTypeUtil .ErrorType .INTERNAL .toString ());
57+ assertThat (ErrorTypeUtil .extractErrorType (null )).isNull ();
5958 }
6059
6160 @ Test
Original file line number Diff line number Diff line change @@ -439,10 +439,8 @@ void testAttemptFailed_internalFallback_nullError() {
439439 // For an anonymous inner class Throwable, getSimpleName() is empty string,
440440 // which triggers the
441441 // fallback
442- verify (span )
443- .setAttribute (
444- ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE ,
445- ErrorTypeUtil .ErrorType .INTERNAL .toString ());
442+ verify (span , never ())
443+ .setAttribute (eq (ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE ), anyString ());
446444 verify (span ).end ();
447445 }
448446
You can’t perform that action at this time.
0 commit comments