@Override
    public void run() {
      PooledByteBufAllocatorMetric metric = PooledByteBufAllocator.DEFAULT.metric();
      numDirectArenas = metric.numDirectArenas();
      numHeapArenas = metric.numHeapArenas();
      numThreadLocalCaches = metric.numThreadLocalCaches();
      usedHeapMemory = metric.usedHeapMemory();
      usedDirectMemory = metric.usedDirectMemory();
      pinnedHeapMemory = PooledByteBufAllocator.DEFAULT.pinnedHeapMemory();
      pinnedDirectMemory = PooledByteBufAllocator.DEFAULT.pinnedDirectMemory();
      List<PoolArenaMetric> heapArenaMetrics = metric.heapArenas();
      List<PoolArenaMetric> directArenaMetrics = metric.directArenas();
      numHeapTotalAllocations = heapArenaMetrics.stream().mapToLong(PoolArenaMetric::numAllocations).sum();
      numHeapTotalDeallocations = heapArenaMetrics.stream().mapToLong(PoolArenaMetric::numDeallocations).sum();
      numHeapTotalActiveAllocations = heapArenaMetrics.stream().mapToLong(PoolArenaMetric::numActiveAllocations).sum();
      numDirectTotalAllocations = directArenaMetrics.stream().mapToLong(PoolArenaMetric::numAllocations).sum();
      numDirectTotalDeallocations = directArenaMetrics.stream().mapToLong(PoolArenaMetric::numDeallocations).sum();
      numDirectTotalActiveAllocations =
          directArenaMetrics.stream().mapToLong(PoolArenaMetric::numActiveAllocations).sum();
    }
Stop collecting metrics. This method would stop this singleton effectively. Do not reuse this single after
calling this method.
ambry-commons/src/main/java/com/github/ambry/commons/NettyInternalMetrics.java