From b212bbfcfb2d8c2e2fdc2fc3609976c8a462f677 Mon Sep 17 00:00:00 2001 From: Reza Karegar Date: Thu, 1 Feb 2024 16:24:16 -0500 Subject: [PATCH] feat: Define the metrics for collecting per connection error count. (#2088) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit 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) - [ ] Rollback plan is reviewed and LGTMed Fixes #2087 ☕️ If you write sample code, please follow the [samples format]( https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md). --- .../stats/BuiltinMeasureConstants.java | 6 +++ .../bigtable/stats/BuiltinViewConstants.java | 53 ++++++++++++------- 2 files changed, 41 insertions(+), 18 deletions(-) diff --git a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMeasureConstants.java b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMeasureConstants.java index 2f51204d4b..59e7511d41 100644 --- a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMeasureConstants.java +++ b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMeasureConstants.java @@ -88,4 +88,10 @@ class BuiltinMeasureConstants { "bigtable.googleapis.com/internal/client/throttling_latencies", "The artificial latency introduced by the client to limit the number of outstanding requests. The publishing of the measurement will be delayed until the attempt trailers have been received.", MILLISECOND); + + static final MeasureLong PER_CONNECTION_ERROR_COUNT = + MeasureLong.create( + "bigtable.googleapis.com/internal/client/per_connection_error_count", + "Distribution of counts of channels per 'error count per minute'.", + COUNT); } diff --git a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinViewConstants.java b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinViewConstants.java index 7c9dc34d78..06364a2288 100644 --- a/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinViewConstants.java +++ b/google-cloud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinViewConstants.java @@ -15,24 +15,7 @@ */ package com.google.cloud.bigtable.stats; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.APPLICATION_LATENCIES; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.APP_PROFILE; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.ATTEMPT_LATENCIES; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CLIENT_NAME; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CLUSTER; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CONNECTIVITY_ERROR_COUNT; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.FIRST_RESPONSE_LATENCIES; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.INSTANCE_ID; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.METHOD; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.OPERATION_LATENCIES; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.PROJECT_ID; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.RETRY_COUNT; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.SERVER_LATENCIES; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.STATUS; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.STREAMING; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.TABLE; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.THROTTLING_LATENCIES; -import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.ZONE; +import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.*; import static io.opencensus.stats.Aggregation.Distribution; import static io.opencensus.stats.Aggregation.Sum; @@ -59,6 +42,32 @@ class BuiltinViewConstants { 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 15.0, 20.0, 30.0, 40.0, 50.0, 100.0))); + private static final Aggregation PER_CONNECTION_ERROR_COUNT_AGGREGATION = + Distribution.create( + BucketBoundaries.create( + ImmutableList.of( + 1.0, + 2.0, + 4.0, + 8.0, + 16.0, + 32.0, + 64.0, + 125.0, + 250.0, + 500.0, + 1_000.0, + 2_000.0, + 4_000.0, + 8_000.0, + 16_000.0, + 32_000.0, + 64_000.0, + 128_000.0, + 250_000.0, + 500_000.0, + 1_000_000.0))); + private static final Aggregation AGGREGATION_COUNT = Sum.create(); static final View OPERATION_LATENCIES_VIEW = @@ -183,4 +192,12 @@ class BuiltinViewConstants { AGGREGATION_WITH_MILLIS_HISTOGRAM, ImmutableList.of( PROJECT_ID, INSTANCE_ID, APP_PROFILE, METHOD, CLIENT_NAME, CLUSTER, ZONE, TABLE)); + + static final View PER_CONNECTION_ERROR_COUNT_VIEW = + View.create( + View.Name.create("bigtable.googleapis.com/internal/client/per_connection_error_count"), + "Distribution of counts of channels per 'error count per minute'.", + PER_CONNECTION_ERROR_COUNT, + PER_CONNECTION_ERROR_COUNT_AGGREGATION, + ImmutableList.of(PROJECT_ID, INSTANCE_ID, APP_PROFILE, CLIENT_NAME)); }