Skip to content

Commit

Permalink
update constant name
Browse files Browse the repository at this point in the history
  • Loading branch information
mutianf committed Mar 11, 2024
1 parent 4dacd1e commit 2ab56d1
Show file tree
Hide file tree
Showing 6 changed files with 18 additions and 16 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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(),
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;

Expand Down Expand Up @@ -80,7 +80,8 @@ class BigtableExporterUtils {

// These metric labels will be promoted to the bigtable_table monitored resource fields
private static final Set<AttributeKey<String>> 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() {}

Expand All @@ -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<TimeSeries> convertToBigtableTimeSeries(List<MetricData> collection, String taskId) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,8 @@
public class BuiltinMetricsConstants {

// Metric attribute keys for monitored resource
public static final AttributeKey<String> PROJECT_ID_KEY = AttributeKey.stringKey("project_id");
public static final AttributeKey<String> BIGTABLE_PROJECT_ID_KEY =
AttributeKey.stringKey("project_id");
public static final AttributeKey<String> INSTANCE_ID_KEY = AttributeKey.stringKey("instance");
public static final AttributeKey<String> TABLE_ID_KEY = AttributeKey.stringKey("table");
public static final AttributeKey<String> CLUSTER_ID_KEY = AttributeKey.stringKey("cluster");
Expand Down Expand Up @@ -99,7 +100,7 @@ public class BuiltinMetricsConstants {

static final Set<AttributeKey> COMMON_ATTRIBUTES =
ImmutableSet.of(
PROJECT_ID_KEY,
BIGTABLE_PROJECT_ID_KEY,
INSTANCE_ID_KEY,
TABLE_ID_KEY,
APP_PROFILE_KEY,
Expand Down Expand Up @@ -211,7 +212,7 @@ public static Map<InstrumentSelector, View> getAllViews() {
InstrumentType.HISTOGRAM,
"1",
ImmutableSet.<AttributeKey>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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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)
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -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,
Expand Down Expand Up @@ -253,7 +253,7 @@ public void testTimeSeriesForMetricWithGceOrGkeResource() {
startEpoch,
endEpoch,
Attributes.of(
PROJECT_ID_KEY,
BIGTABLE_PROJECT_ID_KEY,
projectId,
INSTANCE_ID_KEY,
instanceId,
Expand Down Expand Up @@ -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())
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand Down

0 comments on commit 2ab56d1

Please sign in to comment.