Skip to content

Commit f347a28

Browse files
committed
test: fix tests
1 parent 92fe20c commit f347a28

File tree

2 files changed

+11
-11
lines changed

2 files changed

+11
-11
lines changed

sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/ObservabilityUtils.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff 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) {

sdk-platform-java/gax-java/gax/src/main/java/com/google/api/gax/tracing/SpanTracer.java

Lines changed: 10 additions & 10 deletions
Original file line numberDiff line numberDiff 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;

0 commit comments

Comments
 (0)