Search in sources :

Example 1 with MetricAttribute

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);
}
Also used : Counter(com.codahale.metrics.Counter) InOrder(org.mockito.InOrder) Meter(com.codahale.metrics.Meter) MetricAttribute(com.codahale.metrics.MetricAttribute) Test(org.junit.Test)

Aggregations

Counter (com.codahale.metrics.Counter)1 Meter (com.codahale.metrics.Meter)1 MetricAttribute (com.codahale.metrics.MetricAttribute)1 Test (org.junit.Test)1 InOrder (org.mockito.InOrder)1