nizhikov commented on code in PR #13929: URL: https://github.com/apache/kafka/pull/13929#discussion_r1331245323
########## 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: We can use ``` Set<MetricName> metrics = ...; MetricName name = metricGroup.metricName(MaxLagMetricName, tags); KafkaYammerMetrics.defaultRegistry().newGauge(name, () => { ... }); metrics.add(name); ``` And store explicit `MetricName` instead of implicit name and tags. ``` metrics.forEach(KafkaYammerMetrics.defaultRegistry()::removeMetric); `` ` -- 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