Class CounterWithCallback
Object
Metric
MetricWithFixedMetadata
CounterWithCallback
- All Implemented Interfaces:
Collector
Example:
ClassLoadingMXBean classLoadingMXBean = ManagementFactory.getClassLoadingMXBean();
CounterWithCallback.builder()
.name("classes_loaded_total")
.help("The total number of classes since the JVM has started execution")
.callback(callback -> callback.call(classLoadingMXBean.getLoadedClassCount()))
.register();
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic classstatic interface -
Method Summary
Modifier and TypeMethodDescriptionstatic CounterWithCallback.Builderbuilder()static CounterWithCallback.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
-