Search in sources :

Example 41 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 42 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 43 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)

Example 44 with Snapshot

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

the class SamzaHistogram method updateGaugeValues.

public void updateGaugeValues(double percentile) {
    Snapshot values = histogram.getSnapshot();
    gauges.get(percentile).set(values.getValue(percentile / 100));
}
Also used : Snapshot(com.codahale.metrics.Snapshot)

Example 45 with Snapshot

use of com.codahale.metrics.Snapshot in project jstorm by alibaba.

the class TopologyMetricContext method mergeHistograms.

/**
 * histograms are sampled, but we just update points
 */
public void mergeHistograms(MetricInfo metricInfo, String meta, Map<Integer, MetricSnapshot> data, Map<String, Integer> metaCounters, Map<String, Map<Integer, Histogram>> histograms) {
    Map<Integer, MetricSnapshot> existing = metricInfo.get_metrics().get(meta);
    if (existing == null) {
        metricInfo.put_to_metrics(meta, data);
        Map<Integer, Histogram> histogramMap = new HashMap<>();
        for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
            Histogram histogram = MetricUtils.metricSnapshot2Histogram(dataEntry.getValue());
            histogramMap.put(dataEntry.getKey(), histogram);
        }
        histograms.put(meta, histogramMap);
    } else {
        for (Map.Entry<Integer, MetricSnapshot> dataEntry : data.entrySet()) {
            Integer win = dataEntry.getKey();
            MetricSnapshot snapshot = dataEntry.getValue();
            MetricSnapshot old = existing.get(win);
            if (old == null) {
                existing.put(win, snapshot);
                histograms.get(meta).put(win, MetricUtils.metricSnapshot2Histogram(snapshot));
            } else {
                if (snapshot.get_ts() >= old.get_ts()) {
                    old.set_ts(snapshot.get_ts());
                    Histogram histogram = histograms.get(meta).get(win);
                    Snapshot updateSnapshot = histogram.getSnapshot();
                    if (updateSnapshot instanceof JAverageSnapshot) {
                        sumMetricSnapshot(((JAverageSnapshot) updateSnapshot).getMetricSnapshot(), snapshot);
                    } else {
                        // update points
                        MetricUtils.updateHistogramPoints(histogram, snapshot.get_points(), snapshot.get_pointSize());
                    }
                }
            }
        }
    }
    updateMetricCounters(meta, metaCounters);
}
Also used : MetricSnapshot(backtype.storm.generated.MetricSnapshot) Snapshot(com.codahale.metrics.Snapshot) JAverageSnapshot(com.alibaba.jstorm.common.metric.codahale.JAverageSnapshot) Histogram(com.codahale.metrics.Histogram) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) JAverageSnapshot(com.alibaba.jstorm.common.metric.codahale.JAverageSnapshot) MetricSnapshot(backtype.storm.generated.MetricSnapshot) ConcurrentHashMap(java.util.concurrent.ConcurrentHashMap) ConcurrentMap(java.util.concurrent.ConcurrentMap)

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