apovzner commented on a change in pull request #9317: URL: https://github.com/apache/kafka/pull/9317#discussion_r494034591
########## File path: core/src/main/scala/kafka/network/SocketServer.scala ########## @@ -1447,13 +1454,33 @@ class ConnectionQuotas(config: KafkaConfig, time: Time, metrics: Metrics) extend } } + def removeSensors(): Unit = { Review comment: agreed, `close` will be consistent. About not closing ListenerConnectionQuota on ConnectionQuotas.close(): this is on broker shutdown path where KafkaServer calls metrics.close() on shutdown as well (and metrics are owned by KafkaServer), so I don't think we are leaking anything. But I think it's better to remove listener sensors on ConnectionQuotas.close() anyways, so I will make that change. ########## File path: core/src/main/scala/kafka/network/SocketServer.scala ########## @@ -1292,6 +1292,12 @@ class ConnectionQuotas(config: KafkaConfig, time: Time, metrics: Metrics) extend counts.synchronized { val startThrottleTimeMs = time.milliseconds val throttleTimeMs = math.max(recordConnectionAndGetThrottleTimeMs(listenerName, startThrottleTimeMs), 0) + if (throttleTimeMs > 0) { + // record throttle time due to hitting connection rate limit + // connection could be throttled longer if the limit of the number of active connections is reached as well + maxConnectionsPerListener.get(listenerName) + .foreach(_.connectionRateThrottleSensor.record(throttleTimeMs.toDouble, startThrottleTimeMs)) Review comment: That code seemed readable to me, but perhaps looking up `ListenerConnectionQuota` is better. I made a change to lookup once, please take a look. ---------------------------------------------------------------- This is an automated message from the Apache Git Service. To respond to the message, please log on to GitHub and use the URL above to go to the specific comment. For queries about this service, please contact Infrastructure at: us...@infra.apache.org