Skip to content

Commit 2104315

Browse files
authored
feat: Add test profile to push metrics to test environment (#1921)
feat:add test profile Thank you for opening a Pull Request! Before submitting your PR, there are a few things you can do to make sure it goes smoothly: - [ ] Make sure to open an issue as a [bug/issue](https://togithub.com/googleapis/java-bigtable/issues/new/choose) before writing your code! That way we can discuss the change, evaluate designs, and agree on the general idea - [ ] Ensure the tests and linter pass - [ ] Code coverage does not decrease (if any source code was changed) - [ ] Appropriate docs were updated (if necessary) Fixes 299954521 ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
1 parent 29244f7 commit 2104315

File tree

2 files changed

+15
-1
lines changed

2 files changed

+15
-1
lines changed

google-cloud-bigtable-stats/pom.xml

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -254,4 +254,12 @@
254254
</plugin>
255255
</plugins>
256256
</build>
257+
<profiles>
258+
<profile>
259+
<id>test</id>
260+
<properties>
261+
<bigtable.test-monitoring-endpoint/>
262+
</properties>
263+
</profile>
264+
</profiles>
257265
</project>

google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BigtableStackdriverStatsExporter.java

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,6 +23,7 @@
2323
import com.google.cloud.monitoring.v3.MetricServiceClient;
2424
import com.google.cloud.monitoring.v3.MetricServiceSettings;
2525
import com.google.common.annotations.VisibleForTesting;
26+
import com.google.common.base.MoreObjects;
2627
import com.google.common.base.Preconditions;
2728
import io.opencensus.common.Duration;
2829
import io.opencensus.exporter.metrics.util.IntervalMetricReader;
@@ -44,6 +45,11 @@ public class BigtableStackdriverStatsExporter {
4445
private static final Duration EXPORT_INTERVAL = Duration.create(60, 0);
4546
private static final String RESOURCE_TYPE = "bigtable_client_raw";
4647

48+
private static final String MONITORING_ENDPOINT =
49+
MoreObjects.firstNonNull(
50+
System.getProperty("bigtable.test-monitoring-endpoint"),
51+
MetricServiceSettings.getDefaultEndpoint());
52+
4753
private final IntervalMetricReader intervalMetricReader;
4854

4955
private BigtableStackdriverStatsExporter(
@@ -84,7 +90,7 @@ static MetricServiceClient createMetricServiceClient(Credentials credentials, Du
8490
MetricServiceSettings.newBuilder()
8591
.setTransportChannelProvider(InstantiatingGrpcChannelProvider.newBuilder().build());
8692
settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials));
87-
93+
settingsBuilder.setEndpoint(MONITORING_ENDPOINT);
8894
org.threeten.bp.Duration timeout = org.threeten.bp.Duration.ofMillis(deadline.toMillis());
8995
settingsBuilder.createServiceTimeSeriesSettings().setSimpleTimeoutNoRetries(timeout);
9096
return MetricServiceClient.create(settingsBuilder.build());

0 commit comments

Comments
 (0)