use of com.yammer.metrics.core.Gauge in project java by wavefrontHQ.
the class WavefrontYammerMetricsReporterTest method testPlainGauge.
@Test(timeout = 1000)
public void testPlainGauge() throws Exception {
Gauge gauge = metricsRegistry.newGauge(WavefrontYammerMetricsReporterTest.class, "mygauge", new Gauge<Double>() {
@Override
public Double value() {
return 13.0;
}
});
wavefrontYammerMetricsReporter.run();
assertThat(receiveFromSocket(1, fromMetrics), contains(equalTo("\"mygauge\" 13.0 1485224035")));
}
use of com.yammer.metrics.core.Gauge in project java by wavefrontHQ.
the class QueueController method run.
@Override
public void run() {
// 1. grab current queue sizes (tasks count) and report to EntityProperties
int backlog = processorTasks.stream().mapToInt(x -> x.getTaskQueue().size()).sum();
queueSize.set(backlog);
if (backlogSizeSink != null) {
backlogSizeSink.accept(backlog);
}
// 2. grab queue sizes (points/etc count)
Long totalWeight = 0L;
for (QueueProcessor<T> task : processorTasks) {
TaskQueue<T> taskQueue = task.getTaskQueue();
// noinspection ConstantConditions
totalWeight = taskQueue.weight() == null ? null : taskQueue.weight() + totalWeight;
if (totalWeight == null)
break;
}
if (totalWeight != null) {
if (currentWeight == null) {
currentWeight = new AtomicLong();
Metrics.newGauge(new TaggedMetricName("buffer", handlerKey.getEntityType() + "-count", "port", handlerKey.getHandle()), new Gauge<Long>() {
@Override
public Long value() {
return currentWeight.get();
}
});
}
currentWeight.set(totalWeight);
}
// 3. adjust timing
adjustTimingFactors(processorTasks);
// 4. print stats when there's backlog
if (backlog > 0) {
printQueueStats();
} else if (outputQueueingStats) {
outputQueueingStats = false;
logger.info("[" + handlerKey.getHandle() + "] " + handlerKey.getEntityType() + " backlog has been cleared!");
}
}
Aggregations