3030import io .grpc .InternalChannelz ;
3131import io .grpc .InternalStatus ;
3232import io .grpc .Metadata ;
33+ import io .grpc .MetricRecorder ;
3334import io .grpc .Status ;
3435import io .grpc .StatusException ;
3536import io .grpc .internal .ClientStreamListener .RpcProgress ;
@@ -123,6 +124,7 @@ class NettyClientHandler extends AbstractNettyHandler {
123124 private final Supplier <Stopwatch > stopwatchFactory ;
124125 private final TransportTracer transportTracer ;
125126 private final Attributes eagAttributes ;
127+ private final TcpMetrics .Tracker tcpMetrics ;
126128 private final String authority ;
127129 private final InUseStateAggregator <Http2Stream > inUseState =
128130 new InUseStateAggregator <Http2Stream >() {
@@ -164,7 +166,8 @@ static NettyClientHandler newHandler(
164166 Attributes eagAttributes ,
165167 String authority ,
166168 ChannelLogger negotiationLogger ,
167- Ticker ticker ) {
169+ Ticker ticker ,
170+ MetricRecorder metricRecorder ) {
168171 Preconditions .checkArgument (maxHeaderListSize > 0 , "maxHeaderListSize must be positive" );
169172 Http2HeadersDecoder headersDecoder = new GrpcHttp2ClientHeadersDecoder (maxHeaderListSize );
170173 Http2FrameReader frameReader = new DefaultHttp2FrameReader (headersDecoder );
@@ -194,7 +197,8 @@ static NettyClientHandler newHandler(
194197 eagAttributes ,
195198 authority ,
196199 negotiationLogger ,
197- ticker );
200+ ticker ,
201+ metricRecorder );
198202 }
199203
200204 @ VisibleForTesting
@@ -214,7 +218,8 @@ static NettyClientHandler newHandler(
214218 Attributes eagAttributes ,
215219 String authority ,
216220 ChannelLogger negotiationLogger ,
217- Ticker ticker ) {
221+ Ticker ticker ,
222+ MetricRecorder metricRecorder ) {
218223 Preconditions .checkNotNull (connection , "connection" );
219224 Preconditions .checkNotNull (frameReader , "frameReader" );
220225 Preconditions .checkNotNull (lifecycleManager , "lifecycleManager" );
@@ -269,7 +274,8 @@ static NettyClientHandler newHandler(
269274 pingCounter ,
270275 ticker ,
271276 maxHeaderListSize ,
272- softLimitHeaderListSize );
277+ softLimitHeaderListSize ,
278+ metricRecorder );
273279 }
274280
275281 private NettyClientHandler (
@@ -288,7 +294,8 @@ private NettyClientHandler(
288294 PingLimiter pingLimiter ,
289295 Ticker ticker ,
290296 int maxHeaderListSize ,
291- int softLimitHeaderListSize ) {
297+ int softLimitHeaderListSize ,
298+ MetricRecorder metricRecorder ) {
292299 super (
293300 /* channelUnused= */ null ,
294301 decoder ,
@@ -350,6 +357,7 @@ public void onStreamClosed(Http2Stream stream) {
350357 }
351358 }
352359 });
360+ this .tcpMetrics = new TcpMetrics .Tracker (metricRecorder , "client" );
353361 }
354362
355363 /**
@@ -490,6 +498,12 @@ public void close(ChannelHandlerContext ctx, ChannelPromise promise) throws Exce
490498 /**
491499 * Handler for the Channel shutting down.
492500 */
501+ @ Override
502+ public void channelActive (ChannelHandlerContext ctx ) throws Exception {
503+ tcpMetrics .channelActive ();
504+ super .channelActive (ctx );
505+ }
506+
493507 @ Override
494508 public void channelInactive (ChannelHandlerContext ctx ) throws Exception {
495509 try {
0 commit comments