Class Histogram.Snapshot

java.lang.Object
org.microproxy.stats.Histogram.Snapshot
Enclosing interface:
Histogram

public static final class Histogram.Snapshot extends Object
The counts of a histogram at one moment.

Bucket i counts the values above bound i - 1 (or any value, for i == 0) and at most bound i; bucket bounds().length counts the values above the last bound.

  • Constructor Summary

    Constructors
    Constructor
    Description
    Snapshot(double[] bounds, long[] counts, double sum, long count)
    A snapshot of the given counts.
  • Method Summary

    Modifier and Type
    Method
    Description
    double[]
    Returns a copy of the buckets' upper bounds, ascending, without +Inf.
    long
    bucketCount(int i)
    The count of bucket i alone.
    int
    Returns how many buckets there are, the +Inf one included.
    long
    Returns how many values were recorded.
    long
    The count of bucket i and every bucket below it, as Prometheus's _bucket lines show it.
    double
    quantile(double q)
    Estimates quantile q by interpolating linearly inside the bucket it falls in, as Prometheus's histogram_quantile does; a quantile in the +Inf bucket is the last bound.
    double
    sum()
    Returns the sum of the recorded values.
     

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, wait, wait, wait
  • Constructor Details

    • Snapshot

      public Snapshot(double[] bounds, long[] counts, double sum, long count)
      A snapshot of the given counts.
      Parameters:
      bounds - the buckets' upper bounds, ascending
      counts - each bucket's own count, one more than there are bounds
      sum - the sum of the recorded values
      count - how many values were recorded
      Throws:
      IllegalArgumentException - if there is not one more count than bounds
  • Method Details

    • bounds

      public double[] bounds()
      Returns a copy of the buckets' upper bounds, ascending, without +Inf.
      Returns:
      a copy of the buckets' upper bounds, ascending, without +Inf
    • buckets

      public int buckets()
      Returns how many buckets there are, the +Inf one included.
      Returns:
      how many buckets there are, the +Inf one included
    • bucketCount

      public long bucketCount(int i)
      The count of bucket i alone.
      Parameters:
      i - the bucket, from 0 to bounds().length
      Returns:
      the number of values in the bucket
    • cumulativeCount

      public long cumulativeCount(int i)
      The count of bucket i and every bucket below it, as Prometheus's _bucket lines show it.
      Parameters:
      i - the bucket, from 0 to bounds().length
      Returns:
      the number of values at most the bucket's bound
    • sum

      public double sum()
      Returns the sum of the recorded values.
      Returns:
      the sum of the recorded values
    • count

      public long count()
      Returns how many values were recorded.
      Returns:
      how many values were recorded
    • quantile

      public double quantile(double q)
      Estimates quantile q by interpolating linearly inside the bucket it falls in, as Prometheus's histogram_quantile does; a quantile in the +Inf bucket is the last bound.
      Parameters:
      q - the quantile, from 0 to 1
      Returns:
      the estimate, or NaN when nothing was recorded
    • toString

      public String toString()
      Overrides:
      toString in class Object