soarez commented on code in PR #15863:
URL: https://github.com/apache/kafka/pull/15863#discussion_r1590415617


##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -159,6 +159,7 @@ class LogCleaner(initialConfig: CleanerConfig,
       cleaners += cleaner
       cleaner.start()
     }
+    activateMetrics();

Review Comment:
   Since there is no change to the existing definition of metrics, it seems 
this will cause the metrics to be initialized twice.



##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -182,6 +183,27 @@ class LogCleaner(initialConfig: CleanerConfig,
     cleanerManager.removeMetrics()
   }
 
+  /**
+   * Activate metrics
+   */
+  def activateMetrics():Unit = {
+    metricsGroup.newGauge(MaxBufferUtilizationPercentMetricName,
+      () => maxOverCleanerThreads(_.lastStats.bufferUtilization) * 100)
+
+    metricsGroup.newGauge(CleanerRecopyPercentMetricName, () => {
+      val stats = cleaners.map(_.lastStats)
+      val recopyRate = stats.iterator.map(_.bytesWritten).sum.toDouble / 
math.max(stats.iterator.map(_.bytesRead).sum, 1)
+      (100 * recopyRate).toInt
+    })
+
+    metricsGroup.newGauge(MaxCleanTimeMetricName, () => 
maxOverCleanerThreads(_.lastStats.elapsedSecs))
+
+    metricsGroup.newGauge(MaxCompactionDelayMetricsName,
+      () => 
maxOverCleanerThreads(_.lastPreCleanStats.maxCompactionDelayMs.toDouble) / 1000)
+
+    metricsGroup.newGauge(DeadThreadCountMetricName, () => deadThreadCount)

Review Comment:
   If we're moving the metrics here, please keep the existing comments.



##########
core/src/main/scala/kafka/log/LogCleaner.scala:
##########
@@ -159,6 +159,7 @@ class LogCleaner(initialConfig: CleanerConfig,
       cleaners += cleaner
       cleaner.start()
     }
+    activateMetrics();

Review Comment:
   +1 Please include a test



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

Reply via email to