From b738de55a29bf48ab4ac66540effdeb690cf4c32 Mon Sep 17 00:00:00 2001 From: Diego Marquez Date: Tue, 9 Jul 2024 16:56:28 -0400 Subject: [PATCH] chore: move the `attemptFailed` logic from BaseApiTracer to ApiTracer (#3037) Follow up of https://github.com/googleapis/sdk-platform-java/pull/3016 On `bigtable` and `spanner`: ![image](https://github.com/googleapis/sdk-platform-java/assets/22083784/696c0cec-e83b-4563-a9fe-7f6a249f7bc6) ![image](https://github.com/googleapis/sdk-platform-java/assets/22083784/6170cb3b-2e18-478c-b1ff-9cef5f869dd0) Thanks @blakeli0 and @lqiu96 for the directions. --- .../java/com/google/api/gax/tracing/ApiTracer.java | 10 +++++++++- .../java/com/google/api/gax/tracing/BaseApiTracer.java | 8 -------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracer.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracer.java index 4407f79a85..6755575080 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracer.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracer.java @@ -29,6 +29,8 @@ */ package com.google.api.gax.tracing; +import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; + import com.google.api.core.InternalApi; import com.google.api.core.ObsoleteApi; @@ -121,7 +123,13 @@ default Scope inScope() { * @param error the transient error that caused the attempt to fail. * @param delay the amount of time to wait before the next attempt will start. */ - default void attemptFailedDuration(Throwable error, java.time.Duration delay) {}; + default void attemptFailedDuration(Throwable error, java.time.Duration delay) { + // Defaults to do the same as attemptFailed(Throwable, org.threeten.bp.Duration). This + // is because customers may have older/legacy code that directly implements + // attemptFailed(Throwable, org.threeten.bp.Duration)} and their overridden logic should be + // invoked in gax. + attemptFailed(error, toThreetenDuration(delay)); + }; /** * Adds an annotation that the attempt failed and that no further attempts will be made because diff --git a/gax-java/gax/src/main/java/com/google/api/gax/tracing/BaseApiTracer.java b/gax-java/gax/src/main/java/com/google/api/gax/tracing/BaseApiTracer.java index 8feb1286d2..cffa4c744e 100644 --- a/gax-java/gax/src/main/java/com/google/api/gax/tracing/BaseApiTracer.java +++ b/gax-java/gax/src/main/java/com/google/api/gax/tracing/BaseApiTracer.java @@ -29,8 +29,6 @@ */ package com.google.api.gax.tracing; -import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration; - import com.google.api.core.InternalApi; import com.google.api.core.ObsoleteApi; @@ -105,12 +103,6 @@ public void attemptCancelled() { // noop } - @Override - public void attemptFailedDuration(Throwable error, java.time.Duration delay) { - // noop via attemptFailed(Throwable error, org.threeten.Duration) - attemptFailed(error, toThreetenDuration(delay)); - } - /** * This method is obsolete. Use {@link #attemptFailedDuration(Throwable, java.time.Duration)} * instead.