Class SummaryWithCallback

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

Example:

 double MILLISECONDS_PER_SECOND = 1E3;

 SummaryWithCallback.newBuilder()
         .withName("jvm_gc_collection_seconds")
         .withHelp("Time spent in a given JVM garbage collector in seconds.")
         .withUnit(Unit.SECONDS)
         .withLabelNames("gc")
         .withCallback(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
    • newBuilder

    • newBuilder

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

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