Search in sources :

Example 41 with ReportPoint

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

the class OpenTSDBDecoderTest method testOpenTSDBCharacters.

@Test
public void testOpenTSDBCharacters() {
    List<String> customSourceTags = new ArrayList<>();
    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-test/GOOD some_tag=/vehicle_2554-test/BAD", 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-test/GOOD", point.getHost());
    assertEquals("/vehicle_2554-test/BAD", point.getAnnotations().get("some_tag"));
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) Test(org.junit.Test)

Example 42 with ReportPoint

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

the class GraphiteDecoder method decodeReportPoints.

@Override
public void decodeReportPoints(String msg, List<ReportPoint> out) {
    List<ReportPoint> output = Lists.newArrayList();
    decodeReportPoints(msg, output, "dummy");
    if (!output.isEmpty()) {
        for (ReportPoint rp : output) {
            String metricName = rp.getMetric();
            List<String> metricParts = Lists.newArrayList(Splitter.on(".").split(metricName));
            if (metricParts.size() <= 1) {
                throw new RuntimeException("Metric name does not contain a customer id: " + metricName);
            }
            String customerId = metricParts.get(0);
            if (CUSTOMERID.matcher(customerId).matches()) {
                metricName = Joiner.on(".").join(metricParts.subList(1, metricParts.size()));
            }
            out.add(ReportPoint.newBuilder(rp).setMetric(metricName).setTable(customerId).build());
        }
    }
}
Also used : ReportPoint(wavefront.report.ReportPoint)

Example 43 with ReportPoint

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

the class TapeDispatcher method run.

@Override
public void run() {
    for (Utils.HistogramKey key : digests.keySet()) {
        digests.compute(key, (k, v) -> {
            if (v == null) {
                return null;
            }
            // Remove and add to shipping queue
            if (v.getDispatchTimeMillis() < clock.millisSinceEpoch()) {
                try {
                    ReportPoint out = Utils.pointFromKeyAndDigest(k, v);
                    output.add(out);
                    dispatchCounter.inc();
                } catch (Exception e) {
                    logger.log(Level.SEVERE, "Failed dispatching entry " + k, e);
                }
                return null;
            }
            return v;
        });
    }
}
Also used : ReportPoint(wavefront.report.ReportPoint)

Example 44 with ReportPoint

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

the class GraphiteDecoderTest method testBenchmark.

@Ignore
@Test
public void testBenchmark() throws Exception {
    List<String> customSourceTags = new ArrayList<String>();
    customSourceTags.add("fqdn");
    customSourceTags.add("hostname");
    customSourceTags.add("highcardinalitytag1");
    customSourceTags.add("highcardinalitytag2");
    customSourceTags.add("highcardinalitytag3");
    customSourceTags.add("highcardinalitytag4");
    customSourceTags.add("highcardinalitytag5");
    GraphiteDecoder decoder = new GraphiteDecoder("localhost", emptyCustomSourceTags);
    int ITERATIONS = 1000000;
    for (int i = 0; i < ITERATIONS / 1000; i++) {
        List<ReportPoint> out = new ArrayList<>();
        decoder.decodeReportPoints("tsdb.vehicle.charge.battery_level 93 123456 highcardinalitytag5=vehicle_2554", out);
    }
    long start = System.currentTimeMillis();
    for (int i = 0; i < ITERATIONS; i++) {
        List<ReportPoint> out = new ArrayList<>();
        decoder.decodeReportPoints("tsdb.vehicle.charge.battery_level 93 123456 highcardinalitytag5=vehicle_2554", out);
    }
    double end = System.currentTimeMillis();
    System.out.println(ITERATIONS / ((end - start) / 1000) + " DPS");
}
Also used : ArrayList(java.util.ArrayList) ReportPoint(wavefront.report.ReportPoint) ReportPoint(wavefront.report.ReportPoint) Ignore(org.junit.Ignore) Test(org.junit.Test)

Example 45 with ReportPoint

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

the class GraphiteDecoderTest method testTagVWithDigitAtBeginning.

@Test
public void testTagVWithDigitAtBeginning() throws Exception {
    GraphiteDecoder decoder = new GraphiteDecoder("localhost", emptyCustomSourceTags);
    List<ReportPoint> out = new ArrayList<>();
    decoder.decodeReportPoints("tsdb.vehicle.charge.battery_level 93 host=vehicle_2554 version=1_0", 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());
    assertEquals("1_0", point.getAnnotations().get("version"));
}
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