Skip to content

Commit 2fc938a

Browse files
fix: BaseApiTracer to noop on attemptFailed via overloaded method call (#3016)
Fixes #3015 Fixes #3014 Gax tracing internally works with `attemptFailedDuration`, which defaults to a no-op. Downstream libraries use `attemptFailed`, which has a custom behavior. What happens when an attempt-failed event occurs is that `attemptFailedDuration` is called instead (in favor of using java.time methods internally). This fix makes `attemptFailedDuration`'s behavior to delegate the logic to `attemptFailed`. The downstreams will keep failing because the repos haven't got adapted to the new change in gax. See the follow ups below. ### Fixes in `java-spanner` ![image](https://github.com/googleapis/sdk-platform-java/assets/22083784/85e50341-fe8b-46c8-9743-8de1ca300058) ### Fixes in `java-bigtable` ![image](https://github.com/googleapis/sdk-platform-java/assets/22083784/026af401-1607-4465-abd5-1ee5ddc353d0) ### Follow ups in `java-bigtable` More failures in java-bigtable to be addressed in that repo: ``` Error: BigtableTableAdminSettingsTest.testToString:175 expected to contain: totalTimeout=PT13H32M but was : BigtableTableAdminSettings{projectId=our-project-85, instanceId=our-instance-06, ... ``` Fixed in googleapis/java-bigtable#2274 ### Follow ups in `java-spanner` ``` Error: Failures: Error: CompositeTracerTest.testMethodsOverrideMetricsTracer:238 Method not found in compositeTracerMethods: public void com.google.api.gax.tracing.MetricsTracer.attemptFailedDuration(java.lang.Throwable,java.time.Duration) ``` Fixed in googleapis/java-spanner#3200
1 parent 99bb2b3 commit 2fc938a

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

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

+5-2
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

@@ -105,15 +107,16 @@ public void attemptCancelled() {
105107

106108
@Override
107109
public void attemptFailedDuration(Throwable error, java.time.Duration delay) {
108-
// noop
110+
// noop via attemptFailed(Throwable error, org.threeten.Duration)
111+
attemptFailed(error, toThreetenDuration(delay));
109112
}
110113

111114
/**
112115
* This method is obsolete. Use {@link #attemptFailedDuration(Throwable, java.time.Duration)}
113116
* instead.
114117
*/
115118
@Override
116-
@ObsoleteApi("Use attemptFailed(Throwable, java.time.Duration) instead")
119+
@ObsoleteApi("Use attemptFailedDuration(Throwable, java.time.Duration) instead")
117120
public void attemptFailed(Throwable error, org.threeten.bp.Duration delay) {
118121
// noop
119122
}

0 commit comments

Comments
 (0)