Package io.prometheus.client
Class Collector
- java.lang.Object
-
- io.prometheus.client.Collector
-
- Direct Known Subclasses:
SimpleCollector
public abstract class Collector extends Object
A collector for a set of metrics.Normal users should use
Gauge,Counter,SummaryandHistogram.Subclasssing Collector is for advanced uses, such as proxying metrics from another monitoring system. It is it the responsibility of subclasses to ensure they produce valid metrics.
- See Also:
- Exposition formats.
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description static interfaceCollector.Describablestatic classCollector.MetricFamilySamplesA metric, and all of its samples.static classCollector.Type
-
Field Summary
Fields Modifier and Type Field Description static doubleMILLISECONDS_PER_SECONDNumber of milliseconds in a second.static doubleNANOSECONDS_PER_SECONDNumber of nanoseconds in a second.
-
Constructor Summary
Constructors Constructor Description Collector()
-
Method Summary
All Methods Static Methods Instance Methods Abstract Methods Concrete Methods Modifier and Type Method Description protected static voidcheckMetricLabelName(String name)Throw an exception if the metric label name is invalid.protected static voidcheckMetricName(String name)Throw an exception if the metric name is invalid.abstract List<Collector.MetricFamilySamples>collect()Return all of the metrics of this Collector.static StringdoubleToGoString(double d)Convert a double to its string representation in Go.<T extends Collector>
Tregister()Register the Collector with the default registry.<T extends Collector>
Tregister(CollectorRegistry registry)Register the Collector with the given registry.static StringsanitizeMetricName(String metricName)Sanitize metric name
-
-
-
Field Detail
-
NANOSECONDS_PER_SECOND
public static final double NANOSECONDS_PER_SECOND
Number of nanoseconds in a second.- See Also:
- Constant Field Values
-
MILLISECONDS_PER_SECOND
public static final double MILLISECONDS_PER_SECOND
Number of milliseconds in a second.- See Also:
- Constant Field Values
-
-
Constructor Detail
-
Collector
public Collector()
-
-
Method Detail
-
collect
public abstract List<Collector.MetricFamilySamples> collect()
Return all of the metrics of this Collector.
-
register
public <T extends Collector> T register()
Register the Collector with the default registry.
-
register
public <T extends Collector> T register(CollectorRegistry registry)
Register the Collector with the given registry.
-
checkMetricName
protected static void checkMetricName(String name)
Throw an exception if the metric name is invalid.
-
sanitizeMetricName
public static String sanitizeMetricName(String metricName)
Sanitize metric name
-
checkMetricLabelName
protected static void checkMetricLabelName(String name)
Throw an exception if the metric label name is invalid.
-
doubleToGoString
public static String doubleToGoString(double d)
Convert a double to its string representation in Go.
-
-