ddanielr commented on code in PR #5061:
URL: https://github.com/apache/accumulo/pull/5061#discussion_r1842932606
##########
server/base/src/main/java/org/apache/accumulo/server/metrics/ProcessMetrics.java:
##########
@@ -18,26 +18,35 @@
*/
package org.apache.accumulo.server.metrics;
-import java.util.concurrent.atomic.AtomicInteger;
+import java.util.concurrent.atomic.AtomicBoolean;
import org.apache.accumulo.core.metrics.MetricsProducer;
+import io.micrometer.core.instrument.Gauge;
import io.micrometer.core.instrument.MeterRegistry;
public class ProcessMetrics implements MetricsProducer {
- private final AtomicInteger isIdle;
+ private final AtomicBoolean isIdle;
public ProcessMetrics() {
- this.isIdle = new AtomicInteger(-1);
+ this.isIdle = new AtomicBoolean(true);
}
@Override
public void registerMetrics(MeterRegistry registry) {
- registry.gauge(METRICS_SERVER_IDLE, isIdle, AtomicInteger::get);
+ Gauge.builder(METRICS_SERVER_IDLE, this, this::getIdleAsDouble)
+ .description("Indicates if the server is idle or not. "
+ + "The value will be 1 when idle and 0 when not idle")
+ .register(registry);
}
public void setIdleValue(boolean isIdle) {
- this.isIdle.set(isIdle ? 1 : 0);
+ this.isIdle.set(isIdle);
}
+
+ public double getIdleAsDouble(ProcessMetrics processMetrics) {
Review Comment:
We could. The Gauge.builder is going to convert it to a double but we could
use an int beforehand and let the builder deal with the conversion.
--
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]