File tree Expand file tree Collapse file tree 1 file changed +17
-12
lines changed
sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing Expand file tree Collapse file tree 1 file changed +17
-12
lines changed Original file line number Diff line number Diff line change @@ -200,22 +200,27 @@ public void attemptPermanentFailure(Throwable error) {
200200 }
201201
202202 private void recordErrorAndEndAttempt (Throwable error ) {
203- if (attemptSpan != null ) {
204- attemptSpan .setAttribute (
205- ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE , ObservabilityUtils .extractErrorType (error ));
206-
207- if (error != null ) {
208- attemptSpan .setAttribute (
209- ObservabilityAttributes .EXCEPTION_TYPE_ATTRIBUTE , error .getClass ().getName ());
203+ if (attemptSpan == null ) {
204+ return ;
205+ }
210206
211- String errorMessage = extractErrorMessage (error );
212- if (errorMessage != null ) {
213- attemptSpan .setAttribute (ObservabilityAttributes .STATUS_MESSAGE_ATTRIBUTE , errorMessage );
214- }
215- }
207+ attemptSpan .setAttribute (
208+ ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE , ObservabilityUtils .extractErrorType (error ));
216209
210+ if (error == null ) {
217211 endAttempt ();
212+ return ;
218213 }
214+
215+ attemptSpan .setAttribute (
216+ ObservabilityAttributes .EXCEPTION_TYPE_ATTRIBUTE , error .getClass ().getName ());
217+
218+ if (!Strings .isNullOrEmpty (error .getMessage ())) {
219+ attemptSpan .setAttribute (
220+ ObservabilityAttributes .STATUS_MESSAGE_ATTRIBUTE , error .getMessage ());
221+ }
222+
223+ endAttempt ();
219224 }
220225
221226 private String extractErrorMessage (Throwable error ) {
You can’t perform that action at this time.
0 commit comments