diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java index 21675ff228c..0d30ff1d5f0 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/BuiltInOpenTelemetryMetricsProvider.java @@ -60,12 +60,12 @@ final class BuiltInOpenTelemetryMetricsProvider { private BuiltInOpenTelemetryMetricsProvider() {} OpenTelemetry getOrCreateOpenTelemetry( - String projectId, @Nullable Credentials credentials, @Nullable String metricsHost) { + String projectId, @Nullable Credentials credentials, @Nullable String monitoringHost) { try { if (this.openTelemetry == null) { SdkMeterProviderBuilder sdkMeterProviderBuilder = SdkMeterProvider.builder(); BuiltInOpenTelemetryMetricsView.registerBuiltinMetrics( - SpannerCloudMonitoringExporter.create(projectId, credentials, metricsHost), + SpannerCloudMonitoringExporter.create(projectId, credentials, monitoringHost), sdkMeterProviderBuilder); this.openTelemetry = OpenTelemetrySdk.builder().setMeterProvider(sdkMeterProviderBuilder.build()).build(); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java index 319d7ff3548..fc101fbcfc3 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerCloudMonitoringExporter.java @@ -71,7 +71,7 @@ class SpannerCloudMonitoringExporter implements MetricExporter { private final String spannerProjectId; static SpannerCloudMonitoringExporter create( - String projectId, @Nullable Credentials credentials, @Nullable String metricsHost) + String projectId, @Nullable Credentials credentials, @Nullable String monitoringHost) throws IOException { MetricServiceSettings.Builder settingsBuilder = MetricServiceSettings.newBuilder(); CredentialsProvider credentialsProvider; @@ -81,8 +81,8 @@ static SpannerCloudMonitoringExporter create( credentialsProvider = FixedCredentialsProvider.create(credentials); } settingsBuilder.setCredentialsProvider(credentialsProvider); - if (metricsHost != null) { - settingsBuilder.setEndpoint(metricsHost); + if (monitoringHost != null) { + settingsBuilder.setEndpoint(monitoringHost); } org.threeten.bp.Duration timeout = Duration.ofMinutes(1); diff --git a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java index 65e6782f0f0..d85b39c1253 100644 --- a/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java +++ b/google-cloud-spanner/src/main/java/com/google/cloud/spanner/SpannerOptions.java @@ -164,7 +164,7 @@ public class SpannerOptions extends ServiceOptions { private final boolean enableBuiltInMetrics; private final boolean enableExtendedTracing; private final boolean enableEndToEndTracing; - private final String metricsHost; + private final String monitoringHost; enum TracingFramework { OPEN_CENSUS, @@ -673,7 +673,7 @@ protected SpannerOptions(Builder builder) { enableExtendedTracing = builder.enableExtendedTracing; enableBuiltInMetrics = builder.enableBuiltInMetrics; enableEndToEndTracing = builder.enableEndToEndTracing; - metricsHost = builder.metricsHost; + monitoringHost = builder.monitoringHost; } /** @@ -715,7 +715,7 @@ default boolean isEnableEndToEndTracing() { return false; } - default String getMetricsHost() { + default String getMonitoringHost() { return null; } } @@ -734,7 +734,7 @@ private static class SpannerEnvironmentImpl implements SpannerEnvironment { private static final String SPANNER_ENABLE_END_TO_END_TRACING = "SPANNER_ENABLE_END_TO_END_TRACING"; private static final String SPANNER_DISABLE_BUILTIN_METRICS = "SPANNER_DISABLE_BUILTIN_METRICS"; - private static final String SPANNER_METRICS_HOST = "SPANNER_METRICS_HOST"; + private static final String SPANNER_MONITORING_HOST = "SPANNER_MONITORING_HOST"; private SpannerEnvironmentImpl() {} @@ -772,8 +772,8 @@ public boolean isEnableEndToEndTracing() { } @Override - public String getMetricsHost() { - return System.getenv(SPANNER_METRICS_HOST); + public String getMonitoringHost() { + return System.getenv(SPANNER_MONITORING_HOST); } } @@ -840,7 +840,7 @@ public static class Builder private boolean enableExtendedTracing = SpannerOptions.environment.isEnableExtendedTracing(); private boolean enableEndToEndTracing = SpannerOptions.environment.isEnableEndToEndTracing(); private boolean enableBuiltInMetrics = SpannerOptions.environment.isEnableBuiltInMetrics(); - private String metricsHost = SpannerOptions.environment.getMetricsHost(); + private String monitoringHost = SpannerOptions.environment.getMonitoringHost(); private static String createCustomClientLibToken(String token) { return token + " " + ServiceOptions.getGoogApiClientLibName(); @@ -908,7 +908,7 @@ protected Builder() { this.enableExtendedTracing = options.enableExtendedTracing; this.enableBuiltInMetrics = options.enableBuiltInMetrics; this.enableEndToEndTracing = options.enableEndToEndTracing; - this.metricsHost = options.metricsHost; + this.monitoringHost = options.monitoringHost; } @Override @@ -1431,9 +1431,9 @@ public Builder setBuiltInMetricsEnabled(boolean enableBuiltInMetrics) { return this; } - /** Sets the metrics host to be used for Built-in client side metrics */ - public Builder setMetricsHost(String metricsHost) { - this.metricsHost = metricsHost; + /** Sets the monitoring host to be used for Built-in client side metrics */ + public Builder setMonitoringHost(String monitoringHost) { + this.monitoringHost = monitoringHost; return this; } @@ -1747,7 +1747,7 @@ private ApiTracerFactory getDefaultApiTracerFactory() { private ApiTracerFactory createMetricsApiTracerFactory() { OpenTelemetry openTelemetry = this.builtInOpenTelemetryMetricsProvider.getOrCreateOpenTelemetry( - this.getProjectId(), getCredentials(), this.metricsHost); + this.getProjectId(), getCredentials(), this.monitoringHost); return openTelemetry != null ? new MetricsTracerFactory( @@ -1775,8 +1775,8 @@ public boolean isEnableBuiltInMetrics() { } /** Returns the override metrics Host. */ - String getMetricsHost() { - return metricsHost; + String getMonitoringHost() { + return monitoringHost; } @BetaApi diff --git a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java index 2bb16833b85..7b891fdb7a9 100644 --- a/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java +++ b/google-cloud-spanner/src/test/java/com/google/cloud/spanner/SpannerOptionsTest.java @@ -755,15 +755,15 @@ public void testEndToEndTracingEnablement() { } @Test - public void testMetricsHost() { + public void testmonitoringHost() { String metricsEndpoint = "test-endpoint:443"; - assertNull(SpannerOptions.newBuilder().setProjectId("p").build().getMetricsHost()); + assertNull(SpannerOptions.newBuilder().setProjectId("p").build().getMonitoringHost()); assertThat( SpannerOptions.newBuilder() .setProjectId("p") - .setMetricsHost(metricsEndpoint) + .setMonitoringHost(metricsEndpoint) .build() - .getMetricsHost()) + .getMonitoringHost()) .isEqualTo(metricsEndpoint); }