use of com.yammer.metrics.core.WavefrontHistogram in project java by wavefrontHQ.
the class JsonMetricsGeneratorTest method testWavefrontHistogramBulkUpdateHandlesMismatchedLengths.
@Test
public void testWavefrontHistogramBulkUpdateHandlesMismatchedLengths() throws IOException {
WavefrontHistogram wh = WavefrontHistogram.get(testRegistry, new MetricName("test", "", "metric"), time::get);
wh.bulkUpdate(ImmutableList.of(15d, 30d, 45d, 100d), ImmutableList.of(1, 5, 1));
wh.bulkUpdate(ImmutableList.of(1d, 2d, 3d), ImmutableList.of(1, 1, 1, 9));
// Simulate the 1 minute has passed and we are ready to flush the histogram
// (i.e. all the values prior to the current minute) over the wire...
time.addAndGet(60001L);
String json = generate(false, false, false, null);
assertThat(json).isEqualTo("{\"test.metric\":{\"bins\":[{\"count\":10,\"startMillis\":0,\"durationMillis\":60000,\"means\":[1.0,2.0,3.0,15.0,30.0,45.0],\"counts\":[1,1,1,1,5,1]}]}}");
}
use of com.yammer.metrics.core.WavefrontHistogram in project java by wavefrontHQ.
the class WavefrontYammerMetricsReporterTest method testWavefrontHistogram.
@Test(timeout = 1000)
public void testWavefrontHistogram() throws Exception {
AtomicLong clock = new AtomicLong(System.currentTimeMillis());
WavefrontHistogram wavefrontHistogram = WavefrontHistogram.get(metricsRegistry, new TaggedMetricName("group", "myhisto", "tag1", "value1", "tag2", "value2"), clock::get);
for (int i = 0; i < 101; i++) {
wavefrontHistogram.update(i);
}
// Advance the clock by 1 min ...
clock.addAndGet(60000L + 1);
wavefrontYammerMetricsReporter.run();
assertThat(receiveFromSocket(1, fromHistograms), contains(equalTo("!M 1485224035 #101 50.0 \"myhisto\" tag1=\"value1\" tag2=\"value2\"")));
}
use of com.yammer.metrics.core.WavefrontHistogram in project java by wavefrontHQ.
the class WavefrontYammerMetricsReporterTest method testPrependGroupName.
@Test(timeout = 1000)
public void testPrependGroupName() throws Exception {
innerSetUp(true, null, false, false);
// Counter
TaggedMetricName taggedMetricName = new TaggedMetricName("group", "mycounter", "tag1", "value1", "tag2", "value2");
Counter counter = metricsRegistry.newCounter(taggedMetricName);
counter.inc();
counter.inc();
AtomicLong clock = new AtomicLong(System.currentTimeMillis());
// Wavefront Histo
WavefrontHistogram wavefrontHistogram = WavefrontHistogram.get(metricsRegistry, new TaggedMetricName("group3", "myhisto", "tag1", "value1", "tag2", "value2"), clock::get);
for (int i = 0; i < 101; i++) {
wavefrontHistogram.update(i);
}
// Exploded Histo
Histogram histogram = metricsRegistry.newHistogram(new MetricName("group2", "", "myhisto"), false);
histogram.update(1);
histogram.update(10);
// Advance the clock by 1 min ...
clock.addAndGet(60000L + 1);
wavefrontYammerMetricsReporter.run();
assertThat(receiveFromSocket(12, fromMetrics), containsInAnyOrder(equalTo("\"group.mycounter\" 2.0 1485224035 tag1=\"value1\" tag2=\"value2\""), equalTo("\"group2.myhisto.count\" 2.0 1485224035"), equalTo("\"group2.myhisto.min\" 1.0 1485224035"), equalTo("\"group2.myhisto.max\" 10.0 1485224035"), equalTo("\"group2.myhisto.mean\" 5.5 1485224035"), equalTo("\"group2.myhisto.sum\" 11.0 1485224035"), startsWith("\"group2.myhisto.stddev\""), equalTo("\"group2.myhisto.median\" 5.5 1485224035"), equalTo("\"group2.myhisto.p75\" 10.0 1485224035"), equalTo("\"group2.myhisto.p95\" 10.0 1485224035"), equalTo("\"group2.myhisto.p99\" 10.0 1485224035"), equalTo("\"group2.myhisto.p999\" 10.0 1485224035")));
assertThat(receiveFromSocket(1, fromHistograms), contains(equalTo("!M 1485224035 #101 50.0 \"group3.myhisto\" tag1=\"value1\" tag2=\"value2\"")));
}
Aggregations