dlmarion commented on code in PR #5061:
URL: https://github.com/apache/accumulo/pull/5061#discussion_r1842964624


##########
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:
   The previous code returned an int, which is why I asked. If Micrometer is 
just turning that into a double, then what you have is fine. Thanks!



-- 
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: notifications-unsubscr...@accumulo.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to