Search in sources :

Example 91 with Histogram

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

the class ClientMetrics method init.

public synchronized void init(Collection<Server> servers) {
    if (initialized)
        return;
    this.servers = servers;
    // deprecated the lower-cased initial letter metric names in 4.0
    registerGauge("ConnectedNativeClients", "connectedNativeClients", this::countConnectedClients);
    registerGauge("ConnectedNativeClientsByUser", "connectedNativeClientsByUser", this::countConnectedClientsByUser);
    registerGauge("Connections", "connections", this::connectedClients);
    registerGauge("ClientsByProtocolVersion", "clientsByProtocolVersion", this::recentClientStats);
    registerGauge("RequestsSize", ClientResourceLimits::getCurrentGlobalUsage);
    Reservoir ipUsageReservoir = ClientResourceLimits.ipUsageReservoir();
    Metrics.register(factory.createMetricName("RequestsSizeByIpDistribution"), new Histogram(ipUsageReservoir) {

        public long getCount() {
            return ipUsageReservoir.size();
        }
    });
    authSuccess = registerMeter("AuthSuccess");
    authFailure = registerMeter("AuthFailure");
    pausedConnections = new AtomicInteger();
    pausedConnectionsGauge = registerGauge("PausedConnections", pausedConnections::get);
    requestDiscarded = registerMeter("RequestDiscarded");
    protocolException = registerMeter("ProtocolException");
    unknownException = registerMeter("UnknownException");
    initialized = true;
}
Also used : Histogram(com.codahale.metrics.Histogram) AtomicInteger(java.util.concurrent.atomic.AtomicInteger) Reservoir(com.codahale.metrics.Reservoir)

Example 92 with Histogram

use of com.codahale.metrics.Histogram 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 93 with Histogram

use of com.codahale.metrics.Histogram 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)

Example 94 with Histogram

use of com.codahale.metrics.Histogram in project graylog2-server by Graylog2.

the class MetricUtilsTest method mapSupportsHistogram.

@Test
public void mapSupportsHistogram() {
    final Histogram histogram = new Histogram(new UniformReservoir());
    histogram.update(23);
    final Map<String, Object> map = MetricUtils.map("metric", histogram);
    assertThat(map).containsEntry("type", "histogram").extracting("metric").extracting("count").containsExactly(1L);
}
Also used : Histogram(com.codahale.metrics.Histogram) UniformReservoir(com.codahale.metrics.UniformReservoir) Test(org.junit.Test)

Example 95 with Histogram

use of com.codahale.metrics.Histogram in project graylog2-server by Graylog2.

the class SearchesIT method fieldStatsRecordsMetrics.

@Test
public void fieldStatsRecordsMetrics() throws Exception {
    importFixture("org/graylog2/indexer/searches/SearchesIT.json");
    FieldStatsResult result = searches.fieldStats("n", "*", AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC)));
    assertThat(metricRegistry.getTimers()).containsKey(REQUEST_TIMER_NAME);
    assertThat(metricRegistry.getHistograms()).containsKey(RANGES_HISTOGRAM_NAME);
    Timer timer = metricRegistry.timer(REQUEST_TIMER_NAME);
    assertThat(timer.getCount()).isEqualTo(1L);
    Histogram histogram = metricRegistry.histogram(RANGES_HISTOGRAM_NAME);
    assertThat(histogram.getCount()).isEqualTo(1L);
    assertThat(histogram.getSnapshot().getValues()).containsExactly(86400L);
}
Also used : FieldStatsResult(org.graylog2.indexer.results.FieldStatsResult) Histogram(com.codahale.metrics.Histogram) Timer(com.codahale.metrics.Timer) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) ElasticsearchBaseTest(org.graylog.testing.elasticsearch.ElasticsearchBaseTest) Test(org.junit.Test)

Aggregations

Histogram (com.codahale.metrics.Histogram)97 Test (org.junit.Test)39 Timer (com.codahale.metrics.Timer)34 Counter (com.codahale.metrics.Counter)30 Meter (com.codahale.metrics.Meter)29 Gauge (com.codahale.metrics.Gauge)17 Snapshot (com.codahale.metrics.Snapshot)12 Map (java.util.Map)11 Test (org.testng.annotations.Test)11 MetricRegistry (com.codahale.metrics.MetricRegistry)9 DataProvider (com.tngtech.java.junit.dataprovider.DataProvider)8 IOException (java.io.IOException)8 HashMap (java.util.HashMap)8 Metric (com.codahale.metrics.Metric)6 Reservoir (com.codahale.metrics.Reservoir)6 ZonedDateTime (java.time.ZonedDateTime)6 Properties (java.util.Properties)6 SortedMap (java.util.SortedMap)6 DateTime (org.joda.time.DateTime)6 UniformReservoir (com.codahale.metrics.UniformReservoir)5