@@ -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