Search in sources :

Example 1 with Metered

use of com.yammer.metrics.core.Metered in project Dempsy by Dempsy.

the class TestStatsCollectorCoda method getStatValue.

@SuppressWarnings("unchecked")
long getStatValue(StatsCollectorCoda statCollector, String metricName) {
    MetricsRegistry metricReg = statCollector.getMetricsRegistry();
    Object meter = metricReg.allMetrics().get(statCollector.createName(metricName));
    if (com.yammer.metrics.core.Gauge.class.isAssignableFrom(meter.getClass()))
        return ((com.yammer.metrics.core.Gauge<Long>) metricReg.allMetrics().get(statCollector.createName(metricName))).value();
    else if (com.yammer.metrics.core.Histogram.class.isAssignableFrom(meter.getClass())) {
        final com.yammer.metrics.core.Histogram h = (com.yammer.metrics.core.Histogram) metricReg.allMetrics().get(statCollector.createName(metricName));
        return Math.round(h.count() * h.mean());
    } else
        return ((Metered) metricReg.allMetrics().get(statCollector.createName(metricName))).count();
}
Also used : MetricsRegistry(com.yammer.metrics.core.MetricsRegistry) Metered(com.yammer.metrics.core.Metered) AtomicLong(java.util.concurrent.atomic.AtomicLong)

Aggregations

Metered (com.yammer.metrics.core.Metered)1 MetricsRegistry (com.yammer.metrics.core.MetricsRegistry)1 AtomicLong (java.util.concurrent.atomic.AtomicLong)1