Skip to content

Commit b1fc00a

Browse files
feat: add built-in metric constants (#1243)
* feat: add built in metrics measure and views * remove status from application latency * Rename methods and add comments * update based on comments * add comment for client id * move dependency * use SUM for connectivity errors * update on comments * update dependencies * 🦉 Updates from OwlBot post-processor See https://github.com/googleapis/repo-automation-bots/blob/main/packages/owl-bot/README.md Co-authored-by: Owl Bot <gcf-owl-bot[bot]@users.noreply.github.com>
1 parent 4a3a2c9 commit b1fc00a

File tree

11 files changed

+1063
-33
lines changed

11 files changed

+1063
-33
lines changed

google-cloud-bigtable-bom/pom.xml

+5
Original file line numberDiff line numberDiff line change
@@ -94,6 +94,11 @@
9494
<artifactId>proto-google-cloud-bigtable-v2</artifactId>
9595
<version>2.8.1-SNAPSHOT</version><!-- {x-version-update:proto-google-cloud-bigtable-v2:current} -->
9696
</dependency>
97+
<dependency>
98+
<groupId>com.google.cloud</groupId>
99+
<artifactId>google-cloud-bigtable-stats</artifactId>
100+
<version>2.8.1-SNAPSHOT</version><!-- {x-version-update:google-cloud-bigtable:current} -->
101+
</dependency>
97102
</dependencies>
98103
</dependencyManagement>
99104

google-cloud-bigtable-stats/pom.xml

+24-7
Original file line numberDiff line numberDiff line change
@@ -29,17 +29,38 @@
2929
</dependencyManagement>
3030

3131
<dependencies>
32+
<dependency>
33+
<groupId>com.google.api</groupId>
34+
<artifactId>gax</artifactId>
35+
</dependency>
36+
<dependency>
37+
<groupId>com.google.api</groupId>
38+
<artifactId>api-common</artifactId>
39+
</dependency>
40+
3241
<dependency>
3342
<groupId>io.opencensus</groupId>
3443
<artifactId>opencensus-api</artifactId>
3544
</dependency>
45+
<dependency>
46+
<groupId>com.google.guava</groupId>
47+
<artifactId>guava</artifactId>
48+
</dependency>
49+
3650
<dependency>
3751
<groupId>io.opencensus</groupId>
3852
<artifactId>opencensus-impl</artifactId>
53+
<scope>test</scope>
3954
</dependency>
4055
<dependency>
41-
<groupId>io.opencensus</groupId>
42-
<artifactId>opencensus-exporter-stats-stackdriver</artifactId>
56+
<groupId>com.google.truth</groupId>
57+
<artifactId>truth</artifactId>
58+
<scope>test</scope>
59+
</dependency>
60+
<dependency>
61+
<groupId>junit</groupId>
62+
<artifactId>junit</artifactId>
63+
<scope>test</scope>
4364
</dependency>
4465
</dependencies>
4566

@@ -48,6 +69,7 @@
4869
<plugin>
4970
<groupId>org.apache.maven.plugins</groupId>
5071
<artifactId>maven-shade-plugin</artifactId>
72+
<version>3.2.4</version>
5173
<executions>
5274
<execution>
5375
<phase>package</phase>
@@ -78,11 +100,6 @@
78100
<groupId>org.apache.maven.plugins</groupId>
79101
<artifactId>maven-dependency-plugin</artifactId>
80102
<version>3.3.0</version>
81-
<configuration>
82-
<ignoredUnusedDeclaredDependencies>
83-
<ignoredUnusedDeclaredDependency>*</ignoredUnusedDeclaredDependency>
84-
</ignoredUnusedDeclaredDependencies>
85-
</configuration>
86103
</plugin>
87104
</plugins>
88105
</build>
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,92 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.bigtable.stats;
17+
18+
import static io.opencensus.stats.Measure.MeasureLong;
19+
20+
import io.opencensus.tags.TagKey;
21+
22+
/** Built-in metrics that will be readable under bigtable.googleapis.com/client namespace */
23+
class BuiltinMeasureConstants {
24+
// Monitored resource TagKeys
25+
static final TagKey PROJECT_ID = TagKey.create("project_id");
26+
static final TagKey INSTANCE_ID = TagKey.create("instance_id");
27+
static final TagKey CLUSTER = TagKey.create("cluster");
28+
static final TagKey TABLE = TagKey.create("table");
29+
static final TagKey ZONE = TagKey.create("zone");
30+
// Placeholder TagKey to be used in Stackdriver exporter
31+
static final TagKey CLIENT_ID = TagKey.create("client_id");
32+
33+
// Metrics TagKeys
34+
static final TagKey APP_PROFILE = TagKey.create("app_profile");
35+
static final TagKey METHOD = TagKey.create("method");
36+
static final TagKey STREAMING = TagKey.create("streaming");
37+
static final TagKey STATUS = TagKey.create("status");
38+
static final TagKey CLIENT_NAME = TagKey.create("client_name");
39+
40+
// Units
41+
private static final String COUNT = "1";
42+
private static final String MILLISECOND = "ms";
43+
44+
// Measurements
45+
static final MeasureLong OPERATION_LATENCIES =
46+
MeasureLong.create(
47+
"bigtable.googleapis.com/internal/client/operation_latencies",
48+
"Total time until final operation success or failure, including retries and backoff.",
49+
MILLISECOND);
50+
51+
static final MeasureLong ATTEMPT_LATENCIES =
52+
MeasureLong.create(
53+
"bigtable.googleapis.com/internal/client/attempt_latencies",
54+
"Client observed latency per RPC attempt.",
55+
MILLISECOND);
56+
57+
static final MeasureLong RETRY_COUNT =
58+
MeasureLong.create(
59+
"bigtable.googleapis.com/internal/client/retry_count",
60+
"The number of additional RPCs sent after the initial attempt.",
61+
COUNT);
62+
63+
static final MeasureLong FIRST_RESPONSE_LATENCIES =
64+
MeasureLong.create(
65+
"bigtable.googleapis.com/internal/client/first_response_latencies",
66+
"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.",
67+
MILLISECOND);
68+
69+
static final MeasureLong SERVER_LATENCIES =
70+
MeasureLong.create(
71+
"bigtable.googleapis.com/internal/client/server_latencies",
72+
"The latency measured from the moment that the RPC entered the Google data center until the RPC was completed.",
73+
MILLISECOND);
74+
75+
static final MeasureLong CONNECTIVITY_ERROR_COUNT =
76+
MeasureLong.create(
77+
"bigtable.googleapis.com/internal/client/connectivity_error_count",
78+
"Number of requests that failed to reach the Google datacenter. (Requests without google response headers).",
79+
COUNT);
80+
81+
static final MeasureLong APPLICATION_LATENCIES =
82+
MeasureLong.create(
83+
"bigtable.googleapis.com/internal/client/application_latencies",
84+
"The latency of the client application consuming available response data.",
85+
MILLISECOND);
86+
87+
static final MeasureLong THROTTLING_LATENCIES =
88+
MeasureLong.create(
89+
"bigtable.googleapis.com/internal/client/throttling_latencies",
90+
"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.",
91+
MILLISECOND);
92+
}
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,194 @@
1+
/*
2+
* Copyright 2022 Google LLC
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* https://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
package com.google.cloud.bigtable.stats;
17+
18+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.APPLICATION_LATENCIES;
19+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.APP_PROFILE;
20+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.ATTEMPT_LATENCIES;
21+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CLIENT_NAME;
22+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CLUSTER;
23+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.CONNECTIVITY_ERROR_COUNT;
24+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.FIRST_RESPONSE_LATENCIES;
25+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.INSTANCE_ID;
26+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.METHOD;
27+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.OPERATION_LATENCIES;
28+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.PROJECT_ID;
29+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.RETRY_COUNT;
30+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.SERVER_LATENCIES;
31+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.STATUS;
32+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.STREAMING;
33+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.TABLE;
34+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.THROTTLING_LATENCIES;
35+
import static com.google.cloud.bigtable.stats.BuiltinMeasureConstants.ZONE;
36+
import static io.opencensus.stats.Aggregation.Distribution;
37+
import static io.opencensus.stats.Aggregation.Sum;
38+
39+
import com.google.common.collect.ImmutableList;
40+
import io.opencensus.stats.Aggregation;
41+
import io.opencensus.stats.BucketBoundaries;
42+
import io.opencensus.stats.View;
43+
44+
/** Create built-in metrics views under bigtable.googleapis.com/internal/client namespace */
45+
class BuiltinViewConstants {
46+
private static final Aggregation AGGREGATION_WITH_MILLIS_HISTOGRAM =
47+
Distribution.create(
48+
BucketBoundaries.create(
49+
ImmutableList.of(
50+
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,
51+
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,
52+
250.0, 300.0, 400.0, 500.0, 650.0, 800.0, 1000.0, 2000.0, 5000.0, 10000.0,
53+
20000.0, 50000.0, 100000.0)));
54+
55+
private static final Aggregation AGGREGATION_RETRY_COUNT =
56+
Distribution.create(
57+
BucketBoundaries.create(
58+
ImmutableList.of(
59+
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,
60+
100.0)));
61+
62+
private static final Aggregation AGGREGATION_ERROR_COUNT = Sum.create();
63+
64+
static final View OPERATION_LATENCIES_VIEW =
65+
View.create(
66+
View.Name.create("bigtable.googleapis.com/internal/client/operation_latencies"),
67+
"Total time until final operation success or failure, including retries and backoff.",
68+
OPERATION_LATENCIES,
69+
AGGREGATION_WITH_MILLIS_HISTOGRAM,
70+
ImmutableList.of(
71+
PROJECT_ID,
72+
INSTANCE_ID,
73+
APP_PROFILE,
74+
METHOD,
75+
STREAMING,
76+
STATUS,
77+
CLIENT_NAME,
78+
CLUSTER,
79+
ZONE,
80+
TABLE));
81+
82+
static final View ATTEMPT_LATENCIES_VIEW =
83+
View.create(
84+
View.Name.create("bigtable.googleapis.com/internal/client/attempt_latencies"),
85+
"Client observed latency per RPC attempt.",
86+
ATTEMPT_LATENCIES,
87+
AGGREGATION_WITH_MILLIS_HISTOGRAM,
88+
ImmutableList.of(
89+
PROJECT_ID,
90+
INSTANCE_ID,
91+
APP_PROFILE,
92+
METHOD,
93+
STREAMING,
94+
STATUS,
95+
CLIENT_NAME,
96+
CLUSTER,
97+
ZONE,
98+
TABLE));
99+
100+
static final View RETRY_COUNT_VIEW =
101+
View.create(
102+
View.Name.create("bigtable.googleapis.com/internal/client/retry_count"),
103+
"The number of additional RPCs sent after the initial attempt.",
104+
RETRY_COUNT,
105+
AGGREGATION_RETRY_COUNT,
106+
ImmutableList.of(
107+
PROJECT_ID,
108+
INSTANCE_ID,
109+
APP_PROFILE,
110+
METHOD,
111+
STATUS,
112+
CLIENT_NAME,
113+
CLUSTER,
114+
ZONE,
115+
TABLE));
116+
117+
static final View FIRST_RESPONSE_LATENCIES_VIEW =
118+
View.create(
119+
View.Name.create("bigtable.googleapis.com/internal/client/first_response_latencies"),
120+
"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.",
121+
FIRST_RESPONSE_LATENCIES,
122+
AGGREGATION_WITH_MILLIS_HISTOGRAM,
123+
ImmutableList.of(
124+
PROJECT_ID,
125+
INSTANCE_ID,
126+
APP_PROFILE,
127+
METHOD,
128+
STATUS,
129+
CLIENT_NAME,
130+
CLUSTER,
131+
ZONE,
132+
TABLE));
133+
134+
static final View SERVER_LATENCIES_VIEW =
135+
View.create(
136+
View.Name.create("bigtable.googleapis.com/internal/client/server_latencies"),
137+
"The latency measured from the moment that the RPC entered the Google data center until the RPC was completed.",
138+
SERVER_LATENCIES,
139+
AGGREGATION_WITH_MILLIS_HISTOGRAM,
140+
ImmutableList.of(
141+
PROJECT_ID,
142+
INSTANCE_ID,
143+
APP_PROFILE,
144+
METHOD,
145+
STATUS,
146+
STREAMING,
147+
CLIENT_NAME,
148+
CLUSTER,
149+
ZONE,
150+
TABLE));
151+
152+
static final View CONNECTIVITY_ERROR_COUNT_VIEW =
153+
View.create(
154+
View.Name.create("bigtable.googleapis.com/internal/client/connectivity_error_count"),
155+
"Number of requests that failed to reach the Google datacenter. (Requests without google response headers).",
156+
CONNECTIVITY_ERROR_COUNT,
157+
AGGREGATION_ERROR_COUNT,
158+
ImmutableList.of(
159+
PROJECT_ID,
160+
INSTANCE_ID,
161+
APP_PROFILE,
162+
METHOD,
163+
STATUS,
164+
CLIENT_NAME,
165+
CLUSTER,
166+
ZONE,
167+
TABLE));
168+
169+
static final View APPLICATION_LATENCIES_VIEW =
170+
View.create(
171+
View.Name.create("bigtable.googleapis.com/internal/client/application_latencies"),
172+
"The latency of the client application consuming available response data.",
173+
APPLICATION_LATENCIES,
174+
AGGREGATION_WITH_MILLIS_HISTOGRAM,
175+
ImmutableList.of(
176+
PROJECT_ID,
177+
INSTANCE_ID,
178+
APP_PROFILE,
179+
METHOD,
180+
STREAMING,
181+
CLIENT_NAME,
182+
CLUSTER,
183+
ZONE,
184+
TABLE));
185+
186+
static final View THROTTLING_LATENCIES_VIEW =
187+
View.create(
188+
View.Name.create("bigtable.googleapis.com/internal/client/throttling_latencies"),
189+
"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.",
190+
THROTTLING_LATENCIES,
191+
AGGREGATION_WITH_MILLIS_HISTOGRAM,
192+
ImmutableList.of(
193+
PROJECT_ID, INSTANCE_ID, APP_PROFILE, METHOD, CLIENT_NAME, CLUSTER, ZONE, TABLE));
194+
}

0 commit comments

Comments
 (0)