Search in sources :

Example 36 with ReportPoint

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

the class HistogramDecoderTest method testNoSourceAnnotationsIsNotNull.

@Test
public void testNoSourceAnnotationsIsNotNull() {
    HistogramDecoder decoder = new HistogramDecoder();
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("!M #1 12334 TestMetric", out, "customer");
    ReportPoint p = out.get(0);
    assertNotNull(p.getAnnotations());
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 37 with ReportPoint

use of wavefront.report.ReportPoint 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 38 with ReportPoint

use of wavefront.report.ReportPoint 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 39 with ReportPoint

use of wavefront.report.ReportPoint 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 40 with ReportPoint

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

the class OpenTSDBDecoderTest method testDoubleFormat.

@Test
public void testDoubleFormat() throws Exception {
    List<String> customSourceTags = new ArrayList<String>();
    customSourceTags.add("fqdn");
    OpenTSDBDecoder decoder = new OpenTSDBDecoder("localhost", customSourceTags);
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("put tsdb.vehicle.charge.battery_level 12345.678 93.123e3 host=vehicle_2554", out);
    ReportPoint point = out.get(0);
    assertEquals("dummy", point.getTable());
    assertEquals("tsdb.vehicle.charge.battery_level", point.getMetric());
    assertEquals(93123.0, point.getValue());
    assertEquals(12345678L, point.getTimestamp().longValue());
    assertEquals("vehicle_2554", point.getHost());
    try {
        // need "PUT"
        decoder.decodeReportPoints("tsdb.vehicle.charge.battery_level 12345.678 93.123e3 host=vehicle_2554", out);
        fail();
    } catch (Exception ex) {
    }
    try {
        // need "timestamp"
        decoder.decodeReportPoints("put tsdb.vehicle.charge.battery_level 93.123e3 host=vehicle_2554", out);
        fail();
    } catch (Exception ex) {
    }
    try {
        // need "value"
        decoder.decodeReportPoints("put tsdb.vehicle.charge.battery_level 12345.678 host=vehicle_2554", out);
        fail();
    } catch (Exception ex) {
    }
    out = new ArrayList<>();
    decoder.decodeReportPoints("put tsdb.vehicle.charge.battery_level 12345.678 93.123e3", out);
    point = out.get(0);
    assertEquals("dummy", point.getTable());
    assertEquals("tsdb.vehicle.charge.battery_level", point.getMetric());
    assertEquals(93123.0, point.getValue());
    assertEquals(12345678L, point.getTimestamp().longValue());
    assertEquals("localhost", point.getHost());
    // adaptive timestamp (13-char timestamp is millis).
    out = new ArrayList<>();
    final long now = System.currentTimeMillis();
    decoder.decodeReportPoints("put tsdb.vehicle.charge.battery_level " + now + " 93.123e3", out);
    point = out.get(0);
    assertEquals("dummy", point.getTable());
    assertEquals("tsdb.vehicle.charge.battery_level", point.getMetric());
    assertEquals(93123.0, point.getValue());
    assertEquals(now, point.getTimestamp().longValue());
    assertEquals("localhost", point.getHost());
    out = new ArrayList<>();
    decoder.decodeReportPoints("put tail.kernel.counter.errors 1447394143 0 fqdn=li250-160.members.linode.com  ", out);
    point = out.get(0);
    assertEquals("dummy", point.getTable());
    assertEquals("tail.kernel.counter.errors", point.getMetric());
    assertEquals(0.0, point.getValue());
    assertEquals(1447394143000L, point.getTimestamp().longValue());
    assertEquals("li250-160.members.linode.com", point.getHost());
    out = new ArrayList<>();
    decoder.decodeReportPoints("put df.home-ubuntu-efs.df_complex.free 1447985300 9.22337186120781e+18 fqdn=ip-172-20-0-236.us-west-2.compute.internal  ", out);
    point = out.get(0);
    assertEquals("dummy", point.getTable());
    assertEquals("df.home-ubuntu-efs.df_complex.free", point.getMetric());
    assertEquals(9.22337186120781e+18, point.getValue());
    assertEquals(1447985300000L, point.getTimestamp().longValue());
    assertEquals("ip-172-20-0-236.us-west-2.compute.internal", point.getHost());
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Aggregations

ReportPoint (wavefront.report.ReportPoint)71 Test (org.junit.Test)50 ArrayList (java.util.ArrayList)24 Histogram (wavefront.report.Histogram)10 PointHandler (com.wavefront.agent.PointHandler)4 List (java.util.List)4 JsonNode (com.fasterxml.jackson.databind.JsonNode)3 IOException (java.io.IOException)3 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 AgentDigest (com.tdunning.math.stats.AgentDigest)2 InetSocketAddress (java.net.InetSocketAddress)2 HashMap (java.util.HashMap)2 AtomicInteger (java.util.concurrent.atomic.AtomicInteger)2 Throwables (com.google.common.base.Throwables)1 ImmutableList (com.google.common.collect.ImmutableList)1 Lists (com.google.common.collect.Lists)1 ObjectQueue (com.squareup.tape.ObjectQueue)1 Validation (com.wavefront.agent.Validation)1 Utils (com.wavefront.agent.histogram.Utils)1 Granularity.fromMillis (com.wavefront.agent.histogram.Utils.Granularity.fromMillis)1