kevin-wu24 commented on code in PR #16904:
URL: https://github.com/apache/kafka/pull/16904#discussion_r1731778614


##########
core/src/main/scala/kafka/server/ForwardingManager.scala:
##########
@@ -104,21 +112,30 @@ object ForwardingManager {
 }
 
 class ForwardingManagerImpl(
-  channelManager: NodeToControllerChannelManager
-) extends ForwardingManager with Logging {
+  channelManager: NodeToControllerChannelManager,
+  metrics: Metrics
+) extends ForwardingManager with AutoCloseable with Logging {
+
+  val forwardingManagerMetrics: ForwardingManagerMetrics = 
ForwardingManagerMetrics(metrics)
 
   override def forwardRequest(
     requestContext: RequestContext,
     requestBufferCopy: ByteBuffer,
+    requestCreationNs: Long,
     requestBody: AbstractRequest,
     requestToString: () => String,
     responseCallback: Option[AbstractResponse] => Unit
   ): Unit = {
     val envelopeRequest = 
ForwardingManager.buildEnvelopeRequest(requestContext, requestBufferCopy)
+    val requestCreationTimeMs = 
TimeUnit.NANOSECONDS.toMillis(requestCreationNs)
 
     class ForwardingResponseHandler extends ControllerRequestCompletionHandler 
{
       override def onComplete(clientResponse: ClientResponse): Unit = {
 
+        forwardingManagerMetrics.queueLength.getAndDecrement()

Review Comment:
   Yeah we should decrement on timeout. I think we would only want to record 
`QueueTimeMs` upon a timeout though, not `RemoteTimeMs` since the `onTimeout` 
method is only called for requests that don't make it to the controller and 
timeout while still on the `requestQueue`.



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

To unsubscribe, e-mail: jira-unsubscr...@kafka.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to