Class Summary
- All Implemented Interfaces:
DataPoint, DistributionDataPoint, TimerApi, Collector
public class Summary
extends StatefulMetric<DistributionDataPoint, Summary.DataPoint>
implements DistributionDataPoint
Summary metric. Example:
Summary summary = Summary.builder()
.name("http_request_duration_seconds_hi")
.help("HTTP request service time in seconds")
.unit(SECONDS)
.labelNames("method", "path", "status_code")
.quantile(0.5, 0.01)
.quantile(0.95, 0.001)
.quantile(0.99, 0.001)
.register();
long start = System.nanoTime();
// process a request, duration will be observed
summary.labelValues("GET", "/", "200").observe(Unit.nanosToSeconds(System.nanoTime() - start));
See Summary.Builder for configuration options.-
Nested Class Summary
Nested Classes -
Method Summary
Modifier and TypeMethodDescriptionstatic Summary.Builderbuilder()static Summary.Builderbuilder(PrometheusProperties config) collect()Called when the Prometheus server scrapes metrics.longgetCount()Get the count of observations.Returns the metric type for registration-time validation.doublegetSum()Get the sum of all observed values.voidobserve(double amount) Observevalue.voidobserveWithExemplar(double amount, Labels labels) Observevalue, and create a custom exemplar with the given labels.Methods inherited from class StatefulMetric
clear, initLabelValues, labelValues, remove, removeIfMethods inherited from class MetricWithFixedMetadata
getLabelNames, getMetadata, getPrometheusNameMethods inherited from class Object
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, waitMethods inherited from interface DistributionDataPoint
startTimerMethods inherited from interface TimerApi
time, time, timeChecked
-
Method Details
-
getSum
Description copied from interface:DistributionDataPointGet the sum of all observed values.- Specified by:
getSumin interfaceDistributionDataPoint
-
getCount
Description copied from interface:DistributionDataPointGet the count of observations.- Specified by:
getCountin interfaceDistributionDataPoint
-
observe
Description copied from interface:DistributionDataPointObservevalue.- Specified by:
observein interfaceDistributionDataPoint
-
observeWithExemplar
Description copied from interface:DistributionDataPointObservevalue, and create a custom exemplar with the given labels.- Specified by:
observeWithExemplarin interfaceDistributionDataPoint
-
collect
Description copied from interface:CollectorCalled when the Prometheus server scrapes metrics.- Specified by:
collectin interfaceCollector- Overrides:
collectin classStatefulMetric<DistributionDataPoint, Summary.DataPoint>
-
getMetricType
Description copied from interface:CollectorReturns the metric type for registration-time validation.This is used to prevent different metric types (e.g., Counter and Gauge) from sharing the same name. Returning
nullmeans type validation is skipped for this collector.Validation is performed only at registration time. If this method returns
null, no type validation is performed for this collector, and duplicate or conflicting metrics may result in invalid exposition output.- Specified by:
getMetricTypein interfaceCollector- Returns:
- the metric type, or
nullto skip validation
-
builder
-
builder
-