jsancio commented on code in PR #20422:
URL: https://github.com/apache/kafka/pull/20422#discussion_r2369424368
##########
metadata/src/main/java/org/apache/kafka/controller/metrics/QuorumControllerMetrics.java:
##########
@@ -157,6 +163,16 @@ public Long value() {
return newActiveControllers();
}
}));
+ registry.ifPresent(r -> r.newGauge(AVERAGE_IDLE_RATIO, new
Gauge<Double>() {
+ @Override
+ public Double value() {
+ return avgIdleTimeRatio.measure();
+ }
+ }));
+ }
+
+ public void updateIdleTime(long idleDurationMs) {
+ avgIdleTimeRatio.record((double) idleDurationMs, time.milliseconds());
Review Comment:
This is not thread safe. `updateIdleTime` is called from a different thread
that calls `value()`.
##########
metadata/src/main/java/org/apache/kafka/controller/QuorumController.java:
##########
@@ -406,7 +406,14 @@ public QuorumController build() throws Exception {
KafkaEventQueue queue = null;
try {
- queue = new KafkaEventQueue(time, logContext,
threadNamePrefix);
+ queue = new KafkaEventQueue(
+ time,
+ logContext,
+ threadNamePrefix,
+ EventQueue.VoidEvent.INSTANCE,
+ Optional.of(controllerMetrics::updateIdleTime)
+ );
Review Comment:
Extra spaces. In Java code we indent by 4 spaces.
```java
queue = new KafkaEventQueue(
time,
logContext,
threadNamePrefix,
EventQueue.VoidEvent.INSTANCE,
Optional.of(controllerMetrics::updateIdleTime)
);
```
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]