Search in sources :

Example 11 with ReportPoint

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

the class PreprocessorRulesTest method testPointInRangeCorrectForTimeRanges.

@Test
public void testPointInRangeCorrectForTimeRanges() throws NoSuchMethodException, InvocationTargetException, IllegalAccessException {
    long millisPerYear = 31536000000L;
    long millisPerDay = 86400000L;
    long millisPerHour = 3600000L;
    AnnotatedPredicate<ReportPoint> pointInRange1year = new ReportPointTimestampInRangeFilter(8760, 24);
    // not in range if over a year ago
    ReportPoint rp = new ReportPoint("some metric", System.currentTimeMillis() - millisPerYear, 10L, "host", "table", new HashMap<>());
    Assert.assertFalse(pointInRange1year.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() - millisPerYear - 1);
    Assert.assertFalse(pointInRange1year.apply(rp));
    // in range if within a year ago
    rp.setTimestamp(System.currentTimeMillis() - (millisPerYear / 2));
    Assert.assertTrue(pointInRange1year.apply(rp));
    // in range for right now
    rp.setTimestamp(System.currentTimeMillis());
    Assert.assertTrue(pointInRange1year.apply(rp));
    // in range if within a day in the future
    rp.setTimestamp(System.currentTimeMillis() + millisPerDay - 1);
    Assert.assertTrue(pointInRange1year.apply(rp));
    // out of range for over a day in the future
    rp.setTimestamp(System.currentTimeMillis() + (millisPerDay * 2));
    Assert.assertFalse(pointInRange1year.apply(rp));
    // now test with 1 day limit
    AnnotatedPredicate<ReportPoint> pointInRange1day = new ReportPointTimestampInRangeFilter(24, 24);
    rp.setTimestamp(System.currentTimeMillis() - millisPerDay - 1);
    Assert.assertFalse(pointInRange1day.apply(rp));
    // in range if within 1 day ago
    rp.setTimestamp(System.currentTimeMillis() - (millisPerDay / 2));
    Assert.assertTrue(pointInRange1day.apply(rp));
    // in range for right now
    rp.setTimestamp(System.currentTimeMillis());
    Assert.assertTrue(pointInRange1day.apply(rp));
    // assert for future range within 12 hours
    AnnotatedPredicate<ReportPoint> pointInRange12hours = new ReportPointTimestampInRangeFilter(12, 12);
    rp.setTimestamp(System.currentTimeMillis() + (millisPerHour * 10));
    Assert.assertTrue(pointInRange12hours.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() - (millisPerHour * 10));
    Assert.assertTrue(pointInRange12hours.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() + (millisPerHour * 20));
    Assert.assertFalse(pointInRange12hours.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() - (millisPerHour * 20));
    Assert.assertFalse(pointInRange12hours.apply(rp));
    AnnotatedPredicate<ReportPoint> pointInRange10Days = new ReportPointTimestampInRangeFilter(240, 240);
    rp.setTimestamp(System.currentTimeMillis() + (millisPerDay * 9));
    Assert.assertTrue(pointInRange10Days.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() - (millisPerDay * 9));
    Assert.assertTrue(pointInRange10Days.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() + (millisPerDay * 20));
    Assert.assertFalse(pointInRange10Days.apply(rp));
    rp.setTimestamp(System.currentTimeMillis() - (millisPerDay * 20));
    Assert.assertFalse(pointInRange10Days.apply(rp));
}
Also used : ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 12 with ReportPoint

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

the class PreprocessorRulesTest method applyAllTransformers.

private String applyAllTransformers(String pointLine, String strPort) {
    String transformedPointLine = config.forPort(strPort).forPointLine().transform(pointLine);
    ReportPoint point = parsePointLine(transformedPointLine);
    config.forPort(strPort).forReportPoint().transform(point);
    return referencePointToStringImpl(point);
}
Also used : ReportPoint(wavefront.report.ReportPoint)

Example 13 with ReportPoint

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

the class PreprocessorRulesTest method parsePointLine.

private ReportPoint parsePointLine(String pointLine) {
    List<ReportPoint> points = Lists.newArrayListWithExpectedSize(1);
    decoder.decodeReportPoints(pointLine, points, "dummy");
    ReportPoint point = points.get(0);
    // convert annotations to TreeMap so the result is deterministic
    point.setAnnotations(new TreeMap<>(point.getAnnotations()));
    return point;
}
Also used : ReportPoint(wavefront.report.ReportPoint)

Example 14 with ReportPoint

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

the class PointHandlerDispatcherTest method setup.

@Before
public void setup() {
    timeMillis = new AtomicLong(0L);
    backingStore = new ConcurrentHashMap<>();
    in = new AccumulationCache(backingStore, 0, timeMillis::get);
    pointOut = new LinkedList<>();
    debugLineOut = new LinkedList<>();
    blockedOut = new LinkedList<>();
    digestA = new AgentDigest(COMPRESSION, 100L);
    digestB = new AgentDigest(COMPRESSION, 1000L);
    subject = new PointHandlerDispatcher(in, new PointHandler() {

        @Override
        public void reportPoint(ReportPoint point, String debugLine) {
            pointOut.add(point);
            debugLineOut.add(debugLine);
        }

        @Override
        public void reportPoints(List<ReportPoint> points) {
            pointOut.addAll(points);
        }

        @Override
        public void handleBlockedPoint(String pointLine) {
            blockedOut.add(pointLine);
        }
    }, timeMillis::get, null);
}
Also used : AtomicLong(java.util.concurrent.atomic.AtomicLong) AccumulationCache(com.wavefront.agent.histogram.accumulator.AccumulationCache) AgentDigest(com.tdunning.math.stats.AgentDigest) PointHandler(com.wavefront.agent.PointHandler) List(java.util.List) LinkedList(java.util.LinkedList) ReportPoint(wavefront.report.ReportPoint) Before(org.junit.Before)

Example 15 with ReportPoint

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

the class TapeDispatcherTest method testOnlyRipeEntriesAreDispatched.

@Test
public void testOnlyRipeEntriesAreDispatched() {
    in.put(keyA, digestA);
    in.put(keyB, digestB);
    timeMillis.set(101L);
    subject.run();
    assertThat(out.size()).isEqualTo(1);
    assertThat(in).containsEntry(keyB, digestB);
    ReportPoint point = out.peek();
    TestUtils.testKeyPointMatch(keyA, point);
}
Also used : 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