Class MutableQuantiles

java.lang.Object
org.apache.hadoop.metrics2.lib.MutableMetric
org.apache.hadoop.metrics2.lib.MutableQuantiles
Direct Known Subclasses:
MutableInverseQuantiles

@Public @Evolving public class MutableQuantiles extends MutableMetric
Watches a stream of long values, maintaining online estimates of specific quantiles with provably low error bounds. This is particularly useful for accurate high-percentile (e.g. 95th, 99th) latency metrics.
  • Field Details

    • QUANTILES

      @VisibleForTesting public static final org.apache.hadoop.metrics2.util.Quantile[] QUANTILES
    • previousSnapshot

      @VisibleForTesting protected Map<org.apache.hadoop.metrics2.util.Quantile,Long> previousSnapshot
  • Constructor Details

    • MutableQuantiles

      public MutableQuantiles(String name, String description, String sampleName, String valueName, int interval)
      Instantiates a new MutableQuantiles for a metric that rolls itself over on the specified time interval.
      Parameters:
      name - of the metric
      description - long-form textual description of the metric
      sampleName - type of items in the stream (e.g., "Ops")
      valueName - type of the values
      interval - rollover interval (in seconds) of the estimator
    • MutableQuantiles

      public MutableQuantiles()
  • Method Details

    • snapshot

      public void snapshot(MetricsRecordBuilder builder, boolean all)
      Description copied from class: MutableMetric
      Get a snapshot of the metric
      Specified by:
      snapshot in class MutableMetric
      Parameters:
      builder - the metrics record builder
      all - if true, snapshot unchanged metrics as well
    • add

      public void add(long value)
    • getQuantiles

      public org.apache.hadoop.metrics2.util.Quantile[] getQuantiles()
      Returns the array of Quantiles declared in MutableQuantiles.
      Returns:
      array of Quantiles
    • setNumInfo

      public void setNumInfo(MetricsInfo pNumInfo)
      Set info about the metrics.
      Parameters:
      pNumInfo - info about the metrics.
    • setQuantileInfos

      public void setQuantileInfos(int length)
      Initialize quantileInfos array.
      Parameters:
      length - of the quantileInfos array.
    • addQuantileInfo

      public void addQuantileInfo(int i, MetricsInfo info)
      Add entry to quantileInfos array.
      Parameters:
      i - array index.
      info - info to be added to quantileInfos array.
    • setInterval

      public void setInterval(int pIntervalSecs)
      Set the rollover interval (in seconds) of the estimator.
      Parameters:
      pIntervalSecs - of the estimator.
    • getInterval

      public int getInterval()
      Get the rollover interval (in seconds) of the estimator.
      Returns:
      intervalSecs of the estimator.
    • stop

      public void stop()
    • getEstimator

      @VisibleForTesting public org.apache.hadoop.metrics2.util.QuantileEstimator getEstimator()
      Get the quantile estimator.
      Returns:
      the quantile estimator
    • setEstimator

      public void setEstimator(org.apache.hadoop.metrics2.util.QuantileEstimator quantileEstimator)