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());
}
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);
}
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);
}
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);
}
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());
}
Aggregations