Class Histogram

java.lang.Object
com.codename1.backend.metrics.Instrument
com.codename1.backend.metrics.Histogram

public final class Histogram extends Instrument

A distribution of values -- durations, sizes -- kept as counts per bucket. Exported as a cumulative explicit-bucket histogram.

The buckets are fixed when the histogram is created; the default boundaries are OpenTelemetry's, which suit milliseconds.

A histogram created with label keys keeps a series per combination of label values -- the server's request histogram has route, method and status. The series are found by a map lookup on the first label, which is a constant such as a route template, so nothing new is hashed; and they are capped, so a label with unbounded values cannot grow the histogram without limit.

  • Field Summary

    Fields inherited from class Instrument

    COUNTER, GAUGE, HISTOGRAM, UP_DOWN_COUNTER
  • Method Summary

    Modifier and Type
    Method
    Description
    static double[]
    A copy of OpenTelemetry's default explicit bucket boundaries.
    long
    Every value recorded so far, across all label sets: what a @Timed method's timer or a histogram reads as in the process, without an exporter.
    The label keys this histogram was created with.
    double
    The mean of the values recorded so far, or NaN when there are none.
    double
    The sum of every value recorded so far, across all label sets.
    The current points, each a map with attributes (a map, possibly empty) and either value or, for a histogram, count, sum, min, max, bounds and buckets.
    void
    record(double value)
    Records one value in the series without labels.
    void
    record(double value, Object first, Object second, Object third)
    Records one value in the series for these label values, given in the order of the keys the histogram was created with.

    Methods inherited from class Instrument

    getDescription, getKind, getName, getUnit

    Methods inherited from class Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • defaultBounds

      public static double[] defaultBounds()
      A copy of OpenTelemetry's default explicit bucket boundaries.
    • getLabelKeys

      public String[] getLabelKeys()
      The label keys this histogram was created with.
    • record

      public void record(double value)
      Records one value in the series without labels.
    • record

      public void record(double value, Object first, Object second, Object third)
      Records one value in the series for these label values, given in the order of the keys the histogram was created with.
    • getCount

      public long getCount()
      Every value recorded so far, across all label sets: what a @Timed method's timer or a histogram reads as in the process, without an exporter.
    • getSum

      public double getSum()
      The sum of every value recorded so far, across all label sets.
    • getMean

      public double getMean()
      The mean of the values recorded so far, or NaN when there are none.
    • points

      public List points()
      Description copied from class: Instrument
      The current points, each a map with attributes (a map, possibly empty) and either value or, for a histogram, count, sum, min, max, bounds and buckets.
      Specified by:
      points in class Instrument