Class ThreadExports
- java.lang.Object
-
- io.prometheus.client.Collector
-
- io.prometheus.client.hotspot.ThreadExports
-
public class ThreadExports extends Collector
Exports metrics about JVM thread areas.Example usage:
new ThreadExports().register();
jvm_threads_current{} 300 jvm_threads_daemon{} 200 jvm_threads_peak{} 410 jvm_threads_started_total{} 1200
-
-
Nested Class Summary
-
Nested classes/interfaces inherited from class io.prometheus.client.Collector
Collector.Describable, Collector.MetricFamilySamples, Collector.Type
-
-
Field Summary
Fields Modifier and Type Field Description private static java.lang.String
JVM_THREADS_CURRENT
private static java.lang.String
JVM_THREADS_DAEMON
private static java.lang.String
JVM_THREADS_DEADLOCKED
private static java.lang.String
JVM_THREADS_DEADLOCKED_MONITOR
private static java.lang.String
JVM_THREADS_PEAK
private static java.lang.String
JVM_THREADS_STARTED_TOTAL
static java.lang.String
JVM_THREADS_STATE
private java.lang.management.ThreadMXBean
threadBean
static java.lang.String
UNKNOWN
-
Fields inherited from class io.prometheus.client.Collector
MILLISECONDS_PER_SECOND, NANOSECONDS_PER_SECOND
-
-
Constructor Summary
Constructors Constructor Description ThreadExports()
ThreadExports(java.lang.management.ThreadMXBean threadBean)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) void
addThreadMetrics(java.util.List<Collector.MetricFamilySamples> sampleFamilies, Predicate<java.lang.String> nameFilter)
java.util.List<Collector.MetricFamilySamples>
collect()
Return all metrics of this Collector.java.util.List<Collector.MetricFamilySamples>
collect(Predicate<java.lang.String> nameFilter)
LikeCollector.collect()
, but the result should only containMetricFamilySamples
wheresampleNameFilter.test(name)
istrue
for at least one Sample name.private java.util.Map<java.lang.String,java.lang.Integer>
getThreadStateCountMap()
private static double
nullSafeArrayLength(long[] array)
-
Methods inherited from class io.prometheus.client.Collector
checkMetricLabelName, checkMetricName, doubleToGoString, register, register, sanitizeMetricName
-
-
-
-
Field Detail
-
UNKNOWN
public static final java.lang.String UNKNOWN
- See Also:
- Constant Field Values
-
JVM_THREADS_STATE
public static final java.lang.String JVM_THREADS_STATE
- See Also:
- Constant Field Values
-
JVM_THREADS_CURRENT
private static final java.lang.String JVM_THREADS_CURRENT
- See Also:
- Constant Field Values
-
JVM_THREADS_DAEMON
private static final java.lang.String JVM_THREADS_DAEMON
- See Also:
- Constant Field Values
-
JVM_THREADS_PEAK
private static final java.lang.String JVM_THREADS_PEAK
- See Also:
- Constant Field Values
-
JVM_THREADS_STARTED_TOTAL
private static final java.lang.String JVM_THREADS_STARTED_TOTAL
- See Also:
- Constant Field Values
-
JVM_THREADS_DEADLOCKED
private static final java.lang.String JVM_THREADS_DEADLOCKED
- See Also:
- Constant Field Values
-
JVM_THREADS_DEADLOCKED_MONITOR
private static final java.lang.String JVM_THREADS_DEADLOCKED_MONITOR
- See Also:
- Constant Field Values
-
threadBean
private final java.lang.management.ThreadMXBean threadBean
-
-
Method Detail
-
addThreadMetrics
void addThreadMetrics(java.util.List<Collector.MetricFamilySamples> sampleFamilies, Predicate<java.lang.String> nameFilter)
-
getThreadStateCountMap
private java.util.Map<java.lang.String,java.lang.Integer> getThreadStateCountMap()
-
nullSafeArrayLength
private static double nullSafeArrayLength(long[] array)
-
collect
public java.util.List<Collector.MetricFamilySamples> collect()
Description copied from class:Collector
Return all metrics of this Collector.
-
collect
public java.util.List<Collector.MetricFamilySamples> collect(Predicate<java.lang.String> nameFilter)
Description copied from class:Collector
LikeCollector.collect()
, but the result should only containMetricFamilySamples
wheresampleNameFilter.test(name)
istrue
for at least one Sample name.The default implementation first collects all
MetricFamilySamples
and then discards the ones wheresampleNameFilter.test(name)
returnsfalse
for all names inCollector.MetricFamilySamples.getNames()
. To improve performance, collector implementations should override this method to preventMetricFamilySamples
from being collected if they will be discarded anyways. SeeThreadExports
for an example.Note that the resulting List may contain
MetricFamilySamples
where some Sample names returntrue
forsampleNameFilter.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
.
-
-