Search in sources :

Example 46 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 47 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)

Example 48 with Snapshot

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

the class Executor method processTimers.

private void processTimers(int taskId, List<IMetricsConsumer.DataPoint> dataPoints) {
    Map<String, Timer> timers = workerData.getMetricRegistry().getTaskTimers(taskId);
    for (Map.Entry<String, Timer> entry : timers.entrySet()) {
        Snapshot snapshot = entry.getValue().getSnapshot();
        addSnapshotDatapoints(entry.getKey(), snapshot, dataPoints);
        addMeteredDatapoints(entry.getKey(), entry.getValue(), dataPoints);
    }
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Timer(com.codahale.metrics.Timer) StormTimer(org.apache.storm.StormTimer) Map(java.util.Map) HashMap(java.util.HashMap)

Example 49 with Snapshot

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

the class Executor method processHistograms.

private void processHistograms(int taskId, List<IMetricsConsumer.DataPoint> dataPoints) {
    Map<String, Histogram> histograms = workerData.getMetricRegistry().getTaskHistograms(taskId);
    for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
        Snapshot snapshot = entry.getValue().getSnapshot();
        addSnapshotDatapoints(entry.getKey(), snapshot, dataPoints);
        IMetricsConsumer.DataPoint dataPoint = new IMetricsConsumer.DataPoint(entry.getKey() + ".count", entry.getValue().getCount());
        dataPoints.add(dataPoint);
    }
}
Also used : Snapshot(com.codahale.metrics.Snapshot) Histogram(com.codahale.metrics.Histogram) IMetricsConsumer(org.apache.storm.metric.api.IMetricsConsumer) Map(java.util.Map) HashMap(java.util.HashMap)

Example 50 with Snapshot

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

the class SamzaHistogram method update.

synchronized void update(long value) {
    histogram.update(value);
    Snapshot values = histogram.getSnapshot();
    percentiles.forEach(x -> gauges.get(x).set(values.getValue(x / 100)));
}
Also used : Snapshot(com.codahale.metrics.Snapshot)

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