GV

GeezerVison

The World Wide Web, restored to 800 pixels of glory.

Home|About|Gaming cabinet|Archives|How it works|Starter sites

On this site

  • Sign in
  • ActionsCI/CD and automation
  • CodespacesCloud development environments
  • All Features
  • Documentation
  • Training
  • Certifications
  • Build with Copilot
  • Customize Copilot
  • Integrations
  • Trending repos
  • GitHub Sponsors
  • Developer articles
  • Enterprises

This view

  • Original page
  • New address

GeezerVison is showing github.com — feat: add built-in metric constants by mutianf · Pull Request #1243 · googleapis/java-bigtable

This repository was archived by the owner on Aug 30, 2026. It is now read-only.

feat: add built-in metric constants #1243

Merged
mutianf merged 10 commits into googleapis:main from mutianf:experiment
Jun 21, 2022

Uh oh!

There was an error while loading. Please reload this page.

Merged

feat: add built-in metric constants #1243

Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
10 commits
Select commit Hold shift + click to select a range
78ea8c5
feat: add built in metrics measure and views
mutianf May 10, 2022
cd279d9
remove status from application latency
mutianf May 11, 2022
5ed0ebe
Rename methods and add comments
mutianf Jun 7, 2022
9990553
update based on comments
mutianf Jun 8, 2022
d0a75ba
add comment for client id
mutianf Jun 8, 2022
704234c
move dependency
mutianf Jun 9, 2022
279b048
use SUM for connectivity errors
mutianf Jun 9, 2022
99ca180
update on comments
mutianf Jun 21, 2022
292dcd7
update dependencies
mutianf Jun 21, 2022
1d5d56a
🦉 Updates from OwlBot post-processor
gcf-owl-bot[bot] Jun 21, 2022
File filter
Filter by extension


Clear filters
Conversations
Failed to load comments.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Jump to
Jump to file
Failed to load files.
Loading

Uh oh!

There was an error while loading. Please reload this page.

Diff view
Diff view

There are no files selected for viewing

5 changes: 5 additions & 0 deletions 5 google-cloud-bigtable-bom/pom.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -94,6 +94,11 @@
<artifactId>proto-google-cloud-bigtable-v2</artifactId>
<version>2.8.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-bigtable-v2:current} -->
</dependency>
<dependency>
<groupId>com.google.cloud</groupId>
<artifactId>google-cloud-bigtable-stats</artifactId>
<version>2.8.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable:current} -->
</dependency>
</dependencies>
</dependencyManagement>

Expand Down
31 changes: 24 additions & 7 deletions 31 google-cloud-bigtable-stats/pom.xml
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
Expand Up @@ -29,17 +29,38 @@
</dependencyManagement>

<dependencies>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>gax</artifactId>
</dependency>
<dependency>
<groupId>com.google.api</groupId>
<artifactId>api-common</artifactId>
</dependency>

<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-api</artifactId>
</dependency>
<dependency>
<groupId>com.google.guava</groupId>
<artifactId>guava</artifactId>
</dependency>

<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-impl</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>io.opencensus</groupId>
<artifactId>opencensus-exporter-stats-stackdriver</artifactId>
<groupId>com.google.truth</groupId>
<artifactId>truth</artifactId>
<scope>test</scope>
</dependency>
<dependency>
<groupId>junit</groupId>
<artifactId>junit</artifactId>
<scope>test</scope>
</dependency>
</dependencies>

Expand All @@ -48,6 +69,7 @@
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-shade-plugin</artifactId>
<version>3.2.4</version>
<executions>
<execution>
<phase>package</phase>
Expand Down Expand Up @@ -78,11 +100,6 @@
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-dependency-plugin</artifactId>
<version>3.3.0</version>
<configuration>
<ignoredUnusedDeclaredDependencies>
<ignoredUnusedDeclaredDependency>*</ignoredUnusedDeclaredDependency>
</ignoredUnusedDeclaredDependencies>
</configuration>
</plugin>
</plugins>
</build>
Expand Down
92 changes: 92 additions & 0 deletions 92 ...bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinMeasureConstants.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.google.cloud.bigtable.stats;

import static io.opencensus.stats.Measure.MeasureLong;

import io.opencensus.tags.TagKey;

/** Built-in metrics that will be readable under bigtable.googleapis.com/client namespace */
class BuiltinMeasureConstants {
// Monitored resource TagKeys
static final TagKey PROJECT_ID = TagKey.create("project_id");
static final TagKey INSTANCE_ID = TagKey.create("instance_id");
static final TagKey CLUSTER = TagKey.create("cluster");
static final TagKey TABLE = TagKey.create("table");
static final TagKey ZONE = TagKey.create("zone");
// Placeholder TagKey to be used in Stackdriver exporter
static final TagKey CLIENT_ID = TagKey.create("client_id");

// Metrics TagKeys
static final TagKey APP_PROFILE = TagKey.create("app_profile");
static final TagKey METHOD = TagKey.create("method");
static final TagKey STREAMING = TagKey.create("streaming");
static final TagKey STATUS = TagKey.create("status");
static final TagKey CLIENT_NAME = TagKey.create("client_name");

// Units
private static final String COUNT = "1";
private static final String MILLISECOND = "ms";

// Measurements
static final MeasureLong OPERATION_LATENCIES =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/operation_latencies",
"Total time until final operation success or failure, including retries and backoff.",
MILLISECOND);

static final MeasureLong ATTEMPT_LATENCIES =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/attempt_latencies",
"Client observed latency per RPC attempt.",
MILLISECOND);

static final MeasureLong RETRY_COUNT =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/retry_count",
"The number of additional RPCs sent after the initial attempt.",
COUNT);

static final MeasureLong FIRST_RESPONSE_LATENCIES =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/first_response_latencies",
"Latency from operation start until the response headers were received. The publishing of the measurement will be delayed until the attempt response has been received.",
MILLISECOND);

static final MeasureLong SERVER_LATENCIES =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/server_latencies",
"The latency measured from the moment that the RPC entered the Google data center until the RPC was completed.",
MILLISECOND);

static final MeasureLong CONNECTIVITY_ERROR_COUNT =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/connectivity_error_count",
"Number of requests that failed to reach the Google datacenter. (Requests without google response headers).",
COUNT);

static final MeasureLong APPLICATION_LATENCIES =
MeasureLong.create(
"bigtable.googleapis.com/internal/client/application_latencies",
"The latency of the client application consuming available response data.",
MILLISECOND);

static final MeasureLong THROTTLING_LATENCIES =
MeasureLong.create(
"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);
}
194 changes: 194 additions & 0 deletions 194 ...ud-bigtable-stats/src/main/java/com/google/cloud/bigtable/stats/BuiltinViewConstants.java
Show comments
View file
Open in desktop
Original file line number Diff line number Diff line change
@@ -0,0 +1,194 @@
/*
* Copyright 2022 Google LLC
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* https://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
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 io.opencensus.stats.Aggregation.Distribution;
import static io.opencensus.stats.Aggregation.Sum;

import com.google.common.collect.ImmutableList;
import io.opencensus.stats.Aggregation;
import io.opencensus.stats.BucketBoundaries;
import io.opencensus.stats.View;

/** Create built-in metrics views under bigtable.googleapis.com/internal/client namespace */
class BuiltinViewConstants {
private static final Aggregation AGGREGATION_WITH_MILLIS_HISTOGRAM =
Distribution.create(
BucketBoundaries.create(
ImmutableList.of(
0.0, 0.01, 0.05, 0.1, 0.3, 0.6, 0.8, 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 8.0, 10.0,
13.0, 16.0, 20.0, 25.0, 30.0, 40.0, 50.0, 65.0, 80.0, 100.0, 130.0, 160.0, 200.0,
250.0, 300.0, 400.0, 500.0, 650.0, 800.0, 1000.0, 2000.0, 5000.0, 10000.0,
20000.0, 50000.0, 100000.0)));

private static final Aggregation AGGREGATION_RETRY_COUNT =
Distribution.create(
BucketBoundaries.create(
ImmutableList.of(
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 AGGREGATION_ERROR_COUNT = Sum.create();

static final View OPERATION_LATENCIES_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/operation_latencies"),
"Total time until final operation success or failure, including retries and backoff.",
OPERATION_LATENCIES,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STREAMING,
STATUS,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View ATTEMPT_LATENCIES_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/attempt_latencies"),
"Client observed latency per RPC attempt.",
ATTEMPT_LATENCIES,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STREAMING,
STATUS,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View RETRY_COUNT_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/retry_count"),
"The number of additional RPCs sent after the initial attempt.",
RETRY_COUNT,
AGGREGATION_RETRY_COUNT,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STATUS,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View FIRST_RESPONSE_LATENCIES_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/first_response_latencies"),
"Latency from operation start until the response headers were received. The publishing of the measurement will be delayed until the attempt response has been received.",
FIRST_RESPONSE_LATENCIES,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STATUS,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View SERVER_LATENCIES_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/server_latencies"),
"The latency measured from the moment that the RPC entered the Google data center until the RPC was completed.",
SERVER_LATENCIES,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STATUS,
STREAMING,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View CONNECTIVITY_ERROR_COUNT_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/connectivity_error_count"),
"Number of requests that failed to reach the Google datacenter. (Requests without google response headers).",
CONNECTIVITY_ERROR_COUNT,
AGGREGATION_ERROR_COUNT,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STATUS,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View APPLICATION_LATENCIES_VIEW =
View.create(
View.Name.create("bigtable.googleapis.com/internal/client/application_latencies"),
"The latency of the client application consuming available response data.",
APPLICATION_LATENCIES,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
ImmutableList.of(
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE,
METHOD,
STREAMING,
CLIENT_NAME,
CLUSTER,
ZONE,
TABLE));

static final View THROTTLING_LATENCIES_VIEW =
View.create(
View.Name.create("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.",
THROTTLING_LATENCIES,
AGGREGATION_WITH_MILLIS_HISTOGRAM,
ImmutableList.of(
PROJECT_ID, INSTANCE_ID, APP_PROFILE, METHOD, CLIENT_NAME, CLUSTER, ZONE, TABLE));
}
Loading
Oops, something went wrong.

Uh oh!

There was an error while loading. Please reload this page.

Add this suggestion to a batch that can be applied as a single commit. This suggestion is invalid because no changes were made to the code. Suggestions cannot be applied while the pull request is closed. Suggestions cannot be applied while viewing a subset of changes. Only one suggestion per line can be applied in a batch. Add this suggestion to a batch that can be applied as a single commit. Applying suggestions on deleted lines is not supported. You must change the existing code in this line in order to create a valid suggestion. Outdated suggestions cannot be applied. This suggestion has been applied or marked resolved. Suggestions cannot be applied from pending reviews. Suggestions cannot be applied on multi-line comments. Suggestions cannot be applied while the pull request is queued to merge. Suggestion cannot be applied right now. Please check back later.
You are visitor 01402775 — GeezerVison does not store the pages you look up.
Best viewed with Netscape Navigator 4.7 or Internet Explorer 6 at 800×600. No cookies required.