From 2ab56d148f98fe5cd7e3d37d1c9bd1a8f46f8e03 Mon Sep 17 00:00:00 2001 From: Mattie Fu Date: Mon, 11 Mar 2024 15:17:41 -0400 Subject: [PATCH] update constant name --- .../bigtable/data/v2/stub/EnhancedBigtableStub.java | 4 ++-- .../data/v2/stub/metrics/BigtableExporterUtils.java | 7 ++++--- .../v2/stub/metrics/BuiltinMetricsConstants.java | 7 ++++--- .../metrics/BigtableCloudMonitoringExporterTest.java | 12 ++++++------ .../v2/stub/metrics/BuiltinMetricsTracerTest.java | 2 +- .../v2/stub/metrics/ErrorCountPerConnectionTest.java | 2 +- 6 files changed, 18 insertions(+), 16 deletions(-) diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java index 172152b318..65cb4afa37 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/EnhancedBigtableStub.java @@ -16,9 +16,9 @@ package com.google.cloud.bigtable.data.v2.stub; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.APP_PROFILE_KEY; +import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.BIGTABLE_PROJECT_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLIENT_NAME_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.INSTANCE_ID_KEY; -import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.PROJECT_ID_KEY; import com.google.api.core.ApiFunction; import com.google.api.core.BetaApi; @@ -359,7 +359,7 @@ public static OpenTelemetry getOpenTelemetry( private static Attributes createBuiltinAttributes(EnhancedBigtableStubSettings settings) { return Attributes.of( - PROJECT_ID_KEY, + BIGTABLE_PROJECT_ID_KEY, settings.getProjectId(), INSTANCE_ID_KEY, settings.getInstanceId(), diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableExporterUtils.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableExporterUtils.java index 341a7d84d6..9a4d928ce4 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableExporterUtils.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableExporterUtils.java @@ -25,11 +25,11 @@ import static com.google.api.MetricDescriptor.ValueType.DISTRIBUTION; import static com.google.api.MetricDescriptor.ValueType.DOUBLE; import static com.google.api.MetricDescriptor.ValueType.INT64; +import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.BIGTABLE_PROJECT_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLIENT_UID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLUSTER_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.INSTANCE_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.METER_NAME; -import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.PROJECT_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.TABLE_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.ZONE_ID_KEY; @@ -80,7 +80,8 @@ class BigtableExporterUtils { // These metric labels will be promoted to the bigtable_table monitored resource fields private static final Set> BIGTABLE_PROMOTED_RESOURCE_LABELS = - ImmutableSet.of(PROJECT_ID_KEY, INSTANCE_ID_KEY, TABLE_ID_KEY, CLUSTER_ID_KEY, ZONE_ID_KEY); + ImmutableSet.of( + BIGTABLE_PROJECT_ID_KEY, INSTANCE_ID_KEY, TABLE_ID_KEY, CLUSTER_ID_KEY, ZONE_ID_KEY); private BigtableExporterUtils() {} @@ -106,7 +107,7 @@ static String getDefaultTaskValue() { } static String getProjectId(PointData pointData) { - return pointData.getAttributes().get(PROJECT_ID_KEY); + return pointData.getAttributes().get(BIGTABLE_PROJECT_ID_KEY); } static List convertToBigtableTimeSeries(List collection, String taskId) { diff --git a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsConstants.java b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsConstants.java index b26557999a..f9f0579ca2 100644 --- a/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsConstants.java +++ b/google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsConstants.java @@ -33,7 +33,8 @@ public class BuiltinMetricsConstants { // Metric attribute keys for monitored resource - public static final AttributeKey PROJECT_ID_KEY = AttributeKey.stringKey("project_id"); + public static final AttributeKey BIGTABLE_PROJECT_ID_KEY = + AttributeKey.stringKey("project_id"); public static final AttributeKey INSTANCE_ID_KEY = AttributeKey.stringKey("instance"); public static final AttributeKey TABLE_ID_KEY = AttributeKey.stringKey("table"); public static final AttributeKey CLUSTER_ID_KEY = AttributeKey.stringKey("cluster"); @@ -99,7 +100,7 @@ public class BuiltinMetricsConstants { static final Set COMMON_ATTRIBUTES = ImmutableSet.of( - PROJECT_ID_KEY, + BIGTABLE_PROJECT_ID_KEY, INSTANCE_ID_KEY, TABLE_ID_KEY, APP_PROFILE_KEY, @@ -211,7 +212,7 @@ public static Map getAllViews() { InstrumentType.HISTOGRAM, "1", ImmutableSet.builder() - .add(PROJECT_ID_KEY, INSTANCE_ID_KEY, APP_PROFILE_KEY, CLIENT_NAME_KEY) + .add(BIGTABLE_PROJECT_ID_KEY, INSTANCE_ID_KEY, APP_PROFILE_KEY, CLIENT_NAME_KEY) .build()); return views.build(); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporterTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporterTest.java index 7c9f68982c..151041bff5 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporterTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/BigtableCloudMonitoringExporterTest.java @@ -16,11 +16,11 @@ package com.google.cloud.bigtable.data.v2.stub.metrics; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.APP_PROFILE_KEY; +import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.BIGTABLE_PROJECT_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLIENT_NAME_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLIENT_UID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.CLUSTER_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.INSTANCE_ID_KEY; -import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.PROJECT_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.TABLE_ID_KEY; import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.ZONE_ID_KEY; import static com.google.common.truth.Truth.assertThat; @@ -92,7 +92,7 @@ public void setUp() { attributes = Attributes.builder() - .put(PROJECT_ID_KEY, projectId) + .put(BIGTABLE_PROJECT_ID_KEY, projectId) .put(INSTANCE_ID_KEY, instanceId) .put(TABLE_ID_KEY, tableId) .put(CLUSTER_ID_KEY, cluster) @@ -145,7 +145,7 @@ public void testExportingSumData() { assertThat(timeSeries.getResource().getLabelsMap()) .containsExactly( - PROJECT_ID_KEY.getKey(), projectId, + BIGTABLE_PROJECT_ID_KEY.getKey(), projectId, INSTANCE_ID_KEY.getKey(), instanceId, TABLE_ID_KEY.getKey(), tableId, CLUSTER_ID_KEY.getKey(), cluster, @@ -207,7 +207,7 @@ public void testExportingHistogramData() { assertThat(timeSeries.getResource().getLabelsMap()) .containsExactly( - PROJECT_ID_KEY.getKey(), projectId, + BIGTABLE_PROJECT_ID_KEY.getKey(), projectId, INSTANCE_ID_KEY.getKey(), instanceId, TABLE_ID_KEY.getKey(), tableId, CLUSTER_ID_KEY.getKey(), cluster, @@ -253,7 +253,7 @@ public void testTimeSeriesForMetricWithGceOrGkeResource() { startEpoch, endEpoch, Attributes.of( - PROJECT_ID_KEY, + BIGTABLE_PROJECT_ID_KEY, projectId, INSTANCE_ID_KEY, instanceId, @@ -293,7 +293,7 @@ public void testTimeSeriesForMetricWithGceOrGkeResource() { assertThat(timeSeries.getMetric().getLabelsMap()).hasSize(5); assertThat(timeSeries.getMetric().getLabelsMap()) - .containsAtLeast(PROJECT_ID_KEY.getKey(), projectId); + .containsAtLeast(BIGTABLE_PROJECT_ID_KEY.getKey(), projectId); assertThat(timeSeries.getMetric().getLabelsMap()) .containsAtLeast(INSTANCE_ID_KEY.getKey(), instanceId); assertThat(timeSeries.getMetric().getLabelsMap()) 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 3a601e5036..9ab666a06d 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 @@ -147,7 +147,7 @@ public void setUp() throws Exception { baseAttributes = Attributes.builder() - .put(BuiltinMetricsConstants.PROJECT_ID_KEY, PROJECT_ID) + .put(BuiltinMetricsConstants.BIGTABLE_PROJECT_ID_KEY, PROJECT_ID) .put(BuiltinMetricsConstants.INSTANCE_ID_KEY, INSTANCE_ID) .put(BuiltinMetricsConstants.APP_PROFILE_KEY, APP_PROFILE_ID) .build(); diff --git a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/ErrorCountPerConnectionTest.java b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/ErrorCountPerConnectionTest.java index dec5120b1c..4ab19a5337 100644 --- a/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/ErrorCountPerConnectionTest.java +++ b/google-cloud-bigtable/src/test/java/com/google/cloud/bigtable/data/v2/stub/metrics/ErrorCountPerConnectionTest.java @@ -76,7 +76,7 @@ public void setup() throws Exception { attributes = Attributes.builder() - .put(BuiltinMetricsConstants.PROJECT_ID_KEY, "fake-project") + .put(BuiltinMetricsConstants.BIGTABLE_PROJECT_ID_KEY, "fake-project") .put(BuiltinMetricsConstants.INSTANCE_ID_KEY, "fake-instance") .put(BuiltinMetricsConstants.APP_PROFILE_KEY, "") .put(BuiltinMetricsConstants.CLIENT_NAME_KEY, "bigtable-java/" + Version.VERSION)