Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit b738de5

Browse files
chore: move the attemptFailed logic from BaseApiTracer to ApiTracer (#3037)
Follow up of #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.
1 parent e8deeaf commit b738de5

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

gax-java/gax/src/main/java/com/google/api/gax/tracing/ApiTracer.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,8 @@
2929
*/
3030
package com.google.api.gax.tracing;
3131

32+
import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration;
33+
3234
import com.google.api.core.InternalApi;
3335
import com.google.api.core.ObsoleteApi;
3436

@@ -121,7 +123,13 @@ default Scope inScope() {
121123
* @param error the transient error that caused the attempt to fail.
122124
* @param delay the amount of time to wait before the next attempt will start.
123125
*/
124-
default void attemptFailedDuration(Throwable error, java.time.Duration delay) {};
126+
default void attemptFailedDuration(Throwable error, java.time.Duration delay) {
127+
// Defaults to do the same as attemptFailed(Throwable, org.threeten.bp.Duration). This
128+
// is because customers may have older/legacy code that directly implements
129+
// attemptFailed(Throwable, org.threeten.bp.Duration)} and their overridden logic should be
130+
// invoked in gax.
131+
attemptFailed(error, toThreetenDuration(delay));
132+
};
125133

126134
/**
127135
* Adds an annotation that the attempt failed and that no further attempts will be made because

gax-java/gax/src/main/java/com/google/api/gax/tracing/BaseApiTracer.java

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,6 @@
2929
*/
3030
package com.google.api.gax.tracing;
3131

32-
import static com.google.api.gax.util.TimeConversionUtils.toThreetenDuration;
33-
3432
import com.google.api.core.InternalApi;
3533
import com.google.api.core.ObsoleteApi;
3634

@@ -105,12 +103,6 @@ public void attemptCancelled() {
105103
// noop
106104
}
107105

108-
@Override
109-
public void attemptFailedDuration(Throwable error, java.time.Duration delay) {
110-
// noop via attemptFailed(Throwable error, org.threeten.Duration)
111-
attemptFailed(error, toThreetenDuration(delay));
112-
}
113-
114106
/**
115107
* This method is obsolete. Use {@link #attemptFailedDuration(Throwable, java.time.Duration)}
116108
* instead.

0 commit comments

Comments
 (0)