divijvaidya commented on code in PR #13473: URL: https://github.com/apache/kafka/pull/13473#discussion_r1151651343
########## core/src/main/scala/kafka/controller/KafkaController.scala: ########## @@ -198,6 +198,7 @@ class KafkaController(val config: KafkaConfig, def shutdown(): Unit = { eventManager.close() onControllerResignation() + removeMetrics() Review Comment: please do this in try {} finally {} ########## core/src/main/scala/kafka/controller/KafkaController.scala: ########## @@ -502,6 +503,21 @@ class KafkaController(val config: KafkaConfig, info("Resigned") } + private def removeMetrics(): Unit = { + metricsGroup.removeMetric("ActiveControllerCount") Review Comment: Perhaps we should store the metric names in an Array and then close all of them with: ``` for (String metricName : metrics) metricsGroup.removeMetric(metricName); ``` this will ensure that new metrics added in the future here are cleaned up. -- 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