Skip to content

Commit b5fa19a

Browse files
committed
fix(spanner): preserve grpc metrics overload compatibility
1 parent c9a52a5 commit b5fa19a

3 files changed

Lines changed: 22 additions & 5 deletions

File tree

java-spanner/google-cloud-spanner/clirr-ignored-differences.xml

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1139,9 +1139,4 @@
11391139
<className>com/google/cloud/spanner/XGoogSpannerRequestId</className>
11401140
<field>REQUEST_ID</field>
11411141
</difference>
1142-
<difference>
1143-
<differenceType>7004</differenceType>
1144-
<className>com/google/cloud/spanner/SpannerOptions</className>
1145-
<method>void enablegRPCMetrics(com.google.api.gax.grpc.InstantiatingGrpcChannelProvider$Builder)</method>
1146-
</difference>
11471142
</differences>

java-spanner/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2698,13 +2698,27 @@ public OpenTelemetry getBuiltInOpenTelemetry() {
26982698
this.getProjectId(), getCredentials(), this.monitoringHost, getUniverseDomain());
26992699
}
27002700

2701+
/**
2702+
* Wires gRPC-layer built-in metrics into the given channel provider builder using the
2703+
* pre-emulator-aware behavior.
2704+
*
2705+
* @deprecated for internal callers only. Use {@link #enablegRPCMetrics(
2706+
* InstantiatingGrpcChannelProvider.Builder, boolean)}.
2707+
*/
2708+
@Deprecated
2709+
@InternalApi
2710+
public void enablegRPCMetrics(InstantiatingGrpcChannelProvider.Builder channelProviderBuilder) {
2711+
enablegRPCMetrics(channelProviderBuilder, /* isEmulatorEnabled= */ false);
2712+
}
2713+
27012714
/**
27022715
* Wires gRPC-layer built-in metrics into the given channel provider builder for each active
27032716
* metrics sink: the Cloud Monitoring (GCM) sink when {@link #isEnableBuiltInMetrics()} is true,
27042717
* and the caller-owned OpenTelemetry sink when a {@link CustomOpenTelemetryMetricsProvider} is
27052718
* configured. Does nothing when {@code isEmulatorEnabled} is true or gRPC built-in metrics are
27062719
* disabled via the environment.
27072720
*/
2721+
@InternalApi
27082722
public void enablegRPCMetrics(
27092723
InstantiatingGrpcChannelProvider.Builder channelProviderBuilder, boolean isEmulatorEnabled) {
27102724
if (isEmulatorEnabled || !SpannerOptions.environment.isEnableGRPCBuiltInMetrics()) {

java-spanner/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
import static org.mockito.Mockito.mock;
3232

3333
import com.google.api.gax.grpc.GrpcCallContext;
34+
import com.google.api.gax.grpc.InstantiatingGrpcChannelProvider;
3435
import com.google.api.gax.retrying.RetrySettings;
3536
import com.google.api.gax.rpc.ApiCallContext;
3637
import com.google.api.gax.rpc.ServerStreamingCallSettings;
@@ -1451,6 +1452,13 @@ public void testOmniEnforcedInConstructor() {
14511452
Duration.ofSeconds(42), options.getSessionPoolOptions().getAcquireSessionTimeout());
14521453
}
14531454

1455+
@Test
1456+
public void enableGrpcMetricsKeepsOneArgOverloadForCompatibility() throws Exception {
1457+
assertNotNull(
1458+
SpannerOptions.class.getMethod(
1459+
"enablegRPCMetrics", InstantiatingGrpcChannelProvider.Builder.class));
1460+
}
1461+
14541462
@Test
14551463
public void testCustomProviderKeepsCloudMonitoringSinkOnNonOmni() {
14561464
SpannerOptions.useEnvironment(new SpannerOptions.SpannerEnvironment() {});

0 commit comments

Comments
 (0)