protected void addGarbageCollectionMetrics ( Collection < Metric < ? > > result ) { List < GarbageCollectorMXBean > garbageCollectorMxBeans = ManagementFactory . getGarbageCollectorMXBeans ( ) ; for ( GarbageCollectorMXBean garbageCollectorMXBean : garbageCollectorMxBeans ) { String name = beautifyGcName ( garbageCollectorMXBean . getName ( ) ) ; result . add ( new Metric <> ( "gc." + name + ".count" , garbageCollectorMXBean . getCollectionCount ( ) ) ) ; result . add ( new Metric <> ( "gc." + name + ".time" , garbageCollectorMXBean . getCollectionTime ( ) ) ) ; } }
Add garbage collection metrics .