org.infinispan.commons.stat.GaugeMetricInfo Maven / Gradle / Ivy
package org.infinispan.commons.stat;
import java.util.Map;
import java.util.Objects;
import java.util.function.Function;
import java.util.function.Supplier;
/**
* Represents a gauge metric.
*
* A gauge tracks a specific value, like a queue size.
*
* @since 15.0
*/
public final class GaugeMetricInfo extends BaseMetricInfo {
private final Function function;
public GaugeMetricInfo(String name, String description, Map map, Function function) {
super(name, description, map);
this.function = Objects.requireNonNull(function);
}
/**
* @return The {@link Supplier} to be invoked to fetch the value from {@code instance}.
*/
public Supplier getGauge(T instance) {
return () -> function.apply(instance);
}
}