Class SummaryWithCallback

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

public class SummaryWithCallback extends MetricWithFixedMetadata
Example:

 double MILLISECONDS_PER_SECOND = 1E3;

 SummaryWithCallback.builder()
         .name("jvm_gc_collection_seconds")
         .help("Time spent in a given JVM garbage collector in seconds.")
         .unit(Unit.SECONDS)
         .labelNames("gc")
         .callback(callback -> {
             for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
                 callback.call(
                         gc.getCollectionCount(),
                         gc.getCollectionTime() / MILLISECONDS_PER_SECOND,
                         Quantiles.EMPTY,
                         gc.getName()
                 );
             }
         })
         .register();
 
  • Method Details

    • collect

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

      public static SummaryWithCallback.Builder builder()
    • builder

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

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