Class SummaryWithCallback
Object
Metric
MetricWithFixedMetadata
SummaryWithCallback
- All Implemented Interfaces:
Collector
Example:
double MILLISECONDS_PER_SECOND = 1E3;
SummaryWithCallback.builder()
.name("jvm_gc_collection_seconds")
.help("Time spent in a given JVM garbage collector in seconds.")
.unit(Unit.SECONDS)
.labelNames("gc")
.callback(callback -> {
for (GarbageCollectorMXBean gc : ManagementFactory.getGarbageCollectorMXBeans()) {
callback.call(
gc.getCollectionCount(),
gc.getCollectionTime() / MILLISECONDS_PER_SECOND,
Quantiles.EMPTY,
gc.getName()
);
}
})
.register();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic SummaryWithCallback.Builderbuilder()static SummaryWithCallback.Builderbuilder(PrometheusProperties properties) collect()Called when the Prometheus server scrapes metrics.Returns the metric type for registration-time validation.Methods inherited from class MetricWithFixedMetadata
getLabelNames, getMetadata, getPrometheusName
-
Method Details
-
collect
-
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.- Returns:
- the metric type, or
nullto skip validation
-
builder
-
builder
-