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