Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: make client side metrics tag in sync with server #2401

Merged
merged 4 commits into from
Nov 19, 2024
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -75,9 +75,9 @@ class BuiltinMetricsTracer extends BigtableTracer {
private final AtomicInteger requestLeft = new AtomicInteger(0);

// Monitored resource labels
private String tableId = "unspecified";
private String tableId = "<unspecified>";
private String zone = "global";
private String cluster = "unspecified";
private String cluster = "<unspecified>";

private final AtomicLong totalClientBlockingTime = new AtomicLong(0);

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -24,8 +24,10 @@
import com.google.api.gax.rpc.StatusCode.Code;
import com.google.bigtable.v2.AuthorizedViewName;
import com.google.bigtable.v2.CheckAndMutateRowRequest;
import com.google.bigtable.v2.GenerateInitialChangeStreamPartitionsRequest;
import com.google.bigtable.v2.MutateRowRequest;
import com.google.bigtable.v2.MutateRowsRequest;
import com.google.bigtable.v2.ReadChangeStreamRequest;
import com.google.bigtable.v2.ReadModifyWriteRowRequest;
import com.google.bigtable.v2.ReadRowsRequest;
import com.google.bigtable.v2.ResponseParams;
Expand Down Expand Up @@ -127,14 +129,18 @@ static String extractTableId(Object request) {
} else if (request instanceof ReadModifyWriteRowRequest) {
tableName = ((ReadModifyWriteRowRequest) request).getTableName();
authorizedViewName = ((ReadModifyWriteRowRequest) request).getAuthorizedViewName();
} else if (request instanceof GenerateInitialChangeStreamPartitionsRequest) {
tableName = ((GenerateInitialChangeStreamPartitionsRequest) request).getTableName();
} else if (request instanceof ReadChangeStreamRequest) {
tableName = ((ReadChangeStreamRequest) request).getTableName();
}
if (tableName == null && authorizedViewName == null) return "undefined";
if (tableName.isEmpty() && authorizedViewName.isEmpty()) return "undefined";
if (!tableName.isEmpty()) {
if (tableName != null && !tableName.isEmpty()) {
return TableName.parse(tableName).getTable();
} else {
}
if (authorizedViewName != null && !authorizedViewName.isEmpty()) {
return AuthorizedViewName.parse(authorizedViewName).getTable();
}
return "<unspecified>";
}

/**
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -381,7 +381,7 @@ public void testGfeMetrics() {
.put(STATUS_KEY, "UNAVAILABLE")
.put(TABLE_ID_KEY, TABLE)
.put(ZONE_ID_KEY, "global")
.put(CLUSTER_ID_KEY, "unspecified")
.put(CLUSTER_ID_KEY, "<unspecified>")
.put(METHOD_KEY, "Bigtable.ReadRows")
.put(CLIENT_NAME_KEY, CLIENT_NAME)
.build();
Expand Down Expand Up @@ -535,7 +535,7 @@ public void testMutateRowAttemptsTagValues() {
.put(STATUS_KEY, "UNAVAILABLE")
.put(TABLE_ID_KEY, TABLE)
.put(ZONE_ID_KEY, "global")
.put(CLUSTER_ID_KEY, "unspecified")
.put(CLUSTER_ID_KEY, "<unspecified>")
.put(METHOD_KEY, "Bigtable.MutateRow")
.put(CLIENT_NAME_KEY, CLIENT_NAME)
.put(STREAMING_KEY, false)
Expand Down Expand Up @@ -605,7 +605,7 @@ public void testMutateRowsRpcError() {
.put(STATUS_KEY, "NOT_FOUND")
.put(TABLE_ID_KEY, BAD_TABLE_ID)
.put(ZONE_ID_KEY, "global")
.put(CLUSTER_ID_KEY, "unspecified")
.put(CLUSTER_ID_KEY, "<unspecified>")
.put(METHOD_KEY, "Bigtable.MutateRows")
.put(CLIENT_NAME_KEY, CLIENT_NAME)
.put(STREAMING_KEY, false)
Expand All @@ -626,7 +626,7 @@ public void testReadRowsAttemptsTagValues() {
.put(STATUS_KEY, "UNAVAILABLE")
.put(TABLE_ID_KEY, TABLE)
.put(ZONE_ID_KEY, "global")
.put(CLUSTER_ID_KEY, "unspecified")
.put(CLUSTER_ID_KEY, "<unspecified>")
.put(METHOD_KEY, "Bigtable.ReadRows")
.put(CLIENT_NAME_KEY, CLIENT_NAME)
.put(STREAMING_KEY, true)
Expand Down Expand Up @@ -737,7 +737,7 @@ public void testPermanentFailure() {
.toBuilder()
.put(STATUS_KEY, "NOT_FOUND")
.put(TABLE_ID_KEY, BAD_TABLE_ID)
.put(CLUSTER_ID_KEY, "unspecified")
.put(CLUSTER_ID_KEY, "<unspecified>")
.put(ZONE_ID_KEY, "global")
.put(STREAMING_KEY, true)
.put(METHOD_KEY, "Bigtable.ReadRows")
Expand Down
Loading