Search in sources :

Example 6 with Histogram

use of wavefront.report.Histogram in project java by wavefrontHQ.

the class HistogramDecoderTest method testNegativeMean.

@Test
public void testNegativeMean() {
    HistogramDecoder decoder = new HistogramDecoder();
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("!M 1471988653 #1 -3.1416 TestMetric", out, "customer");
    assertThat(out).isNotEmpty();
    ReportPoint p = out.get(0);
    assertThat(p.getValue()).isNotNull();
    assertThat(p.getValue().getClass()).isEqualTo(Histogram.class);
    Histogram h = (Histogram) p.getValue();
    assertThat(h.getDuration()).isEqualTo(DateUtils.MILLIS_PER_MINUTE);
    assertThat(h.getBins()).isNotNull();
    assertThat(h.getBins()).isNotEmpty();
    assertThat(h.getBins()).containsExactly(-3.1416D);
    assertThat(h.getCounts()).isNotNull();
    assertThat(h.getCounts()).isNotEmpty();
    assertThat(h.getCounts()).containsExactly(1);
}
Also used : Histogram(wavefront.report.Histogram) ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 7 with Histogram

use of wavefront.report.Histogram in project java by wavefrontHQ.

the class HistogramDecoderTest method testMissingMean.

@Test
public void testMissingMean() {
    // Note - missingTimestamp to port 40,000 is no longer invalid - see MONIT-6430 for more details
    // as a side-effect of that, this test no longer fails!!!
    HistogramDecoder decoder = new HistogramDecoder();
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("!M #3 1471988653 TestMetric source=Test tag=value", out, "customer");
    assertThat(out).isNotEmpty();
    long expectedTimestamp = Clock.now();
    ReportPoint p = out.get(0);
    assertThat(p.getMetric()).isEqualTo("TestMetric");
    assertThat(p.getValue()).isNotNull();
    assertThat(p.getValue().getClass()).isEqualTo(Histogram.class);
    // Should be converted to Millis and pinned to the beginning of the corresponding minute
    long duration = ((Histogram) p.getValue()).getDuration();
    expectedTimestamp = (expectedTimestamp / duration) * duration;
    assertThat(p.getTimestamp()).isEqualTo(expectedTimestamp);
    assertThat(p.getHost()).isEqualTo("Test");
    assertThat(p.getTable()).isEqualTo("customer");
    assertThat(p.getAnnotations()).isNotNull();
    assertThat(p.getAnnotations()).containsEntry("_tag", "value");
    Histogram h = (Histogram) p.getValue();
    assertThat(h.getDuration()).isEqualTo(DateUtils.MILLIS_PER_MINUTE);
    assertThat(h.getBins()).isNotNull();
    assertThat(h.getBins()).isNotEmpty();
    assertThat(h.getBins()).containsExactly(1471988653.0);
    assertThat(h.getCounts()).isNotNull();
    assertThat(h.getCounts()).isNotEmpty();
    assertThat(h.getCounts()).containsExactly(3);
}
Also used : Histogram(wavefront.report.Histogram) ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 8 with Histogram

use of wavefront.report.Histogram in project java by wavefrontHQ.

the class HistogramDecoderTest method testDayBin.

@Test
public void testDayBin() {
    HistogramDecoder decoder = new HistogramDecoder();
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("!D 1471988653 #3 123.237 TestMetric source=Test key=value", out, "customer");
    assertThat(out).isNotEmpty();
    ReportPoint p = out.get(0);
    // Should be converted to Millis and pinned to the beginning of the corresponding day
    assertThat(p.getTimestamp()).isEqualTo(1471910400000L);
    assertThat(p.getValue()).isNotNull();
    assertThat(p.getValue().getClass()).isEqualTo(Histogram.class);
    Histogram h = (Histogram) p.getValue();
    assertThat(h.getDuration()).isEqualTo(DateUtils.MILLIS_PER_DAY);
}
Also used : Histogram(wavefront.report.Histogram) ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 9 with Histogram

use of wavefront.report.Histogram in project java by wavefrontHQ.

the class HistogramDecoderTest method testHourBin.

@Test
public void testHourBin() {
    HistogramDecoder decoder = new HistogramDecoder();
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("!H 1471988653 #3 123.237 TestMetric source=Test key=value", out, "customer");
    assertThat(out).isNotEmpty();
    ReportPoint p = out.get(0);
    // Should be converted to Millis and pinned to the beginning of the corresponding hour
    assertThat(p.getTimestamp()).isEqualTo(1471986000000L);
    assertThat(p.getValue()).isNotNull();
    assertThat(p.getValue().getClass()).isEqualTo(Histogram.class);
    Histogram h = (Histogram) p.getValue();
    assertThat(h.getDuration()).isEqualTo(DateUtils.MILLIS_PER_HOUR);
}
Also used : Histogram(wavefront.report.Histogram) ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 10 with Histogram

use of wavefront.report.Histogram in project java by wavefrontHQ.

the class HistogramDecoderTest method testMultipleBuckets.

@Test
public void testMultipleBuckets() {
    HistogramDecoder decoder = new HistogramDecoder();
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("!M 1471988653 #1 3.1416 #1 2.7183 TestMetric", out, "customer");
    assertThat(out).isNotEmpty();
    ReportPoint p = out.get(0);
    assertThat(p.getValue()).isNotNull();
    assertThat(p.getValue().getClass()).isEqualTo(Histogram.class);
    Histogram h = (Histogram) p.getValue();
    assertThat(h.getDuration()).isEqualTo(DateUtils.MILLIS_PER_MINUTE);
    assertThat(h.getBins()).isNotNull();
    assertThat(h.getBins()).isNotEmpty();
    assertThat(h.getBins()).containsExactly(3.1416D, 2.7183D);
    assertThat(h.getCounts()).isNotNull();
    assertThat(h.getCounts()).isNotEmpty();
    assertThat(h.getCounts()).containsExactly(1, 1);
}
Also used : Histogram(wavefront.report.Histogram) ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Aggregations

Histogram (wavefront.report.Histogram)14 Test (org.junit.Test)10 ReportPoint (wavefront.report.ReportPoint)10 ArrayList (java.util.ArrayList)7 JsonNode (com.fasterxml.jackson.databind.JsonNode)1 Throwables (com.google.common.base.Throwables)1 Lists (com.google.common.collect.Lists)1 ObjectQueue (com.squareup.tape.ObjectQueue)1 AgentDigest (com.tdunning.math.stats.AgentDigest)1 PointHandler (com.wavefront.agent.PointHandler)1 PointHandlerImpl.pointToString (com.wavefront.agent.PointHandlerImpl.pointToString)1 Validation (com.wavefront.agent.Validation)1 Utils (com.wavefront.agent.histogram.Utils)1 Granularity.fromMillis (com.wavefront.agent.histogram.Utils.Granularity.fromMillis)1 Decoder (com.wavefront.ingester.Decoder)1 Metrics (com.yammer.metrics.Metrics)1 Counter (com.yammer.metrics.core.Counter)1 MetricName (com.yammer.metrics.core.MetricName)1 System.nanoTime (java.lang.System.nanoTime)1 List (java.util.List)1