Class Collector
- Direct Known Subclasses:
BufferPoolsExports, CacheMetricsCollector, CacheMetricsCollector, ClassLoadingExports, GarbageCollectorExports, JettyStatisticsCollector, MemoryAllocationExports, MemoryPoolsExports, QueuedThreadPoolStatisticsCollector, SimpleCollector, StandardExports, ThreadExports, VersionInfoExports
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic interfacestatic classA metric, and all of its samples.static enum -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionprotected 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 metrics of this Collector.Likecollect(), but the result should only containMetricFamilySampleswheresampleNameFilter.test(name)istruefor at least one Sample name.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 Details
-
NANOSECONDS_PER_SECOND
public static final double NANOSECONDS_PER_SECONDNumber of nanoseconds in a second.- See Also:
-
MILLISECONDS_PER_SECOND
public static final double MILLISECONDS_PER_SECONDNumber of milliseconds in a second.- See Also:
-
METRIC_NAME_RE
-
METRIC_LABEL_NAME_RE
-
RESERVED_METRIC_LABEL_NAME_RE
-
-
Constructor Details
-
Collector
public Collector()
-
-
Method Details
-
collect
Return all metrics of this Collector. -
collect
Likecollect(), but the result should only containMetricFamilySampleswheresampleNameFilter.test(name)istruefor at least one Sample name.The default implementation first collects all
MetricFamilySamplesand then discards the ones wheresampleNameFilter.test(name)returnsfalsefor all names inCollector.MetricFamilySamples.getNames(). To improve performance, collector implementations should override this method to preventMetricFamilySamplesfrom being collected if they will be discarded anyways. SeeThreadExportsfor an example.Note that the resulting List may contain
MetricFamilySampleswhere some Sample names returntrueforsampleNameFilter.test(name)but some Sample names returnfalse. This is ok, because before we produce the output format we will callCollector.MetricFamilySamples.filter(Predicate)to strip all Samples wheresampleNameFilter.test(name)returnsfalse.- Parameters:
sampleNameFilter- may benull, indicating that all metrics should be collected.
-
register
Register the Collector with the default registry. -
register
Register the Collector with the given registry. -
checkMetricName
Throw an exception if the metric name is invalid. -
sanitizeMetricName
-
checkMetricLabelName
Throw an exception if the metric label name is invalid. -
doubleToGoString
Convert a double to its string representation in Go.
-