divijvaidya commented on code in PR #13960: URL: https://github.com/apache/kafka/pull/13960#discussion_r1254402700
########## core/src/main/scala/kafka/controller/KafkaController.scala: ########## @@ -537,6 +538,7 @@ class KafkaController(val config: KafkaConfig, private def removeMetrics(): Unit = { KafkaController.MetricNames.foreach(metricsGroup.removeMetric) + controllerContext.stats.removeMetrics() Review Comment: we should be registering these metrics in initializeControllerContext and removing them in resetControllerContext. The responsibility of correctly resetting and initializing controllerContext is that of KafkaController. ########## core/src/main/scala/kafka/controller/KafkaController.scala: ########## @@ -2788,6 +2796,20 @@ private[controller] class ControllerStats { def removeMetric(name: String): Unit = { metricsGroup.removeMetric(name) } + + def removeMetrics(): Unit = { + MeterMetricNames.foreach(metricsGroup.removeMetric(_)) + timerMetricNames.asScala.foreach(metricsGroup.removeMetric(_)) Review Comment: remove entry from timerMetricNames as well else it keeps growing -- 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