nizhikov commented on code in PR #13929:
URL: https://github.com/apache/kafka/pull/13929#discussion_r1335591076


##########
core/src/main/scala/kafka/server/AbstractFetcherManager.scala:
##########
@@ -39,27 +43,37 @@ abstract class AbstractFetcherManager[T <: 
AbstractFetcherThread](val name: Stri
   val failedPartitions = new FailedPartitions
   this.logIdent = "[" + name + "] "
 
-  private val tags = Map("clientId" -> clientId).asJava
+  newMetrics()
 
-  metricsGroup.newGauge("MaxLag", () => {
-    // current max lag across all fetchers/topics/partitions
-    fetcherThreadMap.values.foldLeft(0L) { (curMaxLagAll, fetcherThread) =>
-      val maxLagThread = 
fetcherThread.fetcherLagStats.stats.values.foldLeft(0L)((curMaxLagThread, 
lagMetrics) =>
-        math.max(curMaxLagThread, lagMetrics.lag))
-      math.max(curMaxLagAll, maxLagThread)
-    }
-  }, tags)
+  private[server] def newMetrics(): Unit = {
+    val tags = Map("clientId" -> clientId).asJava
+    metricsGroup.newGauge(MaxLagMetricName, () => {

Review Comment:
   It seems you can use `MetricName` to check metrics registered and removed 
during test.



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