[GitHub] [kafka] machi1990 commented on a diff in pull request #13623: KAFKA-14926: Remove metrics on Log Cleaner shutdown
machi1990 commented on code in PR #13623: URL: https://github.com/apache/kafka/pull/13623#discussion_r1182849704 ## 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've created https://issues.apache.org/jira/browse/KAFKA-14959, I'll assign it to myself and give it a stab at some point end this week or early next week. -- 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
[GitHub] [kafka] machi1990 commented on a diff in pull request #13623: KAFKA-14926: Remove metrics on Log Cleaner shutdown
machi1990 commented on code in PR #13623: URL: https://github.com/apache/kafka/pull/13623#discussion_r1182592921 ## 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: Thanks @divijvaidya the change looks good to me. Also thanks for the reply regarding my other question. I noticed an occurrence of this in other classes that do not remove the metric during shutdown: e.g `ClientQuotaManager.scala` and some of its child classes. Is it something that you've observed as well? I could open a JIRA so that we track it and work on it in separate PR -- 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
[GitHub] [kafka] machi1990 commented on a diff in pull request #13623: KAFKA-14926: Remove metrics on Log Cleaner shutdown
machi1990 commented on code in PR #13623: URL: https://github.com/apache/kafka/pull/13623#discussion_r1173855980 ## 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: Hi @divijvaidya Just for my own understanding since I am a newbie: what happens when a metric is removed, concretely, what happens to the already registered value? I also have a nit suggestion of extracting the metric names onto const since they seem to be repeated, here and during metric declaration. -- 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