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:
Example metrics being exported: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.StringJVM_THREADS_CURRENTprivate static java.lang.StringJVM_THREADS_DAEMONprivate static java.lang.StringJVM_THREADS_DEADLOCKEDprivate static java.lang.StringJVM_THREADS_DEADLOCKED_MONITORprivate static java.lang.StringJVM_THREADS_PEAKprivate static java.lang.StringJVM_THREADS_STARTED_TOTALstatic java.lang.StringJVM_THREADS_STATEprivate java.lang.management.ThreadMXBeanthreadBeanstatic java.lang.StringUNKNOWN-
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) voidaddThreadMetrics(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 containMetricFamilySampleswheresampleNameFilter.test(name)istruefor at least one Sample name.private java.util.Map<java.lang.String,java.lang.Integer>getThreadStateCountMap()private static doublenullSafeArrayLength(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:CollectorReturn all metrics of this Collector.
-
collect
public java.util.List<Collector.MetricFamilySamples> collect(Predicate<java.lang.String> nameFilter)
Description copied from class:CollectorLikeCollector.collect(), 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.
-
-