From 68d0507ca5130342d04bce49da439f160a0bdd4b Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Mon, 30 Sep 2024 15:51:51 -0400 Subject: [PATCH] update default --- .../v2/stub/EnhancedBigtableStubSettings.java | 23 ++++++++++++++----- .../BigtableCloudMonitoringExporter.java | 19 +++++++++++++-- .../v2/stub/metrics/BuiltinMetricsView.java | 4 ++-- 3 files changed, 36 insertions(+), 10 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java index dbb6a6e10c..2a3d0ddba4 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStubSettings.java @@ -50,7 +50,6 @@ import com.google.cloud.bigtable.data.v2.stub.metrics.MetricsProvider; import com.google.cloud.bigtable.data.v2.stub.mutaterows.MutateRowsBatchingDescriptor; import com.google.cloud.bigtable.data.v2.stub.readrows.ReadRowsBatchingDescriptor; -import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import com.google.common.collect.ImmutableList; @@ -66,6 +65,7 @@ import java.util.Set; import java.util.logging.Logger; import javax.annotation.Nonnull; +import javax.annotation.Nullable; import org.threeten.bp.Duration; /** @@ -251,7 +251,7 @@ public class EnhancedBigtableStubSettings extends StubSettingsmap(FixedCredentialsProvider::create) .orElse(NoCredentialsProvider.create()); settingsBuilder.setCredentialsProvider(credentialsProvider); - settingsBuilder.setEndpoint(endpoint); + if (MONITORING_ENDPOINT != null) { + logger.warning( + "Setting the monitoring endpoint through system variable will be removed in future versions"); + settingsBuilder.setEndpoint(MONITORING_ENDPOINT); + } + if (endpoint != null) { + settingsBuilder.setEndpoint(endpoint); + } org.threeten.bp.Duration timeout = Duration.ofMinutes(1); // TODO: createServiceTimeSeries needs special handling if the request failed. Leaving diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsView.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsView.java index a866800eba..386b88e42d 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsView.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsView.java @@ -59,13 +59,13 @@ public static void registerBuiltinMetrics( /** * Register built-in metrics on the {@link SdkMeterProviderBuilder} with custom credentials and - * endpoint + * endpoint. */ public static void registerBuiltinMetrics( String projectId, @Nullable Credentials credentials, SdkMeterProviderBuilder builder, - String endpoint) + @Nullable String endpoint) throws IOException { MetricExporter metricExporter = BigtableCloudMonitoringExporter.create(projectId, credentials, endpoint);