use of com.codahale.metrics.Counter 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();
}
}
use of com.codahale.metrics.Counter 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();
}
}
use of com.codahale.metrics.Counter in project hive by apache.
the class TestMetricsQueryLifeTimeHook method testCompilationQueryMetric.
@Test
public void testCompilationQueryMetric() {
Timer timer = metricRegistry.getTimers().get(MetricsConstant.HS2_COMPILING_QUERIES);
Counter counter = metricRegistry.getCounters().get(MetricsConstant.ACTIVE_CALLS + MetricsConstant.HS2_COMPILING_QUERIES);
assertThat(timer, nullValue());
assertThat(counter, nullValue());
hook.beforeCompile(ctx);
timer = metricRegistry.getTimers().get(MetricsConstant.HS2_COMPILING_QUERIES);
counter = metricRegistry.getCounters().get(MetricsConstant.ACTIVE_CALLS + MetricsConstant.HS2_COMPILING_QUERIES);
assertThat(timer.getCount(), equalTo(0l));
assertThat(counter.getCount(), equalTo(1l));
hook.afterCompile(ctx, false);
timer = metricRegistry.getTimers().get(MetricsConstant.HS2_COMPILING_QUERIES);
counter = metricRegistry.getCounters().get(MetricsConstant.ACTIVE_CALLS + MetricsConstant.HS2_COMPILING_QUERIES);
assertThat(timer.getCount(), equalTo(1l));
assertThat(counter.getCount(), equalTo(0l));
}
use of com.codahale.metrics.Counter in project newts by OpenNMS.
the class NewtsReporter method report.
@Override
@SuppressWarnings("rawtypes")
public void report(SortedMap<String, Gauge> gauges, SortedMap<String, Counter> counters, SortedMap<String, Histogram> histograms, SortedMap<String, Meter> meters, SortedMap<String, Timer> timers) {
Timestamp timestamp = Timestamp.fromEpochMillis(clock.getTime());
List<Sample> samples = Lists.newArrayList();
for (Map.Entry<String, Gauge> entry : gauges.entrySet()) {
reportGauge(samples, timestamp, entry.getKey(), entry.getValue());
}
for (Map.Entry<String, Counter> entry : counters.entrySet()) {
reportCounter(samples, timestamp, entry.getKey(), entry.getValue());
}
for (Map.Entry<String, Histogram> entry : histograms.entrySet()) {
reportHistogram(samples, timestamp, entry.getKey(), entry.getValue());
}
for (Map.Entry<String, Meter> entry : meters.entrySet()) {
reportMeter(samples, timestamp, entry.getKey(), entry.getValue());
}
for (Map.Entry<String, Timer> entry : timers.entrySet()) {
reportTimer(samples, timestamp, entry.getKey(), entry.getValue());
}
this.repository.insert(samples);
}
use of com.codahale.metrics.Counter in project ninja by ninjaframework.
the class CountedInterceptor method invoke.
@Override
public Object invoke(MethodInvocation invocation) throws Throwable {
Counted counted = invocation.getMethod().getAnnotation(Counted.class);
String counterName = counted.value();
if (counterName.isEmpty()) {
counterName = MetricRegistry.name(invocation.getThis().getClass().getSuperclass(), invocation.getMethod().getName());
}
Counter counter = metricsServiceProvider.get().getMetricRegistry().counter(counterName);
counter.inc();
try {
return invocation.proceed();
} finally {
if (counted.active()) {
counter.dec();
}
}
}
Aggregations