Skip to content

Commit

Permalink
feat: append version to the client name in client-side metrics. (#2062)
Browse files Browse the repository at this point in the history
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 #2061 ☕️

If you write sample code, please follow the [samples format](
https://togithub.com/GoogleCloudPlatform/java-docs-samples/blob/main/SAMPLE_FORMAT.md).
  • Loading branch information
rkaregar committed Jan 25, 2024
1 parent d51d8d0 commit 9a0cdc8
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 19 deletions.
Expand Up @@ -123,7 +123,6 @@ private TagContextBuilder newTagContextBuilder(String tableId, String zone, Stri
TagContextBuilder tagContextBuilder =
tagger
.toBuilder(parentContext)
.putLocal(BuiltinMeasureConstants.CLIENT_NAME, TagValue.create("bigtable-java"))
.putLocal(BuiltinMeasureConstants.METHOD, TagValue.create(spanName.toString()))
.putLocal(BuiltinMeasureConstants.TABLE, TagValue.create(tableId))
.putLocal(BuiltinMeasureConstants.ZONE, TagValue.create(zone))
Expand Down
Expand Up @@ -51,6 +51,7 @@ public class StatsRecorderWrapperTest {
private final String TABLE_ID = "fake-table-id";
private final String ZONE = "fake-zone";
private final String CLUSTER = "fake-cluster";
private final String CLIENT_AND_VERSION = "bigtable-java/fake-version";

private final StatsComponent statsComponent = new StatsComponentImpl();

Expand All @@ -72,7 +73,9 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.INSTANCE_ID.getName(),
INSTANCE_ID,
BuiltinMeasureConstants.APP_PROFILE.getName(),
APP_PROFILE_ID),
APP_PROFILE_ID,
BuiltinMeasureConstants.CLIENT_NAME.getName(),
CLIENT_AND_VERSION),
statsComponent.getStatsRecorder());

long operationLatency = 1234;
Expand Down Expand Up @@ -107,7 +110,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.TABLE, TABLE_ID,
BuiltinMeasureConstants.ZONE, ZONE,
BuiltinMeasureConstants.CLUSTER, CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME, "bigtable-java",
BuiltinMeasureConstants.CLIENT_NAME, CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING, "true"),
PROJECT_ID,
INSTANCE_ID,
Expand All @@ -129,7 +132,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"true"),
PROJECT_ID,
Expand All @@ -152,7 +155,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java"),
CLIENT_AND_VERSION),
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE_ID,
Expand All @@ -167,7 +170,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.STATUS,
"OK",
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"true",
BuiltinMeasureConstants.TABLE,
Expand Down Expand Up @@ -196,7 +199,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"true"),
PROJECT_ID,
Expand All @@ -213,7 +216,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.STATUS,
"OK",
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.TABLE,
TABLE_ID,
BuiltinMeasureConstants.ZONE,
Expand All @@ -233,7 +236,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.TABLE, TABLE_ID,
BuiltinMeasureConstants.ZONE, ZONE,
BuiltinMeasureConstants.CLUSTER, CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME, "bigtable-java"),
BuiltinMeasureConstants.CLIENT_NAME, CLIENT_AND_VERSION),
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE_ID,
Expand All @@ -254,7 +257,7 @@ public void testStreamingOperation() throws InterruptedException {
BuiltinMeasureConstants.STATUS,
"OK",
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java"),
CLIENT_AND_VERSION),
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE_ID,
Expand All @@ -271,7 +274,8 @@ public void testUnaryOperations() throws InterruptedException {
ImmutableMap.of(
BuiltinMeasureConstants.PROJECT_ID.getName(), PROJECT_ID,
BuiltinMeasureConstants.INSTANCE_ID.getName(), INSTANCE_ID,
BuiltinMeasureConstants.APP_PROFILE.getName(), APP_PROFILE_ID),
BuiltinMeasureConstants.APP_PROFILE.getName(), APP_PROFILE_ID,
BuiltinMeasureConstants.CLIENT_NAME.getName(), CLIENT_AND_VERSION),
statsComponent.getStatsRecorder());

long operationLatency = 1234;
Expand Down Expand Up @@ -312,7 +316,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"false"),
PROJECT_ID,
Expand All @@ -335,7 +339,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"false"),
PROJECT_ID,
Expand All @@ -358,7 +362,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java"),
CLIENT_AND_VERSION),
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE_ID,
Expand All @@ -373,7 +377,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.STATUS,
"UNAVAILABLE",
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"false",
BuiltinMeasureConstants.TABLE,
Expand Down Expand Up @@ -402,7 +406,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.CLUSTER,
CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.STREAMING,
"false"),
PROJECT_ID,
Expand All @@ -419,7 +423,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.STATUS,
"UNAVAILABLE",
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java",
CLIENT_AND_VERSION,
BuiltinMeasureConstants.TABLE,
TABLE_ID,
BuiltinMeasureConstants.ZONE,
Expand All @@ -439,7 +443,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.TABLE, TABLE_ID,
BuiltinMeasureConstants.ZONE, ZONE,
BuiltinMeasureConstants.CLUSTER, CLUSTER,
BuiltinMeasureConstants.CLIENT_NAME, "bigtable-java"),
BuiltinMeasureConstants.CLIENT_NAME, CLIENT_AND_VERSION),
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE_ID,
Expand All @@ -460,7 +464,7 @@ public void testUnaryOperations() throws InterruptedException {
BuiltinMeasureConstants.STATUS,
"UNAVAILABLE",
BuiltinMeasureConstants.CLIENT_NAME,
"bigtable-java"),
CLIENT_AND_VERSION),
PROJECT_ID,
INSTANCE_ID,
APP_PROFILE_ID,
Expand Down
Expand Up @@ -259,6 +259,7 @@ public static ApiTracerFactory createBigtableTracerFactory(
.put("project_id", projectId)
.put("instance", instanceId)
.put("app_profile", appProfileId)
.put("client_name", "bigtable-java/" + Version.VERSION)
.build();

return new CompositeTracerFactory(
Expand Down

0 comments on commit 9a0cdc8

Please sign in to comment.