Class StandardExports
- java.lang.Object
-
- io.prometheus.client.Collector
-
- io.prometheus.client.hotspot.StandardExports
-
public class StandardExports extends Collector
Exports the standard exports common across all prometheus clients.This includes stats like CPU time spent and memory usage.
Example usage:
new StandardExports().register();
-
-
Nested Class Summary
Nested Classes Modifier and Type Class Description (package private) static class
StandardExports.StatusReader
-
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 double
KB
private boolean
linux
private static java.util.logging.Logger
LOGGER
private java.lang.management.OperatingSystemMXBean
osBean
private java.lang.management.RuntimeMXBean
runtimeBean
private StandardExports.StatusReader
statusReader
-
Fields inherited from class io.prometheus.client.Collector
MILLISECONDS_PER_SECOND, NANOSECONDS_PER_SECOND
-
-
Constructor Summary
Constructors Constructor Description StandardExports()
StandardExports(StandardExports.StatusReader statusReader, java.lang.management.OperatingSystemMXBean osBean, java.lang.management.RuntimeMXBean runtimeBean)
-
Method Summary
All Methods Static Methods Instance Methods Concrete Methods Modifier and Type Method Description (package private) static java.lang.Long
callLongGetter(java.lang.reflect.Method method, java.lang.Object obj)
Attempts to call a method either directly or via one of the implemented interfaces.(package private) static java.lang.Long
callLongGetter(java.lang.String getterName, java.lang.Object obj)
java.util.List<Collector.MetricFamilySamples>
collect()
Return all metrics of this Collector.(package private) void
collectMemoryMetricsLinux(java.util.List<Collector.MetricFamilySamples> mfs)
-
Methods inherited from class io.prometheus.client.Collector
checkMetricLabelName, checkMetricName, collect, doubleToGoString, register, register, sanitizeMetricName
-
-
-
-
Field Detail
-
LOGGER
private static final java.util.logging.Logger LOGGER
-
statusReader
private final StandardExports.StatusReader statusReader
-
osBean
private final java.lang.management.OperatingSystemMXBean osBean
-
runtimeBean
private final java.lang.management.RuntimeMXBean runtimeBean
-
linux
private final boolean linux
-
KB
private static final double KB
- See Also:
- Constant Field Values
-
-
Constructor Detail
-
StandardExports
public StandardExports()
-
StandardExports
StandardExports(StandardExports.StatusReader statusReader, java.lang.management.OperatingSystemMXBean osBean, java.lang.management.RuntimeMXBean runtimeBean)
-
-
Method Detail
-
collect
public java.util.List<Collector.MetricFamilySamples> collect()
Description copied from class:Collector
Return all metrics of this Collector.
-
callLongGetter
static java.lang.Long callLongGetter(java.lang.String getterName, java.lang.Object obj) throws java.lang.NoSuchMethodException, java.lang.reflect.InvocationTargetException
- Throws:
java.lang.NoSuchMethodException
java.lang.reflect.InvocationTargetException
-
callLongGetter
static java.lang.Long callLongGetter(java.lang.reflect.Method method, java.lang.Object obj) throws java.lang.reflect.InvocationTargetException
Attempts to call a method either directly or via one of the implemented interfaces.A Method object refers to a specific method declared in a specific class. The first invocation might happen with method == SomeConcreteClass.publicLongGetter() and will fail if SomeConcreteClass is not public. We then recurse over all interfaces implemented by SomeConcreteClass (or extended by those interfaces and so on) until we eventually invoke callMethod() with method == SomePublicInterface.publicLongGetter(), which will then succeed.
There is a built-in assumption that the method will never return null (or, equivalently, that it returns the primitive data type, i.e.
long
rather thanLong
). If this assumption doesn't hold, the method might be called repeatedly and the returned value will be the one produced by the last call.- Throws:
java.lang.reflect.InvocationTargetException
-
collectMemoryMetricsLinux
void collectMemoryMetricsLinux(java.util.List<Collector.MetricFamilySamples> mfs)
-
-