File tree Expand file tree Collapse file tree 2 files changed +11
-11
lines changed
sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing Expand file tree Collapse file tree 2 files changed +11
-11
lines changed Original file line number Diff line number Diff line change @@ -50,7 +50,7 @@ final class ObservabilityUtils {
5050 */
5151 static String extractErrorType (@ Nullable Throwable error ) {
5252 return ErrorTypeUtil .extractErrorType (error );
53- }
53+ }
5454
5555 /** Function to extract the status of the error as a canonical code. */
5656 static StatusCode .Code extractStatus (@ Nullable Throwable error ) {
Original file line number Diff line number Diff line change @@ -208,6 +208,13 @@ private void recordErrorAndEndAttempt(Throwable error) {
208208 attemptSpan .setAttribute (
209209 ObservabilityAttributes .ERROR_TYPE_ATTRIBUTE , ObservabilityUtils .extractErrorType (error ));
210210
211+ Map <String , Object > statusAttributes = new HashMap <>();
212+ ObservabilityUtils .populateStatusAttributes (
213+ statusAttributes , error , this .apiTracerContext .transport ());
214+ if (!statusAttributes .isEmpty ()) {
215+ attemptSpan .setAllAttributes (ObservabilityUtils .toOtelAttributes (statusAttributes ));
216+ }
217+
211218 if (error == null ) {
212219 endAttempt ();
213220 return ;
@@ -221,20 +228,13 @@ private void recordErrorAndEndAttempt(Throwable error) {
221228 ObservabilityAttributes .STATUS_MESSAGE_ATTRIBUTE , error .getMessage ());
222229 }
223230
224- Map <String , Object > endAttributes = new HashMap <>();
225- ObservabilityUtils .populateStatusAttributes (
226- endAttributes , error , this .apiTracerContext .transport ());
227- if (!endAttributes .isEmpty ()) {
228- attemptSpan .setAllAttributes (ObservabilityUtils .toOtelAttributes (endAttributes ));
229- }
230-
231231 endAttempt ();
232232 }
233233
234234 private void endAttempt () {
235- if (attemptSpan == null ) {
236- return ;
237- }
235+ if (attemptSpan == null ) {
236+ return ;
237+ }
238238
239239 attemptSpan .end ();
240240 attemptSpan = null ;
You can’t perform that action at this time.
0 commit comments