File tree Expand file tree Collapse file tree 2 files changed +26
-1
lines changed
java-spanner/google-cloud-spanner/src
main/java/com/google/cloud/spanner
test/java/com/google/cloud/spanner/spi/v1 Expand file tree Collapse file tree 2 files changed +26
-1
lines changed Original file line number Diff line number Diff line change @@ -2446,7 +2446,7 @@ public OpenTelemetry getBuiltInOpenTelemetry() {
24462446 }
24472447
24482448 public void enablegRPCMetrics (InstantiatingGrpcChannelProvider .Builder channelProviderBuilder ) {
2449- if (SpannerOptions .environment .isEnableGRPCBuiltInMetrics ()) {
2449+ if (isEnableBuiltInMetrics () && SpannerOptions .environment .isEnableGRPCBuiltInMetrics ()) {
24502450 this .builtInMetricsProvider .enableGrpcMetrics (
24512451 channelProviderBuilder ,
24522452 this .getProjectId (),
Original file line number Diff line number Diff line change @@ -1178,6 +1178,31 @@ public void testGrpcGcpOptionsRetainDynamicChannelPoolSettingsWithDcp() throws E
11781178 assertEquals (
11791179 affinityKeyLifetime , grpcGcpOptions .getChannelPoolOptions ().getAffinityKeyLifetime ());
11801180 assertEquals (cleanupInterval , grpcGcpOptions .getChannelPoolOptions ().getCleanupInterval ());
1181+ public void testBuiltInMetricsDisabledSkipsGrpcBuiltInMetricsConfigurator () {
1182+ try {
1183+ SpannerOptions .useEnvironment (
1184+ new SpannerOptions .SpannerEnvironment () {
1185+ @ Override
1186+ public boolean isEnableGRPCBuiltInMetrics () {
1187+ return true ;
1188+ }
1189+ });
1190+
1191+ SpannerOptions options =
1192+ SpannerOptions .newBuilder ()
1193+ .setProjectId ("[PROJECT]" )
1194+ .setCredentials (STATIC_CREDENTIALS )
1195+ .setBuiltInMetricsEnabled (false )
1196+ .build ();
1197+ InstantiatingGrpcChannelProvider .Builder channelProviderBuilder =
1198+ InstantiatingGrpcChannelProvider .newBuilder ();
1199+
1200+ options .enablegRPCMetrics (channelProviderBuilder );
1201+
1202+ assertNull (channelProviderBuilder .getChannelConfigurator ());
1203+ } finally {
1204+ SpannerOptions .useDefaultEnvironment ();
1205+ }
11811206 }
11821207
11831208 private static final class RecordingTransportChannelProvider implements TransportChannelProvider {
You can’t perform that action at this time.
0 commit comments