You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "divijvaidya (via GitHub)" <gi...@apache.org> on 2023/07/06 12:59:46 UTC

[GitHub] [kafka] divijvaidya commented on a diff in pull request #13960: KAFKA-15129;[6/N] Remove metrics in ControllerStats when broker shutdown

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-unsubscribe@kafka.apache.org

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