Class GaugeWithCallback
Object
Metric
MetricWithFixedMetadata
GaugeWithCallback
- All Implemented Interfaces:
Collector
Example:
MemoryMXBean memoryBean = ManagementFactory.getMemoryMXBean();
GaugeWithCallback.builder()
.name("jvm_memory_bytes_used")
.help("Used bytes of a given JVM memory area.")
.unit(Unit.BYTES)
.labelNames("area")
.callback(callback -> {
callback.call(memoryBean.getHeapMemoryUsage().getUsed(), "heap");
callback.call(memoryBean.getNonHeapMemoryUsage().getUsed(), "nonheap");
})
.register();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic GaugeWithCallback.Builderbuilder()static GaugeWithCallback.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
-