diff --git a/google-cloud-bigtable-stats/pom.xml b/google-cloud-bigtable-stats/pom.xml index 0c3e9df779..2ccabaaea9 100644 --- a/google-cloud-bigtable-stats/pom.xml +++ b/google-cloud-bigtable-stats/pom.xml @@ -254,4 +254,12 @@ + + + test + + + + + diff --git a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BigtableStackdriverStatsExporter.java b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BigtableStackdriverStatsExporter.java index f6c80fdf88..76a36215c6 100644 --- a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BigtableStackdriverStatsExporter.java +++ b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BigtableStackdriverStatsExporter.java @@ -23,6 +23,7 @@ import com.google.cloud.monitoring.v3.MetricServiceClient; import com.google.cloud.monitoring.v3.MetricServiceSettings; import com.google.common.annotations.VisibleForTesting; +import com.google.common.base.MoreObjects; import com.google.common.base.Preconditions; import io.opencensus.common.Duration; import io.opencensus.exporter.metrics.util.IntervalMetricReader; @@ -44,6 +45,11 @@ public class BigtableStackdriverStatsExporter { private static final Duration EXPORT_INTERVAL = Duration.create(60, 0); private static final String RESOURCE_TYPE = "bigtable_client_raw"; + private static final String MONITORING_ENDPOINT = + MoreObjects.firstNonNull( + System.getProperty("bigtable.test-monitoring-endpoint"), + MetricServiceSettings.getDefaultEndpoint()); + private final IntervalMetricReader intervalMetricReader; private BigtableStackdriverStatsExporter( @@ -84,7 +90,7 @@ static MetricServiceClient createMetricServiceClient(Credentials credentials, Du MetricServiceSettings.newBuilder() .setTransportChannelProvider(InstantiatingGrpcChannelProvider.newBuilder().build()); settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)); - + settingsBuilder.setEndpoint(MONITORING_ENDPOINT); org.threeten.bp.Duration timeout = org.threeten.bp.Duration.ofMillis(deadline.toMillis()); settingsBuilder.createServiceTimeSeriesSettings().setSimpleTimeoutNoRetries(timeout); return MetricServiceClient.create(settingsBuilder.build());