Class CounterWithCallback

All Implemented Interfaces:
io.prometheus.metrics.model.registry.Collector

public class CounterWithCallback extends MetricWithFixedMetadata
Example:

 ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();

 CounterWithCallback.builder()
         .name("classes_loaded_total")
         .help("The total number of classes since the JVM has started execution")
         .callback(callback -> callback.call(classLoadingMXBean.getLoadedClassCount()))
         .register();
 
  • Method Details

    • collect

      public io.prometheus.metrics.model.snapshots.CounterSnapshot collect()
      Specified by:
      collect in interface io.prometheus.metrics.model.registry.Collector
      Specified by:
      collect in class Metric
    • builder

      public static CounterWithCallback.Builder builder()
    • builder

      public static CounterWithCallback.Builder builder(io.prometheus.metrics.config.PrometheusProperties properties)
    • makeLabels

      protected io.prometheus.metrics.model.snapshots.Labels makeLabels(String... labelValues)