Search in sources :

Example 1 with Snapshot

use of io.dropwizard.metrics.Snapshot in project java by wavefrontHQ.

the class WavefrontReporter method reportHistogram.

private void reportHistogram(MetricName name, Histogram histogram, long timestamp, Map<String, String> combinedTags) throws IOException {
    final Snapshot snapshot = histogram.getSnapshot();
    wavefront.send(prefix(name, "count"), histogram.getCount(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "max"), snapshot.getMax(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "mean"), snapshot.getMean(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "min"), snapshot.getMin(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "stddev"), snapshot.getStdDev(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "p50"), snapshot.getMedian(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "p75"), snapshot.get75thPercentile(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "p95"), snapshot.get95thPercentile(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "p98"), snapshot.get98thPercentile(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "p99"), snapshot.get99thPercentile(), timestamp, source, combinedTags);
    wavefront.send(prefix(name, "p999"), snapshot.get999thPercentile(), timestamp, source, combinedTags);
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot)

Example 2 with Snapshot

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

the class JmxReporterTest method setUp.

@Before
public void setUp() throws Exception {
    when(gauge.getValue()).thenReturn(1);
    when(counter.getCount()).thenReturn(100L);
    when(histogram.getCount()).thenReturn(1L);
    final Snapshot hSnapshot = mock(Snapshot.class);
    when(hSnapshot.getMax()).thenReturn(2L);
    when(hSnapshot.getMean()).thenReturn(3.0);
    when(hSnapshot.getMin()).thenReturn(4L);
    when(hSnapshot.getStdDev()).thenReturn(5.0);
    when(hSnapshot.getMedian()).thenReturn(6.0);
    when(hSnapshot.get75thPercentile()).thenReturn(7.0);
    when(hSnapshot.get95thPercentile()).thenReturn(8.0);
    when(hSnapshot.get98thPercentile()).thenReturn(9.0);
    when(hSnapshot.get99thPercentile()).thenReturn(10.0);
    when(hSnapshot.get999thPercentile()).thenReturn(11.0);
    when(histogram.getSnapshot()).thenReturn(hSnapshot);
    when(meter.getCount()).thenReturn(1L);
    when(meter.getMeanRate()).thenReturn(2.0);
    when(meter.getOneMinuteRate()).thenReturn(3.0);
    when(meter.getFiveMinuteRate()).thenReturn(4.0);
    when(meter.getFifteenMinuteRate()).thenReturn(5.0);
    when(timer.getCount()).thenReturn(1L);
    when(timer.getMeanRate()).thenReturn(2.0);
    when(timer.getOneMinuteRate()).thenReturn(3.0);
    when(timer.getFiveMinuteRate()).thenReturn(4.0);
    when(timer.getFifteenMinuteRate()).thenReturn(5.0);
    final Snapshot tSnapshot = mock(Snapshot.class);
    when(tSnapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100));
    when(tSnapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200));
    when(tSnapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300));
    when(tSnapshot.getStdDev()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(400));
    when(tSnapshot.getMedian()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(500));
    when(tSnapshot.get75thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(600));
    when(tSnapshot.get95thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(700));
    when(tSnapshot.get98thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(800));
    when(tSnapshot.get99thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(900));
    when(tSnapshot.get999thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(1000));
    when(timer.getSnapshot()).thenReturn(tSnapshot);
    registry.register("gauge", gauge);
    registry.register("test.counter", counter);
    registry.register("test.histogram", histogram);
    registry.register("test.meter", meter);
    registry.register("test.another.timer", timer);
    reporter.start();
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) Before(org.junit.Before)

Example 3 with Snapshot

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

the class InfluxDbReporterTest method reportsHistograms.

@Test
public void reportsHistograms() throws Exception {
    final Histogram histogram = mock(Histogram.class);
    when(histogram.getCount()).thenReturn(1L);
    final Snapshot snapshot = mock(Snapshot.class);
    when(snapshot.getMax()).thenReturn(2L);
    when(snapshot.getMean()).thenReturn(3.0);
    when(snapshot.getMin()).thenReturn(4L);
    when(snapshot.getStdDev()).thenReturn(5.0);
    when(snapshot.getMedian()).thenReturn(6.0);
    when(snapshot.get75thPercentile()).thenReturn(7.0);
    when(snapshot.get95thPercentile()).thenReturn(8.0);
    when(snapshot.get98thPercentile()).thenReturn(9.0);
    when(snapshot.get99thPercentile()).thenReturn(10.0);
    when(snapshot.get999thPercentile()).thenReturn(11.0);
    when(histogram.getSnapshot()).thenReturn(snapshot);
    reporter.report(this.map(), this.map(), this.map("histogram", histogram), this.map(), this.map());
    final ArgumentCaptor<InfluxDbPoint> influxDbPointCaptor = ArgumentCaptor.forClass(InfluxDbPoint.class);
    Mockito.verify(influxDb, atLeastOnce()).appendPoints(influxDbPointCaptor.capture());
    InfluxDbPoint point = influxDbPointCaptor.getValue();
/*
        assertThat(point.getMeasurement()).isEqualTo("histogram");
        assertThat(point.getFields()).isNotEmpty();
        assertThat(point.getFields()).hasSize(13);
        assertThat(point.getFields()).contains(entry("max", 2L));
        assertThat(point.getFields()).contains(entry("mean", 3.0));
        assertThat(point.getFields()).contains(entry("min", 4L));
        assertThat(point.getFields()).contains(entry("std-dev", 5.0));
        assertThat(point.getFields()).contains(entry("median", 6.0));
        assertThat(point.getFields()).contains(entry("75-percentile", 7.0));
        assertThat(point.getFields()).contains(entry("95-percentile", 8.0));
        assertThat(point.getFields()).contains(entry("98-percentile", 9.0));
        assertThat(point.getFields()).contains(entry("99-percentile", 10.0));
        assertThat(point.getFields()).contains(entry("999-percentile", 11.0));
        */
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) Histogram(io.dropwizard.metrics.Histogram) InfluxDbPoint(io.dropwizard.metrics.influxdb.data.InfluxDbPoint) Test(org.junit.Test)

Example 4 with Snapshot

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

the class Slf4jReporterTest method reportsTimerValuesAtError.

@Test
public void reportsTimerValuesAtError() throws Exception {
    final Timer timer = mock(Timer.class);
    when(timer.getCount()).thenReturn(1L);
    when(timer.getMeanRate()).thenReturn(2.0);
    when(timer.getOneMinuteRate()).thenReturn(3.0);
    when(timer.getFiveMinuteRate()).thenReturn(4.0);
    when(timer.getFifteenMinuteRate()).thenReturn(5.0);
    final Snapshot snapshot = mock(Snapshot.class);
    when(snapshot.getMax()).thenReturn(TimeUnit.MILLISECONDS.toNanos(100));
    when(snapshot.getMean()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(200));
    when(snapshot.getMin()).thenReturn(TimeUnit.MILLISECONDS.toNanos(300));
    when(snapshot.getStdDev()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(400));
    when(snapshot.getMedian()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(500));
    when(snapshot.get75thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(600));
    when(snapshot.get95thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(700));
    when(snapshot.get98thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(800));
    when(snapshot.get99thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(900));
    when(snapshot.get999thPercentile()).thenReturn((double) TimeUnit.MILLISECONDS.toNanos(1000));
    when(timer.getSnapshot()).thenReturn(snapshot);
    when(logger.isErrorEnabled(marker)).thenReturn(true);
    errorReporter.report(this.map(), this.map(), this.map(), this.map(), map("test.another.timer", timer));
    verify(logger).error(marker, "type={}, name={}, count={}, min={}, max={}, mean={}, stddev={}, median={}, p75={}, p95={}, p98={}, p99={}, p999={}, mean_rate={}, m1={}, m5={}, m15={}, rate_unit={}, duration_unit={}", "TIMER", "test.another.timer", 1L, 300.0, 100.0, 200.0, 400.0, 500.0, 600.0, 700.0, 800.0, 900.0, 1000.0, 2.0, 3.0, 4.0, 5.0, "events/second", "milliseconds");
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) Timer(io.dropwizard.metrics.Timer) Test(org.junit.Test)

Example 5 with Snapshot

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

the class Slf4jReporterTest method reportsHistogramValuesAtError.

@Test
public void reportsHistogramValuesAtError() throws Exception {
    final Histogram histogram = mock(Histogram.class);
    when(histogram.getCount()).thenReturn(1L);
    final Snapshot snapshot = mock(Snapshot.class);
    when(snapshot.getMax()).thenReturn(2L);
    when(snapshot.getMean()).thenReturn(3.0);
    when(snapshot.getMin()).thenReturn(4L);
    when(snapshot.getStdDev()).thenReturn(5.0);
    when(snapshot.getMedian()).thenReturn(6.0);
    when(snapshot.get75thPercentile()).thenReturn(7.0);
    when(snapshot.get95thPercentile()).thenReturn(8.0);
    when(snapshot.get98thPercentile()).thenReturn(9.0);
    when(snapshot.get99thPercentile()).thenReturn(10.0);
    when(snapshot.get999thPercentile()).thenReturn(11.0);
    when(histogram.getSnapshot()).thenReturn(snapshot);
    when(logger.isErrorEnabled(marker)).thenReturn(true);
    errorReporter.report(this.map(), this.map(), map("test.histogram", histogram), this.map(), this.map());
    verify(logger).error(marker, "type={}, name={}, count={}, min={}, max={}, mean={}, stddev={}, median={}, p75={}, p95={}, p98={}, p99={}, p999={}", "HISTOGRAM", "test.histogram", 1L, 4L, 2L, 3.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0);
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) Histogram(io.dropwizard.metrics.Histogram) Test(org.junit.Test)

Aggregations

Snapshot (io.dropwizard.metrics.Snapshot)33 Test (org.junit.Test)28 WeightedSnapshot (io.dropwizard.metrics.WeightedSnapshot)8 UniformSnapshot (io.dropwizard.metrics.UniformSnapshot)6 Histogram (io.dropwizard.metrics.Histogram)4 Timer (io.dropwizard.metrics.Timer)4 InfluxDbPoint (io.dropwizard.metrics.influxdb.data.InfluxDbPoint)4 ExponentiallyDecayingReservoir (io.dropwizard.metrics.ExponentiallyDecayingReservoir)3 WeightedSample (io.dropwizard.metrics.WeightedSnapshot.WeightedSample)2 UniformReservoir (io.dropwizard.metrics.UniformReservoir)1 Before (org.junit.Before)1