diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java index bd53d6d4d..20e7eb371 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracer.java @@ -79,9 +79,9 @@ class BuiltinMetricsTracer extends BigtableTracer { private final AtomicInteger requestLeft = new AtomicInteger(0); // Monitored resource labels - private String tableId = "unspecified"; + private String tableId = ""; private String zone = "global"; - private String cluster = "unspecified"; + private String cluster = ""; private final AtomicLong totalClientBlockingTime = new AtomicLong(0); diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/Util.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/Util.java index 4c3fd7a42..590917c81 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/Util.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/Util.java @@ -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; @@ -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 ""; } /** diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/StreamingMetricsMetadataIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/StreamingMetricsMetadataIT.java index 84ab24f1c..11da6a6c1 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/StreamingMetricsMetadataIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/StreamingMetricsMetadataIT.java @@ -167,9 +167,9 @@ public void testFailure() { assertThat(pointData) .comparingElementsUsing(POINT_DATA_CLUSTER_ID_CONTAINS) - .contains("unspecified"); + .contains(""); assertThat(pointData).comparingElementsUsing(POINT_DATA_ZONE_ID_CONTAINS).contains("global"); - assertThat(clusterAttributes).contains("unspecified"); + assertThat(clusterAttributes).contains(""); assertThat(zoneAttributes).contains("global"); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/UnaryMetricsMetadataIT.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/UnaryMetricsMetadataIT.java index 42adb8ea6..a6e4f9e88 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/UnaryMetricsMetadataIT.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/it/UnaryMetricsMetadataIT.java @@ -182,7 +182,7 @@ public void testFailure() throws Exception { assertThat(pointData) .comparingElementsUsing(POINT_DATA_CLUSTER_ID_CONTAINS) - .contains("unspecified"); + .contains(""); assertThat(pointData).comparingElementsUsing(POINT_DATA_ZONE_ID_CONTAINS).contains("global"); List clusterAttributes = pointData.stream() @@ -193,7 +193,7 @@ public void testFailure() throws Exception { .map(pd -> pd.getAttributes().get(BuiltinMetricsConstants.ZONE_ID_KEY)) .collect(Collectors.toList()); - assertThat(clusterAttributes).contains("unspecified"); + assertThat(clusterAttributes).contains(""); assertThat(zoneAttributes).contains("global"); } } diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java index e902f0271..ada734d46 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsTracerTest.java @@ -396,7 +396,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, "") .put(METHOD_KEY, "Bigtable.ReadRows") .put(CLIENT_NAME_KEY, CLIENT_NAME) .build(); @@ -550,7 +550,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, "") .put(METHOD_KEY, "Bigtable.MutateRow") .put(CLIENT_NAME_KEY, CLIENT_NAME) .put(STREAMING_KEY, false) @@ -620,7 +620,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, "") .put(METHOD_KEY, "Bigtable.MutateRows") .put(CLIENT_NAME_KEY, CLIENT_NAME) .put(STREAMING_KEY, false) @@ -641,7 +641,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, "") .put(METHOD_KEY, "Bigtable.ReadRows") .put(CLIENT_NAME_KEY, CLIENT_NAME) .put(STREAMING_KEY, true) @@ -752,7 +752,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, "") .put(ZONE_ID_KEY, "global") .put(STREAMING_KEY, true) .put(METHOD_KEY, "Bigtable.ReadRows")