Class MemoryPoolsExports


  • public class MemoryPoolsExports
    extends Collector
    Exports metrics about JVM memory areas.

    Example usage:

     
       new MemoryPoolsExports().register();
     
     
    Example metrics being exported:
       jvm_memory_bytes_used{area="heap"} 2000000
       jvm_memory_bytes_committed{area="nonheap"} 200000
       jvm_memory_bytes_max{area="nonheap"} 2000000
       jvm_memory_pool_bytes_used{pool="PS Eden Space"} 2000
     
    • Field Detail

      • JVM_MEMORY_OBJECTS_PENDING_FINALIZATION

        private static final java.lang.String JVM_MEMORY_OBJECTS_PENDING_FINALIZATION
        See Also:
        Constant Field Values
      • JVM_MEMORY_BYTES_USED

        private static final java.lang.String JVM_MEMORY_BYTES_USED
        See Also:
        Constant Field Values
      • JVM_MEMORY_BYTES_COMMITTED

        private static final java.lang.String JVM_MEMORY_BYTES_COMMITTED
        See Also:
        Constant Field Values
      • JVM_MEMORY_BYTES_MAX

        private static final java.lang.String JVM_MEMORY_BYTES_MAX
        See Also:
        Constant Field Values
      • JVM_MEMORY_BYTES_INIT

        private static final java.lang.String JVM_MEMORY_BYTES_INIT
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_BYTES_USED

        private static final java.lang.String JVM_MEMORY_POOL_BYTES_USED
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_BYTES_COMMITTED

        private static final java.lang.String JVM_MEMORY_POOL_BYTES_COMMITTED
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_BYTES_MAX

        private static final java.lang.String JVM_MEMORY_POOL_BYTES_MAX
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_BYTES_INIT

        private static final java.lang.String JVM_MEMORY_POOL_BYTES_INIT
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_COLLECTION_USED_BYTES

        private static final java.lang.String JVM_MEMORY_POOL_COLLECTION_USED_BYTES
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_COLLECTION_COMMITTED_BYTES

        private static final java.lang.String JVM_MEMORY_POOL_COLLECTION_COMMITTED_BYTES
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_COLLECTION_MAX_BYTES

        private static final java.lang.String JVM_MEMORY_POOL_COLLECTION_MAX_BYTES
        See Also:
        Constant Field Values
      • JVM_MEMORY_POOL_COLLECTION_INIT_BYTES

        private static final java.lang.String JVM_MEMORY_POOL_COLLECTION_INIT_BYTES
        See Also:
        Constant Field Values
      • memoryBean

        private final java.lang.management.MemoryMXBean memoryBean
      • poolBeans

        private final java.util.List<java.lang.management.MemoryPoolMXBean> poolBeans
    • Constructor Detail

      • MemoryPoolsExports

        public MemoryPoolsExports()
      • MemoryPoolsExports

        public MemoryPoolsExports​(java.lang.management.MemoryMXBean memoryBean,
                                  java.util.List<java.lang.management.MemoryPoolMXBean> poolBeans)
    • Method Detail

      • collect

        public java.util.List<Collector.MetricFamilySamples> collect​(Predicate<java.lang.String> nameFilter)
        Description copied from class: Collector
        Like Collector.collect(), but the result should only contain MetricFamilySamples where sampleNameFilter.test(name) is true for at least one Sample name.

        The default implementation first collects all MetricFamilySamples and then discards the ones where sampleNameFilter.test(name) returns false for all names in Collector.MetricFamilySamples.getNames(). To improve performance, collector implementations should override this method to prevent MetricFamilySamples from being collected if they will be discarded anyways. See ThreadExports for an example.

        Note that the resulting List may contain MetricFamilySamples where some Sample names return true for sampleNameFilter.test(name) but some Sample names return false. This is ok, because before we produce the output format we will call Collector.MetricFamilySamples.filter(Predicate) to strip all Samples where sampleNameFilter.test(name) returns false.

        Overrides:
        collect in class Collector
        Parameters:
        nameFilter - may be null, indicating that all metrics should be collected.