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


##########
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:
   I wonder, do we really need `metricNamesToTags` set. It's just 4 metric so 
may be it will be more clear to create explicit `MetricName` for each and use 
them while closing fetcher manager.



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