Search in sources :

Example 6 with ReportPoint

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

the class DroppingSender method run.

@Override
public void run() {
    ReportPoint current;
    while ((current = input.peek()) != null) {
        input.remove();
        logger.log(Level.INFO, "Sent " + current);
    }
    try {
        Thread.sleep(100L + (long) (r.nextDouble() * 400D));
    } catch (InterruptedException e) {
    // eat
    }
}
Also used : ReportPoint(wavefront.report.ReportPoint)

Example 7 with ReportPoint

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

the class PointHandlerDispatcher method run.

@Override
public void run() {
    try {
        accumulatorSize.update(digests.size());
        AtomicInteger dispatchedCount = new AtomicInteger(0);
        long startNanos = nanoTime();
        Iterator<Utils.HistogramKey> index = digests.getRipeDigestsIterator(this.clock);
        while (index.hasNext()) {
            digests.compute(index.next(), (k, v) -> {
                if (v == null) {
                    index.remove();
                    return null;
                }
                try {
                    ReportPoint out = Utils.pointFromKeyAndDigest(k, v);
                    output.reportPoint(out, k.toString());
                    dispatchCounter.inc();
                } catch (Exception e) {
                    dispatchErrorCounter.inc();
                    logger.log(Level.SEVERE, "Failed dispatching entry " + k, e);
                }
                dispatchLagMillis.update(System.currentTimeMillis() - v.getDispatchTimeMillis());
                index.remove();
                dispatchedCount.incrementAndGet();
                return null;
            });
            if (dispatchLimit != null && dispatchedCount.get() >= dispatchLimit)
                break;
        }
        dispatchProcessTime.update(nanoTime() - startNanos);
    } catch (Exception e) {
        logger.log(Level.SEVERE, "PointHandlerDispatcher error", e);
    }
}
Also used : AtomicInteger(java.util.concurrent.atomic.AtomicInteger) ReportPoint(wavefront.report.ReportPoint)

Example 8 with ReportPoint

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

the class Utils method makeKey.

/**
 * Generates a {@link HistogramKey} according a prototype {@link ReportPoint} and {@link Granularity}.
 */
public static HistogramKey makeKey(ReportPoint point, Granularity granularity) {
    Preconditions.checkNotNull(point);
    Preconditions.checkNotNull(granularity);
    String[] annotations = null;
    if (point.getAnnotations() != null) {
        List<Map.Entry<String, String>> keyOrderedTags = point.getAnnotations().entrySet().stream().sorted(Comparator.comparing(Map.Entry::getKey)).collect(Collectors.toList());
        annotations = new String[keyOrderedTags.size() * 2];
        for (int i = 0; i < keyOrderedTags.size(); ++i) {
            annotations[2 * i] = keyOrderedTags.get(i).getKey();
            annotations[(2 * i) + 1] = keyOrderedTags.get(i).getValue();
        }
    }
    return new HistogramKey((byte) granularity.ordinal(), granularity.getBinId(point.getTimestamp()), point.getMetric(), point.getHost(), annotations);
}
Also used : ReportPoint(wavefront.report.ReportPoint)

Example 9 with ReportPoint

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

the class ReportPointReplaceRegexTransformer method replaceString.

private String replaceString(@NotNull ReportPoint reportPoint, String content) {
    Matcher patternMatcher;
    patternMatcher = compiledSearchPattern.matcher(content);
    if (!patternMatcher.find()) {
        return content;
    }
    ruleMetrics.incrementRuleAppliedCounter();
    String replacement = PreprocessorUtil.expandPlaceholders(patternReplace, reportPoint);
    int currentIteration = 0;
    while (currentIteration < maxIterations) {
        content = patternMatcher.replaceAll(replacement);
        patternMatcher = compiledSearchPattern.matcher(content);
        if (!patternMatcher.find()) {
            break;
        }
        currentIteration++;
    }
    return content;
}
Also used : Matcher(java.util.regex.Matcher) ReportPoint(wavefront.report.ReportPoint)

Example 10 with ReportPoint

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

the class PointMatchers method almostMatches.

public static Matcher<ReportPoint> almostMatches(double value, String metricName, Map<String, String> tags) {
    return new BaseMatcher<ReportPoint>() {

        @Override
        public boolean matches(Object o) {
            ReportPoint me = (ReportPoint) o;
            double given = (double) me.getValue();
            return Math.abs(value - given) < 0.001 && me.getMetric().equals(metricName) && mapsEqual(me.getAnnotations(), tags);
        }

        @Override
        public void describeTo(Description description) {
            description.appendText("Value should approximately equal " + value + " and have metric name " + metricName + " and tags " + mapToString(tags));
        }
    };
}
Also used : Description(org.hamcrest.Description) BaseMatcher(org.hamcrest.BaseMatcher) ReportPoint(wavefront.report.ReportPoint)

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