From 433c431daa1fa56fabf683a35247407b73a5920e Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 14:01:10 -0400 Subject: [PATCH 1/7] Add retry metrics tests to ITOtelGoldenMetrics --- .../v1beta1/it/ITOtelGoldenMetrics.java | 301 ++++++++++++++++++ .../it/util/TestClientInitializer.java | 86 +++++ 2 files changed, 387 insertions(+) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index 70f86141f6c5..4658c6479bd6 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -379,4 +379,305 @@ public String getHeaderValue(int index) { .isEqualTo("503"); } } + + @Test + void testMetrics_zeroDeadline_grpc() throws Exception { + GoldenSignalsMetricsTracerFactory tracerFactory = + new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); + + // Using 1ms as 0ms might be rejected by some validation or trigger immediate failure before + // metrics + RetrySettings zeroRetrySettings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setTotalTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setMaxAttempts(1) + .build(); + + try (EchoClient client = + TestClientInitializer.createGrpcEchoClientOpentelemetryWithRetrySettings( + tracerFactory, zeroRetrySettings)) { + + assertThrows( + Exception.class, + () -> client.echo(EchoRequest.newBuilder().setContent("metrics-test").build())); + + Thread.sleep(100); + Collection metrics = metricReader.collectAllMetrics(); + assertThat(metrics).isNotEmpty(); + + MetricData durationMetric = + metrics.stream() + .filter(m -> m.getName().equals("gcp.client.request.duration")) + .findFirst() + .orElseThrow(() -> new AssertionError("Duration metric not found")); + + io.opentelemetry.api.common.Attributes attributes = + durationMetric.getHistogramData().getPoints().iterator().next().getAttributes(); + + assertThat( + attributes.get( + AttributeKey.stringKey(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE))) + .isEqualTo("DEADLINE_EXCEEDED"); + assertThat( + attributes.get(AttributeKey.stringKey(ObservabilityAttributes.ERROR_TYPE_ATTRIBUTE))) + .isEqualTo("DEADLINE_EXCEEDED"); + } + } + + @Test + void testMetrics_zeroDeadline_httpjson() throws Exception { + GoldenSignalsMetricsTracerFactory tracerFactory = + new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); + + RetrySettings zeroRetrySettings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setTotalTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setMaxAttempts(1) + .build(); + + try (EchoClient client = + TestClientInitializer.createHttpJsonEchoClientOpentelemetryWithRetrySettings( + tracerFactory, zeroRetrySettings)) { + + assertThrows( + Exception.class, + () -> client.echo(EchoRequest.newBuilder().setContent("metrics-test").build())); + + Thread.sleep(100); + Collection metrics = metricReader.collectAllMetrics(); + assertThat(metrics).isNotEmpty(); + + MetricData durationMetric = + metrics.stream() + .filter(m -> m.getName().equals("gcp.client.request.duration")) + .findFirst() + .orElseThrow(() -> new AssertionError("Duration metric not found")); + + io.opentelemetry.api.common.Attributes attributes = + durationMetric.getHistogramData().getPoints().iterator().next().getAttributes(); + + assertThat( + attributes.get( + AttributeKey.stringKey(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE))) + .isEqualTo("DEADLINE_EXCEEDED"); + assertThat( + attributes.get(AttributeKey.stringKey(ObservabilityAttributes.ERROR_TYPE_ATTRIBUTE))) + .isEqualTo("504"); + } + } + + @Test + void testMetrics_retryAndSucceed_grpc() throws Exception { + GoldenSignalsMetricsTracerFactory tracerFactory = + new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); + + RetrySettings retrySettings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setTotalTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setMaxAttempts(3) + .build(); + + java.util.concurrent.atomic.AtomicInteger attemptCount = new java.util.concurrent.atomic.AtomicInteger(0); + + ClientInterceptor interceptor = + new ClientInterceptor() { + @Override + public ClientCall interceptCall( + MethodDescriptor method, CallOptions callOptions, Channel next) { + int attempt = attemptCount.incrementAndGet(); + if (attempt <= 2) { + return new ClientCall() { + @Override + public void start(Listener responseListener, Metadata headers) { + responseListener.onClose(io.grpc.Status.UNAVAILABLE, new Metadata()); + } + + @Override + public void request(int numMessages) {} + + @Override + public void cancel(String message, Throwable cause) {} + + @Override + public void halfClose() {} + + @Override + public void sendMessage(ReqT message) {} + }; + } else { + return next.interceptCall(method, callOptions); + } + } + }; + + java.util.Set retryableCodes = java.util.Collections.singleton(StatusCode.Code.UNAVAILABLE); + + try (EchoClient client = + TestClientInitializer.createGrpcEchoClientOpentelemetry( + tracerFactory, retrySettings, retryableCodes, ImmutableList.of(interceptor))) { + + client.echo(EchoRequest.newBuilder().setContent("metrics-test").build()); + + assertThat(attemptCount.get()).isEqualTo(3); + + Thread.sleep(100); + Collection metrics = metricReader.collectAllMetrics(); + assertThat(metrics).hasSize(1); + + MetricData durationMetric = + metrics.stream() + .filter(m -> m.getName().equals("gcp.client.request.duration")) + .findFirst() + .orElseThrow(() -> new AssertionError("Duration metric not found")); + + assertThat(durationMetric.getHistogramData().getPoints()).hasSize(1); + + io.opentelemetry.api.common.Attributes attributes = + durationMetric.getHistogramData().getPoints().iterator().next().getAttributes(); + + assertThat( + attributes.get( + AttributeKey.stringKey(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE))) + .isEqualTo("OK"); + } + } + + @Test + void testMetrics_retryAndSucceed_httpjson() throws Exception { + GoldenSignalsMetricsTracerFactory tracerFactory = + new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); + + RetrySettings retrySettings = + RetrySettings.newBuilder() + .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setTotalTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setMaxAttempts(3) + .build(); + + java.util.concurrent.atomic.AtomicInteger requestCount = new java.util.concurrent.atomic.AtomicInteger(0); + + HttpTransport mockTransport = + new HttpTransport() { + @Override + protected com.google.api.client.http.LowLevelHttpRequest buildRequest( + String method, String url) { + int currentCount = requestCount.incrementAndGet(); + return new com.google.api.client.http.LowLevelHttpRequest() { + @Override + public void addHeader(String name, String value) {} + + @Override + public com.google.api.client.http.LowLevelHttpResponse execute() { + if (currentCount <= 2) { + return new com.google.api.client.http.LowLevelHttpResponse() { + @Override + public InputStream getContent() { + return new ByteArrayInputStream("{}".getBytes()); + } + + @Override + public String getContentEncoding() { return null; } + + @Override + public long getContentLength() { return 2; } + + @Override + public String getContentType() { return "application/json"; } + + @Override + public String getStatusLine() { return "HTTP/1.1 503 Service Unavailable"; } + + @Override + public int getStatusCode() { return 503; } + + @Override + public String getReasonPhrase() { return "Service Unavailable"; } + + @Override + public int getHeaderCount() { return 0; } + + @Override + public String getHeaderName(int index) { return null; } + + @Override + public String getHeaderValue(int index) { return null; } + }; + } else { + return new com.google.api.client.http.LowLevelHttpResponse() { + @Override + public InputStream getContent() { + return new ByteArrayInputStream("{\"content\":\"metrics-test\"}".getBytes()); + } + + @Override + public String getContentEncoding() { return null; } + + @Override + public long getContentLength() { return 24; } + + @Override + public String getContentType() { return "application/json"; } + + @Override + public String getStatusLine() { return "HTTP/1.1 200 OK"; } + + @Override + public int getStatusCode() { return 200; } + + @Override + public String getReasonPhrase() { return "OK"; } + + @Override + public int getHeaderCount() { return 0; } + + @Override + public String getHeaderName(int index) { return null; } + + @Override + public String getHeaderValue(int index) { return null; } + }; + } + } + }; + } + }; + + java.util.Set retryableCodes = java.util.Collections.singleton(StatusCode.Code.UNAVAILABLE); + + try (EchoClient client = + TestClientInitializer.createHttpJsonEchoClientOpentelemetry( + tracerFactory, retrySettings, retryableCodes, mockTransport)) { + + client.echo(EchoRequest.newBuilder().setContent("metrics-test").build()); + + assertThat(requestCount.get()).isEqualTo(3); + + Thread.sleep(100); + Collection metrics = metricReader.collectAllMetrics(); + assertThat(metrics).hasSize(1); + + MetricData durationMetric = + metrics.stream() + .filter(m -> m.getName().equals("gcp.client.request.duration")) + .findFirst() + .orElseThrow(() -> new AssertionError("Duration metric not found")); + + assertThat(durationMetric.getHistogramData().getPoints()).hasSize(1); + + io.opentelemetry.api.common.Attributes attributes = + durationMetric.getHistogramData().getPoints().iterator().next().getAttributes(); + + assertThat( + attributes.get( + AttributeKey.stringKey(ObservabilityAttributes.RPC_RESPONSE_STATUS_ATTRIBUTE))) + .isEqualTo("OK"); + } + } } diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java index 5aeb4d40655c..3f3b54553ce8 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/util/TestClientInitializer.java @@ -329,6 +329,92 @@ public static EchoClient createHttpJsonEchoClientOpentelemetry( return EchoClient.create(createStubWithServiceName(httpJsonEchoSettings, metricsTracerFactory)); } + public static EchoClient createGrpcEchoClientOpentelemetryWithRetrySettings( + ApiTracerFactory metricsTracerFactory, RetrySettings retrySettings) throws Exception { + EchoStubSettings.Builder grpcEchoSettingsBuilder = EchoStubSettings.newBuilder(); + grpcEchoSettingsBuilder.echoSettings().setRetrySettings(retrySettings); + EchoSettings grpcEchoSettings = EchoSettings.create(grpcEchoSettingsBuilder.build()); + grpcEchoSettings = + grpcEchoSettings.toBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .build()) + .setEndpoint(DEFAULT_GRPC_ENDPOINT) + .build(); + + return EchoClient.create(createStubWithServiceName(grpcEchoSettings, metricsTracerFactory)); + } + + public static EchoClient createHttpJsonEchoClientOpentelemetryWithRetrySettings( + ApiTracerFactory metricsTracerFactory, RetrySettings retrySettings) throws Exception { + EchoStubSettings.Builder httpJsonEchoSettingsBuilder = EchoStubSettings.newHttpJsonBuilder(); + httpJsonEchoSettingsBuilder.echoSettings().setRetrySettings(retrySettings); + EchoSettings httpJsonEchoSettings = EchoSettings.create(httpJsonEchoSettingsBuilder.build()); + httpJsonEchoSettings = + httpJsonEchoSettings.toBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + EchoSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport( + new NetHttpTransport.Builder().doNotValidateCertificate().build()) + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) + .build()) + .build(); + + return EchoClient.create(createStubWithServiceName(httpJsonEchoSettings, metricsTracerFactory)); + } + + public static EchoClient createGrpcEchoClientOpentelemetry( + ApiTracerFactory metricsTracerFactory, + RetrySettings retrySettings, + Set retryableCodes, + List interceptorList) throws Exception { + EchoStubSettings.Builder grpcEchoSettingsBuilder = EchoStubSettings.newBuilder(); + grpcEchoSettingsBuilder + .echoSettings() + .setRetrySettings(retrySettings) + .setRetryableCodes(retryableCodes); + EchoSettings grpcEchoSettings = EchoSettings.create(grpcEchoSettingsBuilder.build()); + grpcEchoSettings = + grpcEchoSettings.toBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + EchoSettings.defaultGrpcTransportProviderBuilder() + .setChannelConfigurator(ManagedChannelBuilder::usePlaintext) + .setInterceptorProvider(() -> interceptorList) + .build()) + .setEndpoint(DEFAULT_GRPC_ENDPOINT) + .build(); + + return EchoClient.create(createStubWithServiceName(grpcEchoSettings, metricsTracerFactory)); + } + + public static EchoClient createHttpJsonEchoClientOpentelemetry( + ApiTracerFactory metricsTracerFactory, + RetrySettings retrySettings, + Set retryableCodes, + com.google.api.client.http.HttpTransport transport) throws Exception { + EchoStubSettings.Builder httpJsonEchoSettingsBuilder = EchoStubSettings.newHttpJsonBuilder(); + httpJsonEchoSettingsBuilder + .echoSettings() + .setRetrySettings(retrySettings) + .setRetryableCodes(retryableCodes); + EchoSettings httpJsonEchoSettings = EchoSettings.create(httpJsonEchoSettingsBuilder.build()); + httpJsonEchoSettings = + httpJsonEchoSettings.toBuilder() + .setCredentialsProvider(NoCredentialsProvider.create()) + .setTransportChannelProvider( + EchoSettings.defaultHttpJsonTransportProviderBuilder() + .setHttpTransport(transport) + .setEndpoint(DEFAULT_HTTPJSON_ENDPOINT) + .build()) + .build(); + + return EchoClient.create(createStubWithServiceName(httpJsonEchoSettings, metricsTracerFactory)); + } + public static IdentityClient createGrpcIdentityClientOpentelemetry(ApiTracerFactory tracerFactory) throws Exception { IdentitySettings grpcIdentitySettings = From 7ec89f7e4887ea30b38eaa852750929f623fe55b Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 14:54:09 -0400 Subject: [PATCH 2/7] tests: resolve comments --- .../com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index 4658c6479bd6..26bae58a87c0 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -31,10 +31,12 @@ package com.google.showcase.v1beta1.it; import static com.google.common.truth.Truth.assertThat; +import static java.nio.charset.StandardCharsets.UTF_8; import static org.junit.Assert.assertThrows; import com.google.api.client.http.HttpTransport; import com.google.api.gax.core.NoCredentialsProvider; +import com.google.api.gax.retrying.RetrySettings; import com.google.api.gax.rpc.StatusCode; import com.google.api.gax.rpc.TransportChannelProvider; import com.google.api.gax.rpc.UnavailableException; @@ -579,7 +581,7 @@ public com.google.api.client.http.LowLevelHttpResponse execute() { return new com.google.api.client.http.LowLevelHttpResponse() { @Override public InputStream getContent() { - return new ByteArrayInputStream("{}".getBytes()); + return new ByteArrayInputStream("{}".getBytes(UTF_8)); } @Override @@ -613,7 +615,7 @@ public InputStream getContent() { return new com.google.api.client.http.LowLevelHttpResponse() { @Override public InputStream getContent() { - return new ByteArrayInputStream("{\"content\":\"metrics-test\"}".getBytes()); + return new ByteArrayInputStream("{\"content\":\"metrics-test\"}".getBytes(UTF_8)); } @Override From 4ecfe55fba0e7654d1b6df1df62276383e288ebc Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 15:23:00 -0400 Subject: [PATCH 3/7] tests: fix errors. --- .../v1beta1/it/ITOtelGoldenMetrics.java | 21 +++++++++---------- 1 file changed, 10 insertions(+), 11 deletions(-) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index 26bae58a87c0..dd156be30314 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -30,10 +30,6 @@ package com.google.showcase.v1beta1.it; -import static com.google.common.truth.Truth.assertThat; -import static java.nio.charset.StandardCharsets.UTF_8; -import static org.junit.Assert.assertThrows; - import com.google.api.client.http.HttpTransport; import com.google.api.gax.core.NoCredentialsProvider; import com.google.api.gax.retrying.RetrySettings; @@ -43,10 +39,8 @@ import com.google.api.gax.tracing.GoldenSignalsMetricsTracerFactory; import com.google.api.gax.tracing.ObservabilityAttributes; import com.google.common.collect.ImmutableList; -import com.google.rpc.Status; import com.google.showcase.v1beta1.EchoClient; import com.google.showcase.v1beta1.EchoRequest; -import com.google.showcase.v1beta1.EchoResponse; import com.google.showcase.v1beta1.EchoSettings; import com.google.showcase.v1beta1.it.util.TestClientInitializer; import com.google.showcase.v1beta1.stub.EchoStubSettings; @@ -54,20 +48,25 @@ import io.grpc.Channel; import io.grpc.ClientCall; import io.grpc.ClientInterceptor; -import io.grpc.MethodDescriptor; import io.grpc.Metadata; +import io.grpc.MethodDescriptor; import io.opentelemetry.api.common.AttributeKey; import io.opentelemetry.sdk.OpenTelemetrySdk; import io.opentelemetry.sdk.metrics.SdkMeterProvider; import io.opentelemetry.sdk.metrics.data.MetricData; import io.opentelemetry.sdk.testing.exporter.InMemoryMetricReader; -import java.io.ByteArrayInputStream; -import java.io.InputStream; -import java.util.Collection; import org.junit.jupiter.api.AfterEach; import org.junit.jupiter.api.BeforeEach; import org.junit.jupiter.api.Test; +import java.io.ByteArrayInputStream; +import java.io.InputStream; +import java.util.Collection; + +import static com.google.common.truth.Truth.assertThat; +import static java.nio.charset.StandardCharsets.UTF_8; +import static org.junit.Assert.assertThrows; + class ITOtelGoldenMetrics { private static final String SHOWCASE_SERVER_ADDRESS = "localhost"; private static final long SHOWCASE_SERVER_PORT = 7469; @@ -513,7 +512,7 @@ public void halfClose() {} public void sendMessage(ReqT message) {} }; } else { - return next.interceptCall(method, callOptions); + return next.newCall(method, callOptions); } } }; From 3f32b881279d87727a631a19354a2568b90b8d79 Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 15:56:27 -0400 Subject: [PATCH 4/7] tests: Rename tests. --- .../google/showcase/v1beta1/it/ITOtelGoldenMetrics.java | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index 302da7b0db53..7f25e2f9ab92 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -398,7 +398,7 @@ public String getHeaderValue(int index) { } @Test - void testMetrics_zeroDeadline_grpc() throws Exception { + void testMetrics_clientTimeout_grpc() throws Exception { GoldenSignalsMetricsTracerFactory tracerFactory = new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); @@ -444,7 +444,7 @@ void testMetrics_zeroDeadline_grpc() throws Exception { } @Test - void testMetrics_zeroDeadline_httpjson() throws Exception { + void testMetrics_clientTimeout_httpjson() throws Exception { GoldenSignalsMetricsTracerFactory tracerFactory = new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); @@ -488,7 +488,7 @@ void testMetrics_zeroDeadline_httpjson() throws Exception { } @Test - void testMetrics_retryAndSucceed_grpc() throws Exception { + void testMetrics_retryShouldResultInOneMetric_grpc() throws Exception { GoldenSignalsMetricsTracerFactory tracerFactory = new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); @@ -566,7 +566,7 @@ public void sendMessage(ReqT message) {} } @Test - void testMetrics_retryAndSucceed_httpjson() throws Exception { + void testMetrics_retryShouldResultInOneMetric_httpjson() throws Exception { GoldenSignalsMetricsTracerFactory tracerFactory = new GoldenSignalsMetricsTracerFactory(openTelemetrySdk); From a64c3dab676adcaa2fabde4bdfbf3e94af47feb8 Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 15:57:37 -0400 Subject: [PATCH 5/7] Migrate to java.time.Duration in ITOtelGoldenMetrics --- .../v1beta1/it/ITOtelGoldenMetrics.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index 7f25e2f9ab92..c0cd5eebe050 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -406,9 +406,9 @@ void testMetrics_clientTimeout_grpc() throws Exception { // metrics RetrySettings zeroRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) - .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) - .setTotalTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setInitialRpcTimeout(java.time.Duration.ofMillis(1)) + .setMaxRpcTimeout(java.time.Duration.ofMillis(1)) + .setTotalTimeout(java.time.Duration.ofMillis(1)) .setMaxAttempts(1) .build(); @@ -450,9 +450,9 @@ void testMetrics_clientTimeout_httpjson() throws Exception { RetrySettings zeroRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) - .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(1)) - .setTotalTimeout(org.threeten.bp.Duration.ofMillis(1)) + .setInitialRpcTimeout(java.time.Duration.ofMillis(1)) + .setMaxRpcTimeout(java.time.Duration.ofMillis(1)) + .setTotalTimeout(java.time.Duration.ofMillis(1)) .setMaxAttempts(1) .build(); @@ -494,9 +494,9 @@ void testMetrics_retryShouldResultInOneMetric_grpc() throws Exception { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) - .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) - .setTotalTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setInitialRpcTimeout(java.time.Duration.ofMillis(5000L)) + .setMaxRpcTimeout(java.time.Duration.ofMillis(5000L)) + .setTotalTimeout(java.time.Duration.ofMillis(5000L)) .setMaxAttempts(3) .build(); @@ -572,9 +572,9 @@ void testMetrics_retryShouldResultInOneMetric_httpjson() throws Exception { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) - .setMaxRpcTimeout(org.threeten.bp.Duration.ofMillis(5000L)) - .setTotalTimeout(org.threeten.bp.Duration.ofMillis(5000L)) + .setInitialRpcTimeout(java.time.Duration.ofMillis(5000L)) + .setMaxRpcTimeout(java.time.Duration.ofMillis(5000L)) + .setTotalTimeout(java.time.Duration.ofMillis(5000L)) .setMaxAttempts(3) .build(); From 6d45b65c00ca2f0d028c96776cfa6a9162032c0d Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 15:59:27 -0400 Subject: [PATCH 6/7] Use short name for Duration in ITOtelGoldenMetrics --- .../v1beta1/it/ITOtelGoldenMetrics.java | 25 ++++++++++--------- 1 file changed, 13 insertions(+), 12 deletions(-) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index c0cd5eebe050..c17c2bab6f28 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -61,6 +61,7 @@ import java.io.ByteArrayInputStream; import java.io.InputStream; +import java.time.Duration; import java.util.Collection; import static com.google.common.truth.Truth.assertThat; @@ -406,9 +407,9 @@ void testMetrics_clientTimeout_grpc() throws Exception { // metrics RetrySettings zeroRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(java.time.Duration.ofMillis(1)) - .setMaxRpcTimeout(java.time.Duration.ofMillis(1)) - .setTotalTimeout(java.time.Duration.ofMillis(1)) + .setInitialRpcTimeout(Duration.ofMillis(1)) + .setMaxRpcTimeout(Duration.ofMillis(1)) + .setTotalTimeout(Duration.ofMillis(1)) .setMaxAttempts(1) .build(); @@ -450,9 +451,9 @@ void testMetrics_clientTimeout_httpjson() throws Exception { RetrySettings zeroRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(java.time.Duration.ofMillis(1)) - .setMaxRpcTimeout(java.time.Duration.ofMillis(1)) - .setTotalTimeout(java.time.Duration.ofMillis(1)) + .setInitialRpcTimeout(Duration.ofMillis(1)) + .setMaxRpcTimeout(Duration.ofMillis(1)) + .setTotalTimeout(Duration.ofMillis(1)) .setMaxAttempts(1) .build(); @@ -494,9 +495,9 @@ void testMetrics_retryShouldResultInOneMetric_grpc() throws Exception { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(java.time.Duration.ofMillis(5000L)) - .setMaxRpcTimeout(java.time.Duration.ofMillis(5000L)) - .setTotalTimeout(java.time.Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ofMillis(5000L)) + .setMaxRpcTimeout(Duration.ofMillis(5000L)) + .setTotalTimeout(Duration.ofMillis(5000L)) .setMaxAttempts(3) .build(); @@ -572,9 +573,9 @@ void testMetrics_retryShouldResultInOneMetric_httpjson() throws Exception { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(java.time.Duration.ofMillis(5000L)) - .setMaxRpcTimeout(java.time.Duration.ofMillis(5000L)) - .setTotalTimeout(java.time.Duration.ofMillis(5000L)) + .setInitialRpcTimeout(Duration.ofMillis(5000L)) + .setMaxRpcTimeout(Duration.ofMillis(5000L)) + .setTotalTimeout(Duration.ofMillis(5000L)) .setMaxAttempts(3) .build(); From 3946ce27116538ce0c1b2ee9d7e5dae3ed130a7c Mon Sep 17 00:00:00 2001 From: blakeli Date: Fri, 3 Apr 2026 16:08:54 -0400 Subject: [PATCH 7/7] Use Duration variant methods in RetrySettings in ITOtelGoldenMetrics --- .../v1beta1/it/ITOtelGoldenMetrics.java | 24 +++++++++---------- 1 file changed, 12 insertions(+), 12 deletions(-) diff --git a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java index c17c2bab6f28..6d7065f3dc95 100644 --- a/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java +++ b/sdk-platform-java/java-showcase/gapic-showcase/src/test/java/com/google/showcase/v1beta1/it/ITOtelGoldenMetrics.java @@ -407,9 +407,9 @@ void testMetrics_clientTimeout_grpc() throws Exception { // metrics RetrySettings zeroRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(1)) - .setMaxRpcTimeout(Duration.ofMillis(1)) - .setTotalTimeout(Duration.ofMillis(1)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(1)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(1)) + .setTotalTimeoutDuration(Duration.ofMillis(1)) .setMaxAttempts(1) .build(); @@ -451,9 +451,9 @@ void testMetrics_clientTimeout_httpjson() throws Exception { RetrySettings zeroRetrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(1)) - .setMaxRpcTimeout(Duration.ofMillis(1)) - .setTotalTimeout(Duration.ofMillis(1)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(1)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(1)) + .setTotalTimeoutDuration(Duration.ofMillis(1)) .setMaxAttempts(1) .build(); @@ -495,9 +495,9 @@ void testMetrics_retryShouldResultInOneMetric_grpc() throws Exception { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(5000L)) - .setMaxRpcTimeout(Duration.ofMillis(5000L)) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(5000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setMaxAttempts(3) .build(); @@ -573,9 +573,9 @@ void testMetrics_retryShouldResultInOneMetric_httpjson() throws Exception { RetrySettings retrySettings = RetrySettings.newBuilder() - .setInitialRpcTimeout(Duration.ofMillis(5000L)) - .setMaxRpcTimeout(Duration.ofMillis(5000L)) - .setTotalTimeout(Duration.ofMillis(5000L)) + .setInitialRpcTimeoutDuration(Duration.ofMillis(5000L)) + .setMaxRpcTimeoutDuration(Duration.ofMillis(5000L)) + .setTotalTimeoutDuration(Duration.ofMillis(5000L)) .setMaxAttempts(3) .build();