File tree Expand file tree Collapse file tree 2 files changed +29
-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 +29
-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 @@ -1180,6 +1180,34 @@ public void testGrpcGcpOptionsRetainDynamicChannelPoolSettingsWithDcp() throws E
11801180 assertEquals (cleanupInterval , grpcGcpOptions .getChannelPoolOptions ().getCleanupInterval ());
11811181 }
11821182
1183+ @ Test
1184+ public void testBuiltInMetricsDisabledSkipsGrpcBuiltInMetricsConfigurator () {
1185+ try {
1186+ SpannerOptions .useEnvironment (
1187+ new SpannerOptions .SpannerEnvironment () {
1188+ @ Override
1189+ public boolean isEnableGRPCBuiltInMetrics () {
1190+ return true ;
1191+ }
1192+ });
1193+
1194+ SpannerOptions options =
1195+ SpannerOptions .newBuilder ()
1196+ .setProjectId ("[PROJECT]" )
1197+ .setCredentials (STATIC_CREDENTIALS )
1198+ .setBuiltInMetricsEnabled (false )
1199+ .build ();
1200+ InstantiatingGrpcChannelProvider .Builder channelProviderBuilder =
1201+ InstantiatingGrpcChannelProvider .newBuilder ();
1202+
1203+ options .enablegRPCMetrics (channelProviderBuilder );
1204+
1205+ assertNull (channelProviderBuilder .getChannelConfigurator ());
1206+ } finally {
1207+ SpannerOptions .useDefaultEnvironment ();
1208+ }
1209+ }
1210+
11831211 private static final class RecordingTransportChannelProvider implements TransportChannelProvider {
11841212 private final String host ;
11851213 private final int port ;
You can’t perform that action at this time.
0 commit comments