Class GarbageCollectorExports


  • public class GarbageCollectorExports
    extends Collector
    Exports metrics about JVM garbage collectors.

    Example usage:

     
       new GarbageCollectorExports().register();
     
     
    Example metrics being exported:
       jvm_gc_collection_seconds_count{gc="PS1"} 200
       jvm_gc_collection_seconds_sum{gc="PS1"} 6.7
     
    • Field Detail

      • JVM_GC_COLLECTION_SECONDS

        private static final java.lang.String JVM_GC_COLLECTION_SECONDS
        See Also:
        Constant Field Values
      • garbageCollectors

        private final java.util.List<java.lang.management.GarbageCollectorMXBean> garbageCollectors
    • Constructor Detail

      • GarbageCollectorExports

        public GarbageCollectorExports()
      • GarbageCollectorExports

        GarbageCollectorExports​(java.util.List<java.lang.management.GarbageCollectorMXBean> garbageCollectors)
    • 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.