Search in sources :

Example 1 with Histogram

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

the class SLSCapacityScheduler method registerSchedulerMetrics.

private void registerSchedulerMetrics() {
    samplerLock.lock();
    try {
        // counters for scheduler operations
        schedulerAllocateCounter = metrics.counter("counter.scheduler.operation.allocate");
        schedulerHandleCounter = metrics.counter("counter.scheduler.operation.handle");
        schedulerHandleCounterMap = new HashMap<SchedulerEventType, Counter>();
        for (SchedulerEventType e : SchedulerEventType.values()) {
            Counter counter = metrics.counter("counter.scheduler.operation.handle." + e);
            schedulerHandleCounterMap.put(e, counter);
        }
        // timers for scheduler operations
        int timeWindowSize = conf.getInt(SLSConfiguration.METRICS_TIMER_WINDOW_SIZE, SLSConfiguration.METRICS_TIMER_WINDOW_SIZE_DEFAULT);
        schedulerAllocateTimer = new Timer(new SlidingWindowReservoir(timeWindowSize));
        schedulerHandleTimer = new Timer(new SlidingWindowReservoir(timeWindowSize));
        schedulerHandleTimerMap = new HashMap<SchedulerEventType, Timer>();
        for (SchedulerEventType e : SchedulerEventType.values()) {
            Timer timer = new Timer(new SlidingWindowReservoir(timeWindowSize));
            schedulerHandleTimerMap.put(e, timer);
        }
        // histogram for scheduler operations (Samplers)
        schedulerHistogramList = new ArrayList<Histogram>();
        histogramTimerMap = new HashMap<Histogram, Timer>();
        Histogram schedulerAllocateHistogram = new Histogram(new SlidingWindowReservoir(SAMPLING_SIZE));
        metrics.register("sampler.scheduler.operation.allocate.timecost", schedulerAllocateHistogram);
        schedulerHistogramList.add(schedulerAllocateHistogram);
        histogramTimerMap.put(schedulerAllocateHistogram, schedulerAllocateTimer);
        Histogram schedulerHandleHistogram = new Histogram(new SlidingWindowReservoir(SAMPLING_SIZE));
        metrics.register("sampler.scheduler.operation.handle.timecost", schedulerHandleHistogram);
        schedulerHistogramList.add(schedulerHandleHistogram);
        histogramTimerMap.put(schedulerHandleHistogram, schedulerHandleTimer);
        for (SchedulerEventType e : SchedulerEventType.values()) {
            Histogram histogram = new Histogram(new SlidingWindowReservoir(SAMPLING_SIZE));
            metrics.register("sampler.scheduler.operation.handle." + e + ".timecost", histogram);
            schedulerHistogramList.add(histogram);
            histogramTimerMap.put(histogram, schedulerHandleTimerMap.get(e));
        }
    } finally {
        samplerLock.unlock();
    }
}
Also used : SlidingWindowReservoir(com.codahale.metrics.SlidingWindowReservoir) Histogram(com.codahale.metrics.Histogram) Counter(com.codahale.metrics.Counter) Timer(com.codahale.metrics.Timer) SchedulerEventType(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType)

Example 2 with Histogram

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

the class ResourceSchedulerWrapper method registerSchedulerMetrics.

private void registerSchedulerMetrics() {
    samplerLock.lock();
    try {
        // counters for scheduler operations
        schedulerAllocateCounter = metrics.counter("counter.scheduler.operation.allocate");
        schedulerHandleCounter = metrics.counter("counter.scheduler.operation.handle");
        schedulerHandleCounterMap = new HashMap<SchedulerEventType, Counter>();
        for (SchedulerEventType e : SchedulerEventType.values()) {
            Counter counter = metrics.counter("counter.scheduler.operation.handle." + e);
            schedulerHandleCounterMap.put(e, counter);
        }
        // timers for scheduler operations
        int timeWindowSize = conf.getInt(SLSConfiguration.METRICS_TIMER_WINDOW_SIZE, SLSConfiguration.METRICS_TIMER_WINDOW_SIZE_DEFAULT);
        schedulerAllocateTimer = new Timer(new SlidingWindowReservoir(timeWindowSize));
        schedulerHandleTimer = new Timer(new SlidingWindowReservoir(timeWindowSize));
        schedulerHandleTimerMap = new HashMap<SchedulerEventType, Timer>();
        for (SchedulerEventType e : SchedulerEventType.values()) {
            Timer timer = new Timer(new SlidingWindowReservoir(timeWindowSize));
            schedulerHandleTimerMap.put(e, timer);
        }
        // histogram for scheduler operations (Samplers)
        schedulerHistogramList = new ArrayList<Histogram>();
        histogramTimerMap = new HashMap<Histogram, Timer>();
        Histogram schedulerAllocateHistogram = new Histogram(new SlidingWindowReservoir(SAMPLING_SIZE));
        metrics.register("sampler.scheduler.operation.allocate.timecost", schedulerAllocateHistogram);
        schedulerHistogramList.add(schedulerAllocateHistogram);
        histogramTimerMap.put(schedulerAllocateHistogram, schedulerAllocateTimer);
        Histogram schedulerHandleHistogram = new Histogram(new SlidingWindowReservoir(SAMPLING_SIZE));
        metrics.register("sampler.scheduler.operation.handle.timecost", schedulerHandleHistogram);
        schedulerHistogramList.add(schedulerHandleHistogram);
        histogramTimerMap.put(schedulerHandleHistogram, schedulerHandleTimer);
        for (SchedulerEventType e : SchedulerEventType.values()) {
            Histogram histogram = new Histogram(new SlidingWindowReservoir(SAMPLING_SIZE));
            metrics.register("sampler.scheduler.operation.handle." + e + ".timecost", histogram);
            schedulerHistogramList.add(histogram);
            histogramTimerMap.put(histogram, schedulerHandleTimerMap.get(e));
        }
    } finally {
        samplerLock.unlock();
    }
}
Also used : SlidingWindowReservoir(com.codahale.metrics.SlidingWindowReservoir) Histogram(com.codahale.metrics.Histogram) Counter(com.codahale.metrics.Counter) Timer(com.codahale.metrics.Timer) SchedulerEventType(org.apache.hadoop.yarn.server.resourcemanager.scheduler.event.SchedulerEventType)

Example 3 with Histogram

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

the class HistogramProducer method doProcess.

@Override
protected void doProcess(Exchange exchange, MetricsEndpoint endpoint, MetricRegistry registry, String metricsName) throws Exception {
    Message in = exchange.getIn();
    Histogram histogram = registry.histogram(metricsName);
    Long value = endpoint.getValue();
    Long finalValue = getLongHeader(in, HEADER_HISTOGRAM_VALUE, value);
    if (finalValue != null) {
        histogram.update(finalValue);
    } else {
        LOG.warn("Cannot update histogram \"{}\" with null value", metricsName);
    }
}
Also used : Histogram(com.codahale.metrics.Histogram) Message(org.apache.camel.Message)

Example 4 with Histogram

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

the class SearchesTest method fieldHistogramRecordsMetrics.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void fieldHistogramRecordsMetrics() throws Exception {
    final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC));
    HistogramResult h = searches.fieldHistogram("*", "n", Searches.DateHistogramInterval.MINUTE, null, range, false);
    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 : HistogramResult(org.graylog2.indexer.results.HistogramResult) Histogram(com.codahale.metrics.Histogram) Timer(com.codahale.metrics.Timer) AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) Test(org.junit.Test)

Example 5 with Histogram

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

the class SearchesTest method histogramRecordsMetrics.

@Test
@UsingDataSet(loadStrategy = LoadStrategyEnum.CLEAN_INSERT)
public void histogramRecordsMetrics() throws Exception {
    final AbsoluteRange range = AbsoluteRange.create(new DateTime(2015, 1, 1, 0, 0, DateTimeZone.UTC), new DateTime(2015, 1, 2, 0, 0, DateTimeZone.UTC));
    HistogramResult h = searches.histogram("*", Searches.DateHistogramInterval.MINUTE, range);
    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 : HistogramResult(org.graylog2.indexer.results.HistogramResult) Histogram(com.codahale.metrics.Histogram) Timer(com.codahale.metrics.Timer) AbsoluteRange(org.graylog2.plugin.indexer.searches.timeranges.AbsoluteRange) ZonedDateTime(java.time.ZonedDateTime) DateTime(org.joda.time.DateTime) UsingDataSet(com.lordofthejars.nosqlunit.annotation.UsingDataSet) 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