From 8feaeecfe8dec42d99814adeee30e6b8487f2638 Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Tue, 9 Aug 2022 15:16:44 -0400 Subject: [PATCH] tweak export interval --- .../BigtableStackdriverStatsExporter.java | 19 ++++++++----------- 1 file changed, 8 insertions(+), 11 deletions(-) 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 970a5bf61c..d9d2ed94f1 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 @@ -37,11 +37,11 @@ public class BigtableStackdriverStatsExporter { static final Object lock = new Object(); @Nullable - @GuardedBy("monitor") + @GuardedBy("lock") private static BigtableStackdriverStatsExporter instance = null; - // Default export interval is 10 minutes - private static final Duration EXPORT_INTERVAL = Duration.create(600, 0); + // Default export interval is 5 minutes + private static final Duration EXPORT_INTERVAL = Duration.create(60 * 5, 0); private static final String RESOURCE_TYPE = "bigtable_client_raw"; private final IntervalMetricReader intervalMetricReader; @@ -65,8 +65,7 @@ private BigtableStackdriverStatsExporter( intervalMetricReaderOptionsBuilder.build()); } - public static void register(@Nullable Credentials credentials, String projectId) - throws IOException { + public static void register(Credentials credentials, String projectId) throws IOException { synchronized (lock) { Preconditions.checkState( instance == null, "Bigtable Stackdriver stats exporter is already created"); @@ -79,16 +78,14 @@ public static void register(@Nullable Credentials credentials, String projectId) } } - @GuardedBy("monitor") + @GuardedBy("lock") @VisibleForTesting - static MetricServiceClient createMetricServiceClient( - @Nullable Credentials credentials, Duration deadline) throws IOException { + static MetricServiceClient createMetricServiceClient(Credentials credentials, Duration deadline) + throws IOException { MetricServiceSettings.Builder settingsBuilder = MetricServiceSettings.newBuilder() .setTransportChannelProvider(InstantiatingGrpcChannelProvider.newBuilder().build()); - if (credentials != null) { - settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)); - } + settingsBuilder.setCredentialsProvider(FixedCredentialsProvider.create(credentials)); org.threeten.bp.Duration stackdriverDuration = org.threeten.bp.Duration.ofMillis(deadline.toMillis());