Class 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();
     
     
    • Field Detail

      • LOGGER

        private static final java.util.logging.Logger LOGGER
      • osBean

        private final java.lang.management.OperatingSystemMXBean osBean
      • runtimeBean

        private final java.lang.management.RuntimeMXBean runtimeBean
      • linux

        private final boolean linux
    • Constructor Detail

      • StandardExports

        public StandardExports()
      • StandardExports

        StandardExports​(StandardExports.StatusReader statusReader,
                        java.lang.management.OperatingSystemMXBean osBean,
                        java.lang.management.RuntimeMXBean runtimeBean)
    • Method Detail

      • 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 than Long). 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