Search in sources :

Example 31 with Snapshot

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

the class WeightedSnapshotTest method worksWithUnderestimatedCollections.

@Test
public void worksWithUnderestimatedCollections() throws Exception {
    final List<WeightedSample> items = spy(WeightedArray(new long[] { 5, 1, 2, 3, 4 }, new double[] { 1, 2, 3, 2, 2 }));
    when(items.size()).thenReturn(4, 5);
    final Snapshot other = new WeightedSnapshot(items);
    assertThat(other.getValues()).containsOnly(1, 2, 3, 4, 5);
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSample(io.dropwizard.metrics.WeightedSnapshot.WeightedSample) Test(org.junit.Test)

Example 32 with Snapshot

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

the class WeightedSnapshotTest method calculatesAMaxOfZeroForAnEmptySnapshot.

@Test
public void calculatesAMaxOfZeroForAnEmptySnapshot() throws Exception {
    final Snapshot emptySnapshot = new WeightedSnapshot(WeightedArray(new long[] {}, new double[] {}));
    assertThat(emptySnapshot.getMax()).isZero();
}
Also used : Snapshot(io.dropwizard.metrics.Snapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) WeightedSnapshot(io.dropwizard.metrics.WeightedSnapshot) Test(org.junit.Test)

Example 33 with Snapshot

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

the class WavefrontReporter method reportTimer.

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

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