24
24
import com .google .common .base .MoreObjects ;
25
25
import com .google .common .base .MoreObjects .ToStringHelper ;
26
26
import com .google .common .base .Ticker ;
27
- import com .google .common .collect .Lists ;
28
27
import com .google .common .util .concurrent .Futures ;
29
28
import com .google .common .util .concurrent .ListenableFuture ;
30
29
import com .google .common .util .concurrent .MoreExecutors ;
61
60
import io .grpc .util .ForwardingLoadBalancerHelper ;
62
61
import java .net .URI ;
63
62
import java .net .URISyntaxException ;
63
+ import java .util .Arrays ;
64
+ import java .util .Collections ;
64
65
import java .util .HashMap ;
65
66
import java .util .List ;
66
67
import java .util .Map ;
@@ -127,16 +128,16 @@ final class CachingRlsLbClient {
127
128
= MetricInstrumentRegistry .getDefaultRegistry ();
128
129
DEFAULT_TARGET_PICKS_COUNTER = metricInstrumentRegistry .registerLongCounter (
129
130
"grpc.lb.rls.default_target_picks" , "Number of LB picks sent to the default target" , "pick" ,
130
- Lists . newArrayList ("grpc.target" , "grpc.lb.rls.server_target" ,
131
- "grpc.lb.rls.data_plane_target" , "grpc.lb.pick_result" ), Lists . newArrayList (), true );
131
+ Arrays . asList ("grpc.target" , "grpc.lb.rls.server_target" ,
132
+ "grpc.lb.rls.data_plane_target" , "grpc.lb.pick_result" ), Collections . emptyList (), true );
132
133
TARGET_PICKS_COUNTER = metricInstrumentRegistry .registerLongCounter ("grpc.lb.rls.target_picks" ,
133
134
"Number of LB picks sent to each RLS target" , "pick" ,
134
- Lists . newArrayList ("grpc.target" , "grpc.lb.rls.server_target" ,
135
- "grpc.lb.rls.data_plane_target" , "grpc.lb.pick_result" ), Lists . newArrayList (), true );
135
+ Arrays . asList ("grpc.target" , "grpc.lb.rls.server_target" ,
136
+ "grpc.lb.rls.data_plane_target" , "grpc.lb.pick_result" ), Collections . emptyList (), true );
136
137
FAILED_PICKS_COUNTER = metricInstrumentRegistry .registerLongCounter ("grpc.lb.rls.failed_picks" ,
137
138
"Number of LB picks failed due to either a failed RLS request or the RLS channel being "
138
- + "throttled" , "pick" , Lists . newArrayList ("grpc.target" , "grpc.lb.rls.server_target" ),
139
- Lists . newArrayList (), true );
139
+ + "throttled" , "pick" , Arrays . asList ("grpc.target" , "grpc.lb.rls.server_target" ),
140
+ Collections . emptyList (), true );
140
141
}
141
142
142
143
private CachingRlsLbClient (Builder builder ) {
@@ -968,11 +969,11 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
968
969
// Happy path
969
970
logger .log (ChannelLogLevel .DEBUG , "Returning PickResult" );
970
971
PickResult pickResult = picker .pickSubchannel (args );
971
- // TODO: include the "grpc.target" label once target is available here.
972
972
if (pickResult .hasResult ()) {
973
973
helper .getMetricRecorder ().addLongCounter (TARGET_PICKS_COUNTER , 1 ,
974
- Lists .newArrayList ("" , lookupService , childPolicyWrapper .getTarget (),
975
- determineMetricsPickResult (pickResult )), Lists .newArrayList ());
974
+ Arrays .asList (helper .getChannelTarget (), lookupService ,
975
+ childPolicyWrapper .getTarget (), determineMetricsPickResult (pickResult )),
976
+ Collections .emptyList ());
976
977
}
977
978
return pickResult ;
978
979
} else if (response .hasError ()) {
@@ -982,9 +983,8 @@ public PickResult pickSubchannel(PickSubchannelArgs args) {
982
983
return useFallback (args );
983
984
}
984
985
logger .log (ChannelLogLevel .DEBUG , "No RLS fallback, returning PickResult with an error" );
985
- // TODO: include the "grpc.target" label once target is available here.
986
986
helper .getMetricRecorder ().addLongCounter (FAILED_PICKS_COUNTER , 1 ,
987
- Lists . newArrayList ( "" , lookupService ), Lists . newArrayList ());
987
+ Arrays . asList ( helper . getChannelTarget () , lookupService ), Collections . emptyList ());
988
988
return PickResult .withError (
989
989
convertRlsServerStatus (response .getStatus (),
990
990
lbPolicyConfig .getRouteLookupConfig ().lookupService ()));
@@ -1007,10 +1007,10 @@ private PickResult useFallback(PickSubchannelArgs args) {
1007
1007
}
1008
1008
PickResult pickResult = picker .pickSubchannel (args );
1009
1009
if (pickResult .hasResult ()) {
1010
- // TODO: include the grpc.target label once target is available here.
1011
1010
helper .getMetricRecorder ().addLongCounter (DEFAULT_TARGET_PICKS_COUNTER , 1 ,
1012
- Lists .newArrayList ("" , lookupService , fallbackChildPolicyWrapper .getTarget (),
1013
- determineMetricsPickResult (pickResult )), Lists .newArrayList ());
1011
+ Arrays .asList (helper .getChannelTarget (), lookupService ,
1012
+ fallbackChildPolicyWrapper .getTarget (), determineMetricsPickResult (pickResult )),
1013
+ Collections .emptyList ());
1014
1014
}
1015
1015
return pickResult ;
1016
1016
}
0 commit comments