You are viewing a plain text version of this content. The canonical link for it is here.
Posted to jira@kafka.apache.org by "kirktrue (via GitHub)" <gi...@apache.org> on 2023/04/28 18:57:55 UTC

[GitHub] [kafka] kirktrue commented on a diff in pull request #13623: KAFKA-14926: Remove metrics on Log Cleaner shutdown

kirktrue commented on code in PR #13623:
URL: https://github.com/apache/kafka/pull/13623#discussion_r1180722737


##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -167,8 +167,20 @@ class LogCleaner(initialConfig: CleanerConfig,
    */
   def shutdown(): Unit = {
     info("Shutting down the log cleaner.")
-    cleaners.foreach(_.shutdown())
-    cleaners.clear()
+    try {
+      cleaners.foreach(_.shutdown())
+      cleaners.clear()
+    } finally {
+      remoteMetrics()
+    }
+  }
+
+  def remoteMetrics(): Unit = {

Review Comment:
   Should this method name be `removeMetrics` (a `v` instead of a `t`)?



##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -167,8 +167,20 @@ class LogCleaner(initialConfig: CleanerConfig,
    */
   def shutdown(): Unit = {
     info("Shutting down the log cleaner.")
-    cleaners.foreach(_.shutdown())
-    cleaners.clear()
+    try {
+      cleaners.foreach(_.shutdown())
+      cleaners.clear()
+    } finally {
+      remoteMetrics()
+    }
+  }
+
+  def remoteMetrics(): Unit = {
+    metricsGroup.removeMetric("max-buffer-utilization-percent")
+    metricsGroup.removeMetric("cleaner-recopy-percent")
+    metricsGroup.removeMetric("max-clean-time-secs")
+    metricsGroup.removeMetric("max-compaction-delay-secs")
+    metricsGroup.removeMetric("DeadThreadCount")

Review Comment:
   I had a similar thought. Calling them out together as constants could also remind future contributors that might add a metric that they need to remove the metric too.



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