protected void recordMetricsForPool ( final MemoryPoolMXBean pool , final Metrics metrics ) { final MemoryUsage usage = pool . getUsage ( ) ; metrics . setGauge ( String . join ( "/" , ROOT_NAMESPACE , memoryTypeSegment ( pool . getType ( ) ) , MetricsUtil . convertToSnakeCase ( pool . getName ( ) ) , MEMORY_USED ) , usage . getUsed ( ) , Units . BYTE ) ; final long memoryMax = usage . getMax ( ) ; if ( memoryMax != - 1 ) { metrics . setGauge ( String . join ( "/" , ROOT_NAMESPACE , memoryTypeSegment ( pool . getType ( ) ) , MetricsUtil . convertToSnakeCase ( pool . getName ( ) ) , MEMORY_MAX ) , memoryMax , Units . BYTE ) ; } }
Records the metrics for a given pool . Useful if a deriving class filters the list of pools to collect .