Class CounterWithCallback

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

Example:

 ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();

 CounterWithCallback.newBuilder()
         .withName("classes_loaded_total")
         .withHelp("The total number of classes that have been loaded since the JVM has started execution")
         .withCallback(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
    • newBuilder

    • newBuilder

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

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