Search in sources :

Example 31 with ReportPoint

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

the class GraphiteDecoderTest method testFormatWithNoTagsAndTimestamp.

@Test
public void testFormatWithNoTagsAndTimestamp() throws Exception {
    GraphiteDecoder decoder = new GraphiteDecoder("localhost", emptyCustomSourceTags);
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("tsdb.vehicle.charge.battery_level 93 1234567890.246", out);
    ReportPoint point = out.get(0);
    assertEquals("tsdb", point.getTable());
    assertEquals("vehicle.charge.battery_level", point.getMetric());
    assertEquals(93.0, point.getValue());
    assertEquals(1234567890246L, point.getTimestamp().longValue());
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 32 with ReportPoint

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

the class GraphiteDecoderTest method testDecodeWithNoCustomer.

@Test
public void testDecodeWithNoCustomer() throws Exception {
    GraphiteDecoder decoder = new GraphiteDecoder(emptyCustomSourceTags);
    List<ReportPoint> out = Lists.newArrayList();
    decoder.decodeReportPoints("vehicle.charge.battery_level 93 host=vehicle_2554", out, "customer");
    ReportPoint point = out.get(0);
    assertEquals("customer", point.getTable());
    assertEquals("vehicle.charge.battery_level", point.getMetric());
    assertEquals(93.0, point.getValue());
    assertEquals("vehicle_2554", point.getHost());
}
Also used : ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 33 with ReportPoint

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

the class GraphiteDecoderTest method testFQDNasSource.

@Test
public void testFQDNasSource() throws Exception {
    List<String> customSourceTags = new ArrayList<String>();
    customSourceTags.add("fqdn");
    customSourceTags.add("hostname");
    GraphiteDecoder decoder = new GraphiteDecoder(customSourceTags);
    List<ReportPoint> out = Lists.newArrayList();
    decoder.decodeReportPoints("test 1 hostname=machine fqdn=machine.company.com", out, "customer");
    ReportPoint point = out.get(0);
    assertEquals("customer", point.getTable());
    assertEquals("test", point.getMetric());
    assertEquals("machine.company.com", point.getHost());
    assertEquals("machine.company.com", point.getAnnotations().get("fqdn"));
    assertEquals("machine", point.getAnnotations().get("hostname"));
    assertEquals(1.0, point.getValue());
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 34 with ReportPoint

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

the class GraphiteDecoderTest method testFormat.

@Test
public void testFormat() throws Exception {
    GraphiteDecoder decoder = new GraphiteDecoder("localhost", emptyCustomSourceTags);
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("tsdb.vehicle.charge.battery_level 93 host=vehicle_2554", out);
    ReportPoint point = out.get(0);
    assertEquals("tsdb", point.getTable());
    assertEquals("vehicle.charge.battery_level", point.getMetric());
    assertEquals(93.0, point.getValue());
    assertEquals("vehicle_2554", point.getHost());
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 35 with ReportPoint

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

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