private void registerMetrics(PooledByteBufAllocator allocator) { PooledByteBufAllocatorMetric pooledAllocatorMetric = allocator.metric(); // Register general metrics. allMetrics.put(MetricRegistry.name(metricPrefix, "usedHeapMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedHeapMemory()); allMetrics.put(MetricRegistry.name(metricPrefix, "usedDirectMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedDirectMemory()); if (verboseMetricsEnabled) { int directArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.directArenas()) { registerArenaMetric(metric, "directArena" + directArenaIndex); directArenaIndex++; } int heapArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.heapArenas()) { registerArenaMetric(metric, "heapArena" + heapArenaIndex); heapArenaIndex++; } } }
private void registerMetrics(PooledByteBufAllocator allocator) { PooledByteBufAllocatorMetric pooledAllocatorMetric = allocator.metric(); // Register general metrics. allMetrics.put(MetricRegistry.name(metricPrefix, "usedHeapMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedHeapMemory()); allMetrics.put(MetricRegistry.name(metricPrefix, "usedDirectMemory"), (Gauge<Long>) () -> pooledAllocatorMetric.usedDirectMemory()); if (verboseMetricsEnabled) { int directArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.directArenas()) { registerArenaMetric(metric, "directArena" + directArenaIndex); directArenaIndex++; } int heapArenaIndex = 0; for (PoolArenaMetric metric : pooledAllocatorMetric.heapArenas()) { registerArenaMetric(metric, "heapArena" + heapArenaIndex); heapArenaIndex++; } } }