use of com.codahale.metrics.MetricAttribute in project metrics by dropwizard.
the class GraphiteReporterTest method disabledMetricsAttribute.
@Test
public void disabledMetricsAttribute() throws Exception {
final Meter meter = mock(Meter.class);
when(meter.getCount()).thenReturn(1L);
when(meter.getOneMinuteRate()).thenReturn(2.0);
when(meter.getFiveMinuteRate()).thenReturn(3.0);
when(meter.getFifteenMinuteRate()).thenReturn(4.0);
when(meter.getMeanRate()).thenReturn(5.0);
final Counter counter = mock(Counter.class);
when(counter.getCount()).thenReturn(11L);
Set<MetricAttribute> disabledMetricAttributes = EnumSet.of(MetricAttribute.M15_RATE, MetricAttribute.M5_RATE);
GraphiteReporter reporterWithdisabledMetricAttributes = GraphiteReporter.forRegistry(registry).withClock(clock).prefixedWith("prefix").convertRatesTo(TimeUnit.SECONDS).convertDurationsTo(TimeUnit.MILLISECONDS).filter(MetricFilter.ALL).disabledMetricAttributes(disabledMetricAttributes).build(graphite);
reporterWithdisabledMetricAttributes.report(map(), map("counter", counter), map(), map("meter", meter), map());
final InOrder inOrder = inOrder(graphite);
inOrder.verify(graphite).connect();
inOrder.verify(graphite).send("prefix.counter.count", "11", timestamp);
inOrder.verify(graphite).send("prefix.meter.count", "1", timestamp);
inOrder.verify(graphite).send("prefix.meter.m1_rate", "2.00", timestamp);
inOrder.verify(graphite).send("prefix.meter.mean_rate", "5.00", timestamp);
inOrder.verify(graphite).flush();
inOrder.verify(graphite).close();
verifyNoMoreInteractions(graphite);
}
Aggregations