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

Commit b2bcc12

Browse files
chore: merge main into generate-libraries-main
2 parents 6642b98 + e3e6e99 commit b2bcc12

2 files changed

Lines changed: 82 additions & 10 deletions

File tree

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

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@
6464
import java.io.IOException;
6565
import java.nio.charset.StandardCharsets;
6666
import java.util.Base64;
67+
import java.util.Collections;
6768
import java.util.List;
6869
import java.util.Map;
6970
import java.util.Optional;
@@ -113,6 +114,10 @@ public class EnhancedBigtableStubSettings extends StubSettings<EnhancedBigtableS
113114
private static final boolean DIRECT_PATH_ENABLED =
114115
Boolean.parseBoolean(System.getenv("CBT_ENABLE_DIRECTPATH"));
115116

117+
// If true, disable the bound-token-by-default feature for DirectPath.
118+
private static final boolean DIRECT_PATH_BOUND_TOKEN_DISABLED =
119+
Boolean.parseBoolean(System.getenv("CBT_DISABLE_DIRECTPATH_BOUND_TOKEN"));
120+
116121
private static final boolean SKIP_TRAILERS =
117122
Optional.ofNullable(System.getenv("CBT_SKIP_HEADERS"))
118123
.map(Boolean::parseBoolean)
@@ -440,6 +445,12 @@ public static InstantiatingGrpcChannelProvider.Builder defaultGrpcTransportProvi
440445
.setAttemptDirectPath(true)
441446
// Allow using non-default service account in DirectPath.
442447
.setAllowNonDefaultServiceAccount(true);
448+
if (!DIRECT_PATH_BOUND_TOKEN_DISABLED) {
449+
// Try to fetch a hard-bound access token for direct access if the runtime
450+
// environment supports it.
451+
grpcTransportProviderBuilder.setAllowHardBoundTokenTypes(
452+
Collections.singletonList(InstantiatingGrpcChannelProvider.HardBoundTokenTypes.ALTS));
453+
}
443454
}
444455
return grpcTransportProviderBuilder
445456
.setChannelPoolSettings(

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

Lines changed: 71 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,30 @@ public class BuiltinMetricsConstants {
5555
static final AttributeKey<String> TRANSPORT_ZONE = AttributeKey.stringKey("transport_zone");
5656
static final AttributeKey<String> TRANSPORT_SUBZONE = AttributeKey.stringKey("transport_subzone");
5757

58+
// gRPC attribute keys
59+
// Note that these attributes keys from transformed from
60+
// A.B.C to A_B_C before exporting to Cloud Monitoring.
61+
static final AttributeKey<String> GRPC_LB_BACKEND_SERVICE_KEY =
62+
AttributeKey.stringKey("grpc.lb.backend_service");
63+
static final AttributeKey<String> GRPC_DISCONNECT_ERROR_KEY =
64+
AttributeKey.stringKey("grpc.disconnect_error");
65+
static final AttributeKey<String> GRPC_LB_LOCALITY_KEY =
66+
AttributeKey.stringKey("grpc.lb.locality");
67+
static final AttributeKey<String> GRPC_TARGET_KEY = AttributeKey.stringKey("grpc.target");
68+
static final AttributeKey<String> GRPC_SECURITY_LEVEL_KEY =
69+
AttributeKey.stringKey("grpc.security_level");
70+
static final AttributeKey<String> GRPC_METHOD_KEY = AttributeKey.stringKey("grpc.method");
71+
static final AttributeKey<String> GRPC_STATUS_KEY = AttributeKey.stringKey("grpc.status");
72+
static final AttributeKey<String> GRPC_LB_RLS_DATA_PLANE_TARGET_KEY =
73+
AttributeKey.stringKey("grpc.lb.rls.data_plane_target");
74+
static final AttributeKey<String> GRPC_LB_PICK_RESULT_KEY =
75+
AttributeKey.stringKey("grpc.lb.pick_result");
76+
static final AttributeKey<String> GRPC_LB_RLS_SERVER_TARGET_KEY =
77+
AttributeKey.stringKey("grpc.lb.rls.server_target");
78+
static final AttributeKey<String> GRPC_XDS_SERVER_KEY = AttributeKey.stringKey("grpc.xds.server");
79+
static final AttributeKey<String> GRPC_XDS_RESOURCE_TYPE_KEY =
80+
AttributeKey.stringKey("grpc.xds.resource_type");
81+
5882
public static final String METER_NAME = "bigtable.googleapis.com/internal/client/";
5983

6084
// Metric names
@@ -77,31 +101,68 @@ public class BuiltinMetricsConstants {
77101
ImmutableMap.<String, Set<String>>builder()
78102
.put(
79103
"grpc.client.attempt.duration",
80-
ImmutableSet.of("grpc.lb.locality", "grpc.method", "grpc.target", "grpc.status"))
104+
ImmutableSet.of(
105+
GRPC_LB_LOCALITY_KEY.getKey(),
106+
GRPC_METHOD_KEY.getKey(),
107+
GRPC_TARGET_KEY.getKey(),
108+
GRPC_STATUS_KEY.getKey()))
81109
.put(
82110
"grpc.lb.rls.default_target_picks",
83-
ImmutableSet.of("grpc.lb.rls.data_plane_target", "grpc.lb.pick_result"))
111+
ImmutableSet.of(
112+
GRPC_LB_RLS_DATA_PLANE_TARGET_KEY.getKey(), GRPC_LB_PICK_RESULT_KEY.getKey()))
84113
.put(
85114
"grpc.lb.rls.target_picks",
86115
ImmutableSet.of(
87-
"grpc.target",
88-
"grpc.lb.rls.server_target",
89-
"grpc.lb.rls.data_plane_target",
90-
"grpc.lb.pick_result"))
116+
GRPC_TARGET_KEY.getKey(),
117+
GRPC_LB_RLS_SERVER_TARGET_KEY.getKey(),
118+
GRPC_LB_RLS_DATA_PLANE_TARGET_KEY.getKey(),
119+
GRPC_LB_PICK_RESULT_KEY.getKey()))
91120
.put(
92121
"grpc.lb.rls.failed_picks",
93-
ImmutableSet.of("grpc.target", "grpc.lb.rls.server_target"))
122+
ImmutableSet.of(GRPC_TARGET_KEY.getKey(), GRPC_LB_RLS_SERVER_TARGET_KEY.getKey()))
94123
// TODO: "grpc.xds_client.connected"
95-
.put("grpc.xds_client.server_failure", ImmutableSet.of("grpc.target", "grpc.xds.server"))
124+
.put(
125+
"grpc.xds_client.server_failure",
126+
ImmutableSet.of(GRPC_TARGET_KEY.getKey(), GRPC_XDS_SERVER_KEY.getKey()))
96127
// TODO: "grpc.xds_client.resource_updates_valid",
97128
.put(
98129
"grpc.xds_client.resource_updates_invalid",
99-
ImmutableSet.of("grpc.target", "grpc.xds.server", "grpc.xds.resource_type"))
130+
ImmutableSet.of(
131+
GRPC_TARGET_KEY.getKey(),
132+
GRPC_XDS_SERVER_KEY.getKey(),
133+
GRPC_XDS_RESOURCE_TYPE_KEY.getKey()))
100134
// TODO: "grpc.xds_client.resources"
135+
// gRPC subchannel metrics
136+
.put(
137+
"grpc.subchannel.disconnections",
138+
ImmutableSet.of(
139+
GRPC_LB_BACKEND_SERVICE_KEY.getKey(),
140+
GRPC_DISCONNECT_ERROR_KEY.getKey(),
141+
GRPC_LB_LOCALITY_KEY.getKey(),
142+
GRPC_TARGET_KEY.getKey()))
143+
.put(
144+
"grpc.subchannel.connection_attempts_succeeded",
145+
ImmutableSet.of(
146+
GRPC_LB_BACKEND_SERVICE_KEY.getKey(),
147+
GRPC_LB_LOCALITY_KEY.getKey(),
148+
GRPC_TARGET_KEY.getKey()))
149+
.put(
150+
"grpc.subchannel.connection_attempts_failed",
151+
ImmutableSet.of(
152+
GRPC_LB_BACKEND_SERVICE_KEY.getKey(),
153+
GRPC_LB_LOCALITY_KEY.getKey(),
154+
GRPC_TARGET_KEY.getKey()))
155+
.put(
156+
"grpc.subchannel.open_connections",
157+
ImmutableSet.of(
158+
GRPC_LB_BACKEND_SERVICE_KEY.getKey(),
159+
GRPC_LB_LOCALITY_KEY.getKey(),
160+
GRPC_SECURITY_LEVEL_KEY.getKey(),
161+
GRPC_TARGET_KEY.getKey()))
101162
.build();
102163

103164
public static final Set<String> INTERNAL_METRICS =
104-
ImmutableSet.of(PER_CONNECTION_ERROR_COUNT_NAME).stream()
165+
ImmutableSet.of(PER_CONNECTION_ERROR_COUNT_NAME, OUTSTANDING_RPCS_PER_CHANNEL_NAME).stream()
105166
.map(m -> METER_NAME + m)
106167
.collect(ImmutableSet.toImmutableSet());
107168
// End allow list of metrics that will be exported

0 commit comments

Comments
 (0)