@Test public void gaugeReportsDirectMemoryUsageValue() throws Exception { when(metricUnderTest.usedDirectMemory()).thenReturn(1L); NettyAllocatorMetricSet metricSet = new NettyAllocatorMetricSet("test-metric", metricUnderTest); Gauge<Long> metric = (Gauge<Long>) metricSet.getMetrics().get("test-metric.usedDirectMemory"); assertThat(metric.getValue(), is(1L)); }
@Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::usedHeapMemory); return copyOf(gauges); }
NettyAllocatorMetricSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::usedHeapMemory); return copyOf(gauges); } }
NettyAllocatorMetricSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::usedHeapMemory); return copyOf(gauges); } NettyAllocatorMetricSet(String namespace,  ByteBufAllocatorMetric metric); }
NettyAllocatorMetricSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::usedHeapMemory); return copyOf(gauges); } NettyAllocatorMetricSet(String namespace,  ByteBufAllocatorMetric metric); @Override Map<String, Metric> getMetrics(); }
NettyAllocatorMetricSet implements MetricSet { @Override public Map<String, Metric> getMetrics() { Map<String, Metric> gauges = new HashMap<>(); gauges.put(name(namespace, "usedDirectMemory"), (Gauge<Long>) metric::usedDirectMemory); gauges.put(name(namespace, "usedHeapMemory"), (Gauge<Long>) metric::usedHeapMemory); return copyOf(gauges); } NettyAllocatorMetricSet(String namespace,  ByteBufAllocatorMetric metric); @Override Map<String, Metric> getMetrics();  }