Search in sources :

Example 6 with WavefrontHistogram

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]}]}}");
}
Also used : MetricName(com.yammer.metrics.core.MetricName) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Test(org.junit.Test)

Example 7 with WavefrontHistogram

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\"")));
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) TaggedMetricName(com.wavefront.common.TaggedMetricName) Test(org.junit.Test)

Example 8 with WavefrontHistogram

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\"")));
}
Also used : MetricName(com.yammer.metrics.core.MetricName) TaggedMetricName(com.wavefront.common.TaggedMetricName) AtomicLong(java.util.concurrent.atomic.AtomicLong) Histogram(com.yammer.metrics.core.Histogram) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) Counter(com.yammer.metrics.core.Counter) WavefrontHistogram(com.yammer.metrics.core.WavefrontHistogram) TaggedMetricName(com.wavefront.common.TaggedMetricName) Test(org.junit.Test)

Aggregations

WavefrontHistogram (com.yammer.metrics.core.WavefrontHistogram)8 MetricName (com.yammer.metrics.core.MetricName)5 Test (org.junit.Test)5 TaggedMetricName (com.wavefront.common.TaggedMetricName)3 Counter (com.yammer.metrics.core.Counter)3 Histogram (com.yammer.metrics.core.Histogram)3 AtomicLong (java.util.concurrent.atomic.AtomicLong)2 AVLTreeDigest (com.tdunning.math.stats.AVLTreeDigest)1 Centroid (com.tdunning.math.stats.Centroid)1 TDigest (com.tdunning.math.stats.TDigest)1 MetricsToTimeseries (com.wavefront.common.MetricsToTimeseries)1 Metrics (com.yammer.metrics.Metrics)1 DeltaCounter (com.yammer.metrics.core.DeltaCounter)1 Gauge (com.yammer.metrics.core.Gauge)1 Metered (com.yammer.metrics.core.Metered)1 MetricProcessor (com.yammer.metrics.core.MetricProcessor)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 Sampling (com.yammer.metrics.core.Sampling)1 Summarizable (com.yammer.metrics.core.Summarizable)1 Timer (com.yammer.metrics.core.Timer)1