Package org.microproxy.stats
Class Histogram.Snapshot
java.lang.Object
org.microproxy.stats.Histogram.Snapshot
- Enclosing interface:
Histogram
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
ConstructorsConstructorDescriptionSnapshot(double[] bounds, long[] counts, double sum, long count) A snapshot of the given counts. -
Method Summary
Modifier and TypeMethodDescriptiondouble[]bounds()Returns a copy of the buckets' upper bounds, ascending, without+Inf.longbucketCount(int i) The count of bucketialone.intbuckets()Returns how many buckets there are, the+Infone included.longcount()Returns how many values were recorded.longcumulativeCount(int i) The count of bucketiand every bucket below it, as Prometheus's_bucketlines show it.doublequantile(double q) Estimates quantileqby interpolating linearly inside the bucket it falls in, as Prometheus'shistogram_quantiledoes; a quantile in the+Infbucket is the last bound.doublesum()Returns the sum of the recorded values.toString()
-
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, ascendingcounts- each bucket's own count, one more than there are boundssum- the sum of the recorded valuescount- 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+Infone included.- Returns:
- how many buckets there are, the
+Infone included
-
bucketCount
public long bucketCount(int i) The count of bucketialone.- Parameters:
i- the bucket, from 0 tobounds().length- Returns:
- the number of values in the bucket
-
cumulativeCount
public long cumulativeCount(int i) The count of bucketiand every bucket below it, as Prometheus's_bucketlines show it.- Parameters:
i- the bucket, from 0 tobounds().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 quantileqby interpolating linearly inside the bucket it falls in, as Prometheus'shistogram_quantiledoes; a quantile in the+Infbucket is the last bound.- Parameters:
q- the quantile, from 0 to 1- Returns:
- the estimate, or
NaNwhen nothing was recorded
-
toString
-