Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Add test profile to push metrics to test environment #1921

Merged
merged 5 commits into from
Oct 11, 2023
Merged
Show file tree
Hide file tree
Changes from 2 commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 8 additions & 0 deletions google-cloud-bigtable-stats/pom.xml
Original file line number Diff line number Diff line change
Expand Up @@ -254,4 +254,12 @@
</plugin>
</plugins>
</build>
<profiles>
<profile>
<id>test</id>
<properties>
<bigtable.test-monitoring-endpoint/>
</properties>
</profile>
</profiles>
</project>
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@
import com.google.cloud.monitoring.v3.MetricServiceSettings;
import com.google.common.annotations.VisibleForTesting;
import com.google.common.base.Preconditions;
import com.google.common.base.MoreObjects;
import io.opencensus.common.Duration;
import io.opencensus.exporter.metrics.util.IntervalMetricReader;
import io.opencensus.exporter.metrics.util.MetricReader;
Expand All @@ -44,6 +45,10 @@ 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(
Expand Down Expand Up @@ -84,7 +89,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());
Expand Down
Loading