Search in sources :

Example 36 with Snapshot

use of com.codahale.metrics.Snapshot in project java by wavefrontHQ.

the class WavefrontReporter method reportTimer.

private void reportTimer(String name, Timer timer) throws IOException {
    final Snapshot snapshot = timer.getSnapshot();
    final long time = clock.getTime() / 1000;
    wavefront.send(prefixAndSanitize(name, "max"), convertDuration(snapshot.getMax()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "mean"), convertDuration(snapshot.getMean()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "min"), convertDuration(snapshot.getMin()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "stddev"), convertDuration(snapshot.getStdDev()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p50"), convertDuration(snapshot.getMedian()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p75"), convertDuration(snapshot.get75thPercentile()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p95"), convertDuration(snapshot.get95thPercentile()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p98"), convertDuration(snapshot.get98thPercentile()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p99"), convertDuration(snapshot.get99thPercentile()), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p999"), convertDuration(snapshot.get999thPercentile()), time, source, pointTags);
    reportMetered(name, timer);
}
Also used : Snapshot(com.codahale.metrics.Snapshot)

Example 37 with Snapshot

use of com.codahale.metrics.Snapshot in project java by wavefrontHQ.

the class WavefrontReporter method reportHistogram.

private void reportHistogram(String name, Histogram histogram) throws IOException {
    final Snapshot snapshot = histogram.getSnapshot();
    final long time = clock.getTime() / 1000;
    wavefront.send(prefixAndSanitize(name, "count"), histogram.getCount(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "max"), snapshot.getMax(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "mean"), snapshot.getMean(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "min"), snapshot.getMin(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "stddev"), snapshot.getStdDev(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p50"), snapshot.getMedian(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p75"), snapshot.get75thPercentile(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p95"), snapshot.get95thPercentile(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p98"), snapshot.get98thPercentile(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p99"), snapshot.get99thPercentile(), time, source, pointTags);
    wavefront.send(prefixAndSanitize(name, "p999"), snapshot.get999thPercentile(), time, source, pointTags);
}
Also used : Snapshot(com.codahale.metrics.Snapshot)

Example 38 with Snapshot

use of com.codahale.metrics.Snapshot in project helix by apache.

the class HistogramDynamicMetric method getAttributeValue.

@Override
public Number getAttributeValue(String attributeName) {
    if (!_attributeNameSet.contains(attributeName)) {
        return null;
    }
    String[] attributeNameParts = attributeName.split("\\.");
    if (attributeNameParts.length == 2) {
        try {
            SnapshotAttribute snapshotAttribute = SnapshotAttribute.valueOf(attributeNameParts[1]);
            Method getMethod = Snapshot.class.getMethod(snapshotAttribute._getMethodName);
            Snapshot snapshot = getMetricObject().getSnapshot();
            if (snapshot != null) {
                return (Number) getMethod.invoke(snapshot);
            }
        } catch (Exception ex) {
            _logger.error(String.format("Failed to get Snapshot value for attribute: %s", attributeName), ex);
        }
    } else {
        _logger.error(String.format("Invalid attribute name format: %s", attributeName));
    }
    return null;
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Method(java.lang.reflect.Method)

Example 39 with Snapshot

use of com.codahale.metrics.Snapshot in project cassandra by apache.

the class BatchMetricsTableTest method testSelectAll.

@Test
public void testSelectAll() throws Throwable {
    BatchMetrics metrics = BatchStatement.metrics;
    for (int i = 0; i < 10; i++) {
        metrics.partitionsPerLoggedBatch.update(i);
        metrics.partitionsPerUnloggedBatch.update(i + 10);
        metrics.partitionsPerCounterBatch.update(i * 10);
    }
    ResultSet result = executeNet(format("SELECT * FROM %s.batch_metrics", KS_NAME));
    assertEquals(5, result.getColumnDefinitions().size());
    AtomicInteger rowCount = new AtomicInteger(0);
    result.forEach(r -> {
        Snapshot snapshot = getExpectedHistogram(metrics, r.getString("name")).getSnapshot();
        assertEquals(snapshot.getMedian(), r.getDouble("p50th"), 0.0);
        assertEquals(snapshot.get99thPercentile(), r.getDouble("p99th"), 0.0);
        rowCount.addAndGet(1);
    });
    assertEquals(3, rowCount.get());
}
Also used : Snapshot(com.codahale.metrics.Snapshot) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) BatchMetrics(org.apache.cassandra.metrics.BatchMetrics) ResultSet(com.datastax.driver.core.ResultSet) Test(org.junit.Test)

Example 40 with Snapshot

use of com.codahale.metrics.Snapshot in project cassandra by apache.

the class DecayingEstimatedHistogramReservoirTest method testMinMax.

@Test
public void testMinMax() {
    DecayingEstimatedHistogramReservoir histogram = new DecayingEstimatedHistogramReservoir();
    histogram.update(16);
    Snapshot snapshot = histogram.getSnapshot();
    assertEquals(15, snapshot.getMin());
    assertEquals(17, snapshot.getMax());
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Test(org.junit.Test)

Aggregations

Snapshot (com.codahale.metrics.Snapshot)57 Test (org.junit.Test)13 Histogram (com.codahale.metrics.Histogram)11 Timer (com.codahale.metrics.Timer)11 Map (java.util.Map)6 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)4 ConcurrentMap (java.util.concurrent.ConcurrentMap)4 HashMap (java.util.HashMap)3 SortedMap (java.util.SortedMap)3 MetricSnapshot (backtype.storm.generated.MetricSnapshot)2 JAverageSnapshot (com.alibaba.jstorm.common.metric.codahale.JAverageSnapshot)2 Counter (com.codahale.metrics.Counter)2 Gauge (com.codahale.metrics.Gauge)2 Meter (com.codahale.metrics.Meter)2 ObjectMapper (com.fasterxml.jackson.databind.ObjectMapper)2 InOrder (org.mockito.InOrder)2 SlidingWindowReservoir (com.codahale.metrics.SlidingWindowReservoir)1 UniformReservoir (com.codahale.metrics.UniformReservoir)1 ResultSet (com.datastax.driver.core.ResultSet)1 ListenableFuture (com.google.common.util.concurrent.ListenableFuture)1