Refine search
@Override public void run() { running.inc(); final Timer.Context context = duration.time(); try { command.run(); } finally { final long elapsed = context.stop(); running.dec(); completed.mark(); if (elapsed > periodInNanos) { scheduledOverrun.inc(); } percentOfPeriod.update((100L * elapsed) / periodInNanos); } } }
private void printHistogram(Histogram histogram) { Snapshot snapshot = histogram.getSnapshot(); output.printf(locale, " min = %d%n", snapshot.getMin()); output.printf(locale, " max = %d%n", snapshot.getMax()); output.printf(locale, " mean = %2.2f%n", snapshot.getMean()); output.printf(locale, " stddev = %2.2f%n", snapshot.getStdDev()); output.printf(locale, " median = %2.2f%n", snapshot.getMedian()); output.printf(locale, " 75%% <= %2.2f%n", snapshot.get75thPercentile()); output.printf(locale, " 95%% <= %2.2f%n", snapshot.get95thPercentile()); output.printf(locale, " 98%% <= %2.2f%n", snapshot.get98thPercentile()); output.printf(locale, " 99%% <= %2.2f%n", snapshot.get99thPercentile()); output.printf(locale, " 99.9%% <= %2.2f%n", snapshot.get999thPercentile()); output.printf(locale, " count = %d%n", histogram.getCount()); } }
@Setup(Level.Iteration) public void setup() { registry = new MetricRegistry(); histogram = registry.histogram("histogram"); histogramSlidingTimeWindow = registry.register("slidingTimeWindowHistogram", new Histogram(new SlidingTimeWindowReservoir(10, TimeUnit.SECONDS))); histogramUniform = registry.register("uniformHistogram", new Histogram(new UniformReservoir())); }
public void writeValues(Histogram histogram, JsonGenerator jg) throws IOException { final Snapshot snapshot = histogram.getSnapshot(); jg.writeNumberField("count", histogram.getCount()); writeHistogramSnapshot(snapshot, jg); } }
public static Map<String, Object> buildHistogramMap(Histogram h) { Map<String, Object> metrics = Maps.newHashMap(); if (h == null) { return metrics; } Map<String, Object> time = Maps.newHashMap(); time.put("max", h.getSnapshot().getMax()); time.put("min", h.getSnapshot().getMin()); time.put("mean", (long) h.getSnapshot().getMean()); time.put("95th_percentile", (long) h.getSnapshot().get95thPercentile()); time.put("98th_percentile", (long) h.getSnapshot().get98thPercentile()); time.put("99th_percentile", (long) h.getSnapshot().get99thPercentile()); time.put("std_dev", (long) h.getSnapshot().getStdDev()); metrics.put("time", time); metrics.put("count", h.getCount()); return metrics; }
com.codahale.metrics.Counter recordsProcessedCounter = new com.codahale.metrics.Counter(); recordsProcessedCounter.inc(10l); Histogram recordSizeDistributionHistogram = new Histogram(new ExponentiallyDecayingReservoir()); recordSizeDistributionHistogram.update(1); recordSizeDistributionHistogram.update(2); recordSizeDistributionHistogram.update(3); Meter recordProcessRateMeter = new Meter(); recordProcessRateMeter.mark(1l); recordProcessRateMeter.mark(2l); recordProcessRateMeter.mark(3l); Timer totalDurationTimer = new Timer(); totalDurationTimer.update(1, TimeUnit.SECONDS); totalDurationTimer.update(2, TimeUnit.SECONDS); totalDurationTimer.update(3, TimeUnit.SECONDS); Mockito.verify(this.queueSize).setValue(1000); recordsProcessedCounter.inc(5l); recordSizeDistributionHistogram.update(4); recordProcessRateMeter.mark(4l); totalDurationTimer.update(4, TimeUnit.SECONDS);
@Override protected void run() throws Exception { try { requestedReadCount = metricRegistry.register(name(this.getClass(), "requestedReadCount"), new HdrHistogram(processBuffer.getRingBufferSize() + 1, 3)); } catch (IllegalArgumentException e) { log.warn("Metric already exists", e); requestedReadCount.update(remainingCapacity); final List<Journal.JournalReadEntry> encodedRawMessages = journal.read(remainingCapacity); if (encodedRawMessages.isEmpty()) { readBlocked.inc(); journalFilled.acquire(); } catch (InterruptedException ignored) { readMessages.mark(encodedRawMessages.size()); log.debug("Processing {} messages from journal.", encodedRawMessages.size()); for (final Journal.JournalReadEntry encodedRawMessage : encodedRawMessages) {
/** @return a summary of {@code hist}. */ public static String getHistogramReport(final Histogram hist) { Snapshot sn = hist.getSnapshot(); return "mean=" + DOUBLE_FORMAT.format(sn.getMean()) + ", min=" + DOUBLE_FORMAT.format(sn.getMin()) + ", max=" + DOUBLE_FORMAT.format(sn.getMax()) + ", stdDev=" + DOUBLE_FORMAT.format(sn.getStdDev()) + ", 50th=" + DOUBLE_FORMAT.format(sn.getMedian()) + ", 75th=" + DOUBLE_FORMAT.format(sn.get75thPercentile()) + ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) + ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile()) + ", 99.9th=" + DOUBLE_FORMAT.format(sn.get999thPercentile()) + ", 99.99th=" + DOUBLE_FORMAT.format(sn.getValue(0.9999)) + ", 99.999th=" + DOUBLE_FORMAT.format(sn.getValue(0.99999)); }
private void flush(List<Map.Entry<IndexSet, Message>> messages) { // never try to flush an empty buffer if (messages.isEmpty()) { return; } activeFlushThreads.incrementAndGet(); if (log.isDebugEnabled()) { log.debug("Starting flushing {} messages, flush threads active {}", messages.size(), activeFlushThreads.get()); } try (Timer.Context ignored = processTime.time()) { lastFlushTime.set(System.nanoTime()); writeMessageEntries(messages); batchSize.update(messages.size()); bufferFlushes.mark(); } catch (Exception e) { log.error("Unable to flush message buffer", e); bufferFlushFailures.mark(); } activeFlushThreads.decrementAndGet(); log.debug("Flushing {} messages completed", messages.size()); }
Entry<String, Counter> counter = counterIterator.next(); MetricsInfo info = Interns.info(counter.getKey(), EMPTY_STRING); builder.addCounter(info, counter.getValue().getCount()); final Histogram histogram = entry.getValue(); addSnapshot(builder, name, EMPTY_STRING, histogram.getSnapshot(), histogram.getCount()); final Meter meter = meterEntry.getValue(); addMeter(builder, name, EMPTY_STRING, meter.getCount(), meter.getMeanRate(), meter.getOneMinuteRate(), meter.getFiveMinuteRate(), meter.getFifteenMinuteRate()); final String name = timerEntry.getKey(); final Timer timer = timerEntry.getValue(); final Snapshot snapshot = timer.getSnapshot(); addMeter(builder, name, EMPTY_STRING, timer.getCount(), timer.getMeanRate(), timer.getOneMinuteRate(), timer.getFiveMinuteRate(), timer.getFifteenMinuteRate());
public static void main(String[] args) throws InterruptedException { MetricRegistry registry = new MetricRegistry(); ConsoleReporter reporter = ConsoleReporter.forRegistry(registry).build(); reporter.start(1, TimeUnit.SECONDS); Histogram histogram = new Histogram(new ExponentiallyDecayingReservoir()); registry.register(MetricRegistry.name(HistogramExample.class, "request", "histogram"), histogram); while (true) { Thread.sleep(1000); histogram.update(random.nextInt(100000)); } } }
/** @return an abbreviated summary of {@code hist}. */ public static String getShortHistogramReport(final Histogram hist) { Snapshot sn = hist.getSnapshot(); return "mean=" + DOUBLE_FORMAT.format(sn.getMean()) + ", min=" + DOUBLE_FORMAT.format(sn.getMin()) + ", max=" + DOUBLE_FORMAT.format(sn.getMax()) + ", stdDev=" + DOUBLE_FORMAT.format(sn.getStdDev()) + ", 95th=" + DOUBLE_FORMAT.format(sn.get95thPercentile()) + ", 99th=" + DOUBLE_FORMAT.format(sn.get99thPercentile()); }
private void updateChannelPerThreadCounters(int amount) { Thread thread = Thread.currentThread(); Counter channelCount = this.metricRegistry.counter(name(counterPrefix(thread), "registered-channel-count")); channelCount.inc(amount); Histogram histogram = metricRegistry.histogram(name(counterPrefix(thread), "channels")); histogram.update(channelCount.getCount()); }
private void recordSliceMetrics(StoreTransaction txh, List<Entry> row) { if (!txh.getConfiguration().hasGroupName()) return; String p = txh.getConfiguration().getGroupName(); final MetricManager mgr = MetricManager.INSTANCE; mgr.getCounter(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_COUNT).inc(row.size()); mgr.getHistogram(p, metricsStoreName, M_GET_SLICE, M_ENTRIES_HISTO).update(row.size()); }
.histogram(HISTOGRAM_NAME).getSnapshot(); "[motan-accessStatistic] app: {} module: {} item: {} total_count: {} slow_count: {} p75: {} p95: {} p98: {} p99: {} p999: {} biz_excp: {} other_excp: {} avg_time: {}ms biz_time: {}ms avg_tps: {} max_tps: {} min_tps: {} ", application, module, keys[0], result.totalCount, result.slowCount, mbFormat.format(snapshot.get75thPercentile()), mbFormat.format(snapshot.get95thPercentile()), mbFormat.format(snapshot.get98thPercentile()), mbFormat.format(snapshot.get99thPercentile()), mbFormat.format(snapshot.get999thPercentile()), result.bizExceptionCount, result.otherExceptionCount, mbFormat.format(result.costTime / result.totalCount), mbFormat.format(result.bizTime / result.totalCount), Snapshot snapshot = InternalMetricsFactory.getRegistryInstance(entry.getKey()) .histogram(HISTOGRAM_NAME).getSnapshot(); if (totalResult.totalCount > 0) { LoggerUtil.accessStatsLog(
private void recordEsMetrics(JestResult jestResult, @Nullable TimeRange range) { esTotalSearchesCounter.inc(); final long tookMs = tookMsFromSearchResult(jestResult); esRequestTimer.update(tookMs, TimeUnit.MILLISECONDS); if (range != null) { esTimeRangeHistogram.update(TimeRanges.toSeconds(range)); } }
public Map<String, Object> values() { Map<String, Object> m = new LinkedHashMap<>(); m.putAll(counter.values()); m.put("p50_" + name, Math.round(this.histogram.getSnapshot().getMedian())); m.put("p95_" + name, Math.round(this.histogram.getSnapshot().get95thPercentile())); m.put("p99_" + name, Math.round(this.histogram.getSnapshot().get99thPercentile())); m.put("p999_" + name, Math.round(this.histogram.getSnapshot().get999thPercentile())); return m; } }