Interface DistributionDataPoint

All Superinterfaces:
DataPoint, TimerApi
All Known Implementing Classes:
Histogram, Histogram.DataPoint, Summary, Summary.DataPoint

public interface DistributionDataPoint extends DataPoint, TimerApi
Represents a single data point of a histogram or a summary metric.

Single data point means identified label values like {method="GET", path="/", status_code="200"}, ignoring the "le" label for histograms or the "quantile" label for summaries.

This interface is named DistributionDataPoint because both histograms and summaries are used to observe distributions, like latency distributions or distributions of request sizes. Therefore DistributionDataPoint is a good name for a common interface implemented by histogram data points and summary data points.

See JavaDoc of CounterDataPoint on how using data points directly can improve performance.

  • Method Summary

    Modifier and Type
    Method
    Description
    void
    observe(double value)
    Observe value.
    void
    observeWithExemplar(double value, Labels labels)
    Observe value, and create a custom exemplar with the given labels.
    default Timer
    Start a Timer.

    Methods inherited from interface TimerApi

    time, time, timeChecked
  • Method Details

    • observe

      void observe(double value)
      Observe value.
    • observeWithExemplar

      void observeWithExemplar(double value, Labels labels)
      Observe value, and create a custom exemplar with the given labels.
    • startTimer

      default Timer startTimer()
      Start a Timer. Example:
      
       Histogram histogram = Histogram.builder()
               .name("http_request_duration_seconds")
               .help("HTTP request service time in seconds")
               .unit(SECONDS)
               .labelNames("method", "path")
               .register();
      
       try (Timer timer = histogram.labelValues("GET", "/").startTimer()) {
           // duration of this code block will be observed.
       }
       
      Durations are recorded in seconds. The Prometheus instrumentation guidelines say: "Metrics must use base units (e.g. seconds, bytes) and leave converting them to something more readable to graphing tools".
      Specified by:
      startTimer in interface TimerApi