Skip to content
This repository was archived by the owner on May 8, 2026. It is now read-only.

Commit 6f83f73

Browse files
committed
fix: fix outstanding rpc metric
1 parent de1669e commit 6f83f73

2 files changed

Lines changed: 10 additions & 8 deletions

File tree

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/BuiltinMetricsConstants.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -81,6 +81,7 @@ public class BuiltinMetricsConstants {
8181
static final AttributeKey<String> GRPC_XDS_SERVER_KEY = AttributeKey.stringKey("grpc.xds.server");
8282
static final AttributeKey<String> GRPC_XDS_RESOURCE_TYPE_KEY =
8383
AttributeKey.stringKey("grpc.xds.resource_type");
84+
static final AttributeKey<String> GRPC_LB_POLICY_KEY = AttributeKey.stringKey("lb_policy");
8485

8586
public static final String METER_NAME = "bigtable.googleapis.com/internal/client/";
8687

@@ -246,8 +247,6 @@ static void defineView(
246247
.build();
247248
Set<String> attributesFilter =
248249
ImmutableSet.<String>builder()
249-
.addAll(
250-
COMMON_ATTRIBUTES.stream().map(AttributeKey::getKey).collect(Collectors.toSet()))
251250
.addAll(attributes.stream().map(AttributeKey::getKey).collect(Collectors.toSet()))
252251
.build();
253252
ViewBuilder viewBuilder =
@@ -277,7 +276,7 @@ public static Map<InstrumentSelector, View> getInternalViews() {
277276
InstrumentType.HISTOGRAM,
278277
"1",
279278
ImmutableSet.<AttributeKey>builder()
280-
.add(BIGTABLE_PROJECT_ID_KEY, INSTANCE_ID_KEY, APP_PROFILE_KEY, CLIENT_NAME_KEY)
279+
.add(TRANSPORT_TYPE, GRPC_LB_POLICY_KEY, STREAMING_KEY)
281280
.build());
282281
return views.build();
283282
}

google-cloud-bigtable/src/main/java/com/google/cloud/bigtable/data/v2/stub/metrics/ChannelPoolMetricsTracer.java

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,12 @@
1515
*/
1616
package com.google.cloud.bigtable.data.v2.stub.metrics;
1717

18+
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.GRPC_LB_POLICY_KEY;
1819
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.METER_NAME;
1920
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.OUTSTANDING_RPCS_PER_CHANNEL_NAME;
2021
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.PER_CONNECTION_ERROR_COUNT_NAME;
22+
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.STREAMING_KEY;
23+
import static com.google.cloud.bigtable.data.v2.stub.metrics.BuiltinMetricsConstants.TRANSPORT_TYPE;
2124

2225
import com.google.api.core.InternalApi;
2326
import com.google.cloud.bigtable.gaxx.grpc.BigtableChannelObserver;
@@ -103,9 +106,9 @@ public void run() {
103106

104107
// Build attributes if they haven't been built yet.
105108
if (unaryAttributes == null || streamingAttributes == null) {
106-
Attributes baseAttrs = commonAttrs.toBuilder().put("lb_policy", lbPolicy).build();
107-
this.unaryAttributes = baseAttrs.toBuilder().put("streaming", false).build();
108-
this.streamingAttributes = baseAttrs.toBuilder().put("streaming", true).build();
109+
Attributes baseAttrs = Attributes.of(GRPC_LB_POLICY_KEY, lbPolicy);
110+
this.unaryAttributes = baseAttrs.toBuilder().put(STREAMING_KEY, false).build();
111+
this.streamingAttributes = baseAttrs.toBuilder().put(STREAMING_KEY, true).build();
109112
}
110113
List<? extends BigtableChannelObserver> channelInsights =
111114
channelInsightsProvider.getChannelInfos();
@@ -115,9 +118,9 @@ public void run() {
115118
for (BigtableChannelObserver info : channelInsights) {
116119
String transportTypeValue = info.isAltsChannel() ? "DIRECTPATH" : "CLOUDPATH";
117120
this.unaryAttributes =
118-
this.unaryAttributes.toBuilder().put("transport_type", transportTypeValue).build();
121+
this.unaryAttributes.toBuilder().put(TRANSPORT_TYPE, transportTypeValue).build();
119122
this.streamingAttributes =
120-
this.streamingAttributes.toBuilder().put("transport_type", transportTypeValue).build();
123+
this.streamingAttributes.toBuilder().put(TRANSPORT_TYPE, transportTypeValue).build();
121124

122125
long currentOutstandingUnaryRpcs = info.getOutstandingUnaryRpcs();
123126
long currentOutstandingStreamingRpcs = info.getOutstandingStreamingRpcs();

0 commit comments

Comments
 (0)