001package io.prometheus.client.exemplars;
002
003/**
004 * Exemplar sampler for histogram metrics.
005 */
006public interface HistogramExemplarSampler {
007  /**
008   * @param value      the value to be observed.
009   * @param bucketFrom upper boundary of the previous bucket in the histogram.
010   *                   Will be {@link Double#NEGATIVE_INFINITY} if there is no previous bucket.
011   * @param bucketTo   upper boundary of this histogram bucket.
012   *                   Will be {@link Double#POSITIVE_INFINITY} if this is the last bucket.
013   * @param previous   the previously sampled exemplar, or {@code null} if there is none.
014   * @return an Exemplar to be sampled, or {@code null} if the previous exemplar does not need to be updated.
015   * Returning {@code null} and returning {@code previous} is equivalent.
016   */
017  Exemplar sample(double value, double bucketFrom, double bucketTo, Exemplar previous);
018}