Search in sources :

Example 6 with Meter

use of io.dropwizard.metrics.Meter in project light-4j by networknt.

the class MeterApproximationTest method controlMeter1MinuteMeanApproximation.

@Test
public void controlMeter1MinuteMeanApproximation() throws Exception {
    final Meter meter = simulateMetronome(62934, TimeUnit.MILLISECONDS, 3, TimeUnit.MINUTES);
    assertThat(meter.getOneMinuteRate() * 60.0).isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute));
}
Also used : Meter(io.dropwizard.metrics.Meter) Test(org.junit.Test)

Example 7 with Meter

use of io.dropwizard.metrics.Meter in project light-4j by networknt.

the class MeterApproximationTest method controlMeter5MinuteMeanApproximation.

@Test
public void controlMeter5MinuteMeanApproximation() throws Exception {
    final Meter meter = simulateMetronome(62934, TimeUnit.MILLISECONDS, 13, TimeUnit.MINUTES);
    assertThat(meter.getFiveMinuteRate() * 60.0).isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute));
}
Also used : Meter(io.dropwizard.metrics.Meter) Test(org.junit.Test)

Example 8 with Meter

use of io.dropwizard.metrics.Meter in project light-4j by networknt.

the class MeterApproximationTest method controlMeter15MinuteMeanApproximation.

@Test
public void controlMeter15MinuteMeanApproximation() throws Exception {
    final Meter meter = simulateMetronome(62934, TimeUnit.MILLISECONDS, 38, TimeUnit.MINUTES);
    assertThat(meter.getFifteenMinuteRate() * 60.0).isEqualTo(ratePerMinute, offset(0.1 * ratePerMinute));
}
Also used : Meter(io.dropwizard.metrics.Meter) Test(org.junit.Test)

Example 9 with Meter

use of io.dropwizard.metrics.Meter in project light-4j by networknt.

the class MeterApproximationTest method simulateMetronome.

private Meter simulateMetronome(long introDelay, TimeUnit introDelayUnit, long duration, TimeUnit durationUnit) {
    final ManualClock clock = new ManualClock();
    final Meter meter = new Meter(clock);
    clock.addNanos(introDelayUnit.toNanos(introDelay));
    final long endTick = clock.getTick() + durationUnit.toNanos(duration);
    final long marksIntervalInNanos = TimeUnit.MINUTES.toNanos(1) / ratePerMinute;
    while (clock.getTick() <= endTick) {
        clock.addNanos(marksIntervalInNanos);
        meter.mark();
    }
    return meter;
}
Also used : Meter(io.dropwizard.metrics.Meter)

Example 10 with Meter

use of io.dropwizard.metrics.Meter in project light-4j by networknt.

the class MetricRegistryTest method accessingAMeterRegistersAndReusesIt.

@Test
public void accessingAMeterRegistersAndReusesIt() throws Exception {
    final Meter meter1 = registry.meter(THING);
    final Meter meter2 = registry.meter(THING);
    assertThat(meter1).isSameAs(meter2);
    verify(listener).onMeterAdded(THING, meter1);
}
Also used : Meter(io.dropwizard.metrics.Meter) Test(org.junit.Test)

Aggregations

Meter (io.dropwizard.metrics.Meter)13 Test (org.junit.Test)10 Timer (io.dropwizard.metrics.Timer)4 Counter (io.dropwizard.metrics.Counter)3 InstrumentedExecutorService (io.dropwizard.metrics.InstrumentedExecutorService)2 Gauge (io.dropwizard.metrics.Gauge)1 Histogram (io.dropwizard.metrics.Histogram)1 MetricName (io.dropwizard.metrics.MetricName)1 MetricRegistry (io.dropwizard.metrics.MetricRegistry)1 ScheduledReporter (io.dropwizard.metrics.ScheduledReporter)1 InfluxDbReporter (io.dropwizard.metrics.influxdb.InfluxDbReporter)1 InfluxDbPoint (io.dropwizard.metrics.influxdb.data.InfluxDbPoint)1 ArrayList (java.util.ArrayList)1