001package io.prometheus.metrics.core.datapoints;
002
003import io.prometheus.metrics.model.snapshots.Labels;
004
005/**
006 * Represents a single data point of a histogram or a summary metric.
007 *
008 * <p>Single data point means identified label values like {@code {method="GET", path="/",
009 * status_code="200"}}, ignoring the {@code "le"} label for histograms or the {@code "quantile"}
010 * label for summaries.
011 *
012 * <p>This interface is named <i>DistributionDataPoint</i> because both histograms and summaries are
013 * used to observe distributions, like latency distributions or distributions of request sizes.
014 * Therefore <i>DistributionDataPoint</i> is a good name for a common interface implemented by
015 * histogram data points and summary data points.
016 *
017 * <p>See JavaDoc of {@link CounterDataPoint} on how using data points directly can improve
018 * performance.
019 */
020public interface DistributionDataPoint extends DataPoint, TimerApi {
021
022  /** Get the count of observations. */
023  long getCount();
024
025  /** Get the sum of all observed values. */
026  double getSum();
027
028  /** Observe {@code value}. */
029  void observe(double value);
030
031  /** Observe {@code value}, and create a custom exemplar with the given labels. */
032  void observeWithExemplar(double value, Labels labels);
033
034  @Override
035  default Timer startTimer() {
036    return new Timer(this::observe);
037  }
038}