Class MetricsCollector.HistogramSnapshot

java.lang.Object
com.soklet.MetricsCollector.HistogramSnapshot
Enclosing interface:
MetricsCollector

@ThreadSafe public static final class MetricsCollector.HistogramSnapshot extends Object
Immutable snapshot of a MetricsCollector.Histogram.

Bucket counts are cumulative. Boundaries are inclusive upper bounds, and the final boundary is Long.MAX_VALUE to represent the overflow bucket. Units are the same as values passed to MetricsCollector.Histogram.record(long).

Author:
Mark Allen
  • Constructor Summary

    Constructors
    Constructor
    Description
    HistogramSnapshot(@NonNull long[] bucketBoundaries, @NonNull long[] bucketCumulativeCounts, long count, long sum, long min, long max)
    Creates an immutable histogram snapshot.
  • Method Summary

    Modifier and Type
    Method
    Description
    long
    getBucketBoundary(int index)
    The inclusive upper bound for the bucket at the given index.
    int
    Number of histogram buckets, including the overflow bucket.
    long
    The cumulative count for the bucket at the given index.
    long
    Total number of recorded values.
    long
    Largest recorded value, or 0 if no values were recorded.
    long
    Smallest recorded value, or 0 if no values were recorded.
    long
    getPercentile(double percentile)
    Returns an approximate percentile based on bucket boundaries.
    long
    Sum of all recorded values.
     

    Methods inherited from class Object

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

    • HistogramSnapshot

      public HistogramSnapshot(@NonNull long[] bucketBoundaries, @NonNull long[] bucketCumulativeCounts, long count, long sum, long min, long max)
      Creates an immutable histogram snapshot.
      Parameters:
      bucketBoundaries - inclusive upper bounds for buckets, including overflow
      bucketCumulativeCounts - cumulative counts for each bucket
      count - total number of samples recorded
      sum - sum of all recorded values
      min - smallest recorded value (or 0 if none)
      max - largest recorded value (or 0 if none)
  • Method Details

    • getBucketCount

      public int getBucketCount()
      Number of histogram buckets, including the overflow bucket.
      Returns:
      the bucket count
    • getBucketBoundary

      public long getBucketBoundary(int index)
      The inclusive upper bound for the bucket at the given index.
      Parameters:
      index - the bucket index
      Returns:
      the bucket boundary
    • getBucketCumulativeCount

      public long getBucketCumulativeCount(int index)
      The cumulative count for the bucket at the given index.
      Parameters:
      index - the bucket index
      Returns:
      the cumulative count
    • getCount

      public long getCount()
      Total number of recorded values.
      Returns:
      the count
    • getSum

      public long getSum()
      Sum of all recorded values.
      Returns:
      the sum
    • getMin

      public long getMin()
      Smallest recorded value, or 0 if no values were recorded.
      Returns:
      the minimum value
    • getMax

      public long getMax()
      Largest recorded value, or 0 if no values were recorded.
      Returns:
      the maximum value
    • getPercentile

      public long getPercentile(double percentile)
      Returns an approximate percentile based on bucket boundaries.
      Parameters:
      percentile - percentile between 0 and 100
      Returns:
      the approximated percentile value
    • toString

      public String toString()
      Overrides:
      toString in class Object