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 * <p> 008 * Single data point means identified label values like {@code {method="GET", path="/", status_code="200"}}, 009 * ignoring the {@code "le"} label for histograms or the {@code "quantile"} label for summaries. 010 * <p> 011 * This interface is named <i>DistributionDataPoint</i> because both histograms and summaries are used to observe 012 * distributions, like latency distributions or distributions of request sizes. Therefore 013 * <i>DistributionDataPoint</i> is a good name for a common interface implemented by histogram data points 014 * and summary data points. 015 * <p> 016 * See JavaDoc of {@link CounterDataPoint} on how using data points directly can improve performance. 017 */ 018public interface DistributionDataPoint extends DataPoint, TimerApi { 019 020 /** 021 * Observe {@code value}. 022 */ 023 void observe(double value); 024 025 /** 026 * Observe {@code value}, and create a custom exemplar with the given labels. 027 */ 028 void observeWithExemplar(double value, Labels labels); 029 030 /** 031 * {@inheritDoc} 032 */ 033 default Timer startTimer() { 034 return new Timer(this::observe); 035 } 036}