@Override public Snapshot getSnapshot() { return successfulCallsTimer.getSnapshot(); } }
public void writeValues(Timer timer, JsonGenerator jg) throws IOException { writeMetered(timer, jg); writeTimerSnapshot(timer.getSnapshot(), jg); } }
public int compare(Timer o1, Timer o2) { return Double.compare(o2.getSnapshot().getMean(), o1.getSnapshot().getMean()); } });
public static boolean isFasterThanXPercentOfAllRequests(long executionTimeNanos, double percentileLimit, Timer timer) { boolean faster = true; if (percentileLimit > 0) { if (percentileLimit >= 1) { faster = false; } else { final double percentile = timer.getSnapshot().getValue(percentileLimit); if (executionTimeNanos < percentile) { faster = false; } } } return faster; }
private void reportTimer(JsonGenerator json, String name, Timer timer) throws IOException { json.writeFieldName(sanitize(name)); json.writeStartObject(); json.writeFieldName("rate"); json.writeStartObject(); writeMetered(json, timer); json.writeEndObject(); json.writeFieldName("duration"); json.writeStartObject(); writeTimedSnapshot(json, timer.getSnapshot()); json.writeEndObject(); json.writeEndObject(); }
/** * Export dropwizard Timer as a histogram. Use TIME_UNIT as time unit. */ private MetricFamilySamples fromTimer(List<Map.Entry<MetricName, Timer>> histogramsWithSameName) { final SummaryMetricFamily summaryMetricFamily = getSummaryMetricFamily(histogramsWithSameName, "_seconds"); for (Map.Entry<MetricName, Timer> entry : histogramsWithSameName) { addSummaryMetric(summaryMetricFamily, entry.getKey(), entry.getValue().getSnapshot(), SECONDS_IN_NANOS, entry.getValue().getCount()); } return summaryMetricFamily; }
private void reportTimer(List<Point> points, String prefix, String name, Timer timer, long timestamp) throws IOException { reportSnapshot(points, prefix, name, timer.getSnapshot(), timestamp, true); reportMetered(points, prefix, name, timer, timestamp); }
private void printTimer(String name, Timer timer, int maxNameLength, StringBuilder sb) { final Snapshot snapshot = timer.getSnapshot(); sb.append(String.format("%" + maxNameLength + "s | ", name)); sb.append(formatCount(timer.getCount())); printTimerSnapshot(snapshot, sb); printMetered(timer, sb); sb.append('\n'); }
public static TimerRateMetricsResponse buildTimerMap(Timer t) { final TimerRateMetricsResponse result = new TimerRateMetricsResponse(); if (t == null) { return result; } final TimerMetricsResponse time = new TimerMetricsResponse(); time.max = TimeUnit.MICROSECONDS.convert(t.getSnapshot().getMax(), TimeUnit.NANOSECONDS); time.min = TimeUnit.MICROSECONDS.convert(t.getSnapshot().getMin(), TimeUnit.NANOSECONDS); time.mean = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().getMean(), TimeUnit.NANOSECONDS); time.percentile95th = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().get95thPercentile(), TimeUnit.NANOSECONDS); time.percentile98th = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().get98thPercentile(), TimeUnit.NANOSECONDS); time.percentile99th = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().get99thPercentile(), TimeUnit.NANOSECONDS); time.stdDev = TimeUnit.MICROSECONDS.convert((long) t.getSnapshot().getStdDev(), TimeUnit.NANOSECONDS); final RateMetricsResponse rate = new RateMetricsResponse(); rate.oneMinute = t.getOneMinuteRate(); rate.fiveMinute = t.getFiveMinuteRate(); rate.fifteenMinute = t.getFifteenMinuteRate(); rate.total = t.getCount(); rate.mean = t.getMeanRate(); result.time = time; result.rate = rate; result.rateUnit = "events/second"; result.durationUnit = TimeUnit.MICROSECONDS.toString().toLowerCase(Locale.ENGLISH); return result; }
private void reportTimer(String prefix, String name, Timer timer, long timestamp) throws IOException { reportSnapshot(prefix, name, timer.getSnapshot(), timestamp, true); reportMetered(prefix, name, timer, timestamp); }
/** {@inheritDoc} */ @Override protected Result check() throws Exception { final long the99thPercentile = TimeUnit.NANOSECONDS.toMillis(Math.round(waitTimer.getSnapshot().get99thPercentile())); return the99thPercentile <= expected99thPercentile ? Result.healthy() : Result.unhealthy("99th percentile connection wait time of %dms exceeds the threshold %dms", the99thPercentile, expected99thPercentile); } }
private void reportTimers(Map<MetricName, Timer> timers, long timestamp) { for (Map.Entry<MetricName, Timer> entry : timers.entrySet()) { final Timer timer = entry.getValue(); final Snapshot snapshot = timer.getSnapshot(); reportLine(getInfluxDbLineProtocolString(entry.getKey()), reportMetered(timer) + "," + reportTimerSnapshot(snapshot), timestamp); } }
metrics.addAll(serializeSnapshot(timer.getKey(), timer.getValue().getSnapshot())); metrics.addAll(serializeMetered(timer.getKey(), timer.getValue())); metrics.addAll(serializeSingleValue(timer.getKey(), timer.getValue().getCount(), Measurements.COUNT.getName()));
private void reportTimer(String name, Timer timer) { final Metric metric = createMetric(name, "timer") .attribute("unit", "ns"); reportHistogram(metric, timer.getSnapshot()); reportMetered(metric, timer); }
public static Timer timer(long count, double meanRate, double m1Rate, double m5Rate, double m15Rate, Snapshot snapshot) { final Timer timer = mock(Timer.class); when(timer.getCount()).thenReturn(count); when(timer.getMeanRate()).thenReturn(meanRate); when(timer.getOneMinuteRate()).thenReturn(m1Rate); when(timer.getFiveMinuteRate()).thenReturn(m5Rate); when(timer.getFifteenMinuteRate()).thenReturn(m15Rate); when(timer.getSnapshot()).thenReturn(snapshot); return timer; }
metrics.getTrashedConnections().getValue())); Snapshot snapshot = metrics.getRequestsTimer().getSnapshot(); prefix = prefix + ".requests_timer"; ret.add(newDataPointSet(prefix, "max", now,
private void printTimer(Timer timer) { final Snapshot snapshot = timer.getSnapshot(); this.outputBufferPrintStream.printf(locale, " count = %d%n", timer.getCount()); this.outputBufferPrintStream.printf(locale, " mean rate = %2.2f calls/%s%n", convertRate(timer.getMeanRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 1-minute rate = %2.2f calls/%s%n", convertRate(timer.getOneMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 5-minute rate = %2.2f calls/%s%n", convertRate(timer.getFiveMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " 15-minute rate = %2.2f calls/%s%n", convertRate(timer.getFifteenMinuteRate()), getRateUnit()); this.outputBufferPrintStream.printf(locale, " min = %2.2f %s%n", convertDuration(snapshot.getMin()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " max = %2.2f %s%n", convertDuration(snapshot.getMax()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " mean = %2.2f %s%n", convertDuration(snapshot.getMean()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " stddev = %2.2f %s%n", convertDuration(snapshot.getStdDev()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " median = %2.2f %s%n", convertDuration(snapshot.getMedian()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " 75%% <= %2.2f %s%n", convertDuration(snapshot.get75thPercentile()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " 95%% <= %2.2f %s%n", convertDuration(snapshot.get95thPercentile()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " 98%% <= %2.2f %s%n", convertDuration(snapshot.get98thPercentile()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " 99%% <= %2.2f %s%n", convertDuration(snapshot.get99thPercentile()), getDurationUnit()); this.outputBufferPrintStream.printf(locale, " 99.9%% <= %2.2f %s%n", convertDuration(snapshot.get999thPercentile()), getDurationUnit()); }
private void printTimer(Timer timer) { final Snapshot snapshot = timer.getSnapshot(); printIfEnabled(MetricAttribute.COUNT, String.format(locale, " count = %d", timer.getCount())); printIfEnabled(MetricAttribute.MEAN_RATE, String.format(locale, " mean rate = %2.2f calls/%s", convertRate(timer.getMeanRate()), getRateUnit())); printIfEnabled(MetricAttribute.M1_RATE, String.format(locale, " 1-minute rate = %2.2f calls/%s", convertRate(timer.getOneMinuteRate()), getRateUnit())); printIfEnabled(MetricAttribute.M5_RATE, String.format(locale, " 5-minute rate = %2.2f calls/%s", convertRate(timer.getFiveMinuteRate()), getRateUnit())); printIfEnabled(MetricAttribute.M15_RATE, String.format(locale, " 15-minute rate = %2.2f calls/%s", convertRate(timer.getFifteenMinuteRate()), getRateUnit())); printIfEnabled(MetricAttribute.MIN, String.format(locale, " min = %2.2f %s", convertDuration(snapshot.getMin()), getDurationUnit())); printIfEnabled(MetricAttribute.MAX, String.format(locale, " max = %2.2f %s", convertDuration(snapshot.getMax()), getDurationUnit())); printIfEnabled(MetricAttribute.MEAN, String.format(locale, " mean = %2.2f %s", convertDuration(snapshot.getMean()), getDurationUnit())); printIfEnabled(MetricAttribute.STDDEV, String.format(locale, " stddev = %2.2f %s", convertDuration(snapshot.getStdDev()), getDurationUnit())); printIfEnabled(MetricAttribute.P50, String.format(locale, " median = %2.2f %s", convertDuration(snapshot.getMedian()), getDurationUnit())); printIfEnabled(MetricAttribute.P75, String.format(locale, " 75%% <= %2.2f %s", convertDuration(snapshot.get75thPercentile()), getDurationUnit())); printIfEnabled(MetricAttribute.P95, String.format(locale, " 95%% <= %2.2f %s", convertDuration(snapshot.get95thPercentile()), getDurationUnit())); printIfEnabled(MetricAttribute.P98, String.format(locale, " 98%% <= %2.2f %s", convertDuration(snapshot.get98thPercentile()), getDurationUnit())); printIfEnabled(MetricAttribute.P99, String.format(locale, " 99%% <= %2.2f %s", convertDuration(snapshot.get99thPercentile()), getDurationUnit())); printIfEnabled(MetricAttribute.P999, String.format(locale, " 99.9%% <= %2.2f %s", convertDuration(snapshot.get999thPercentile()), getDurationUnit())); }
private void reportTimer(long timestamp, String name, Timer timer) { final Snapshot snapshot = timer.getSnapshot(); report(timestamp, name, "count,max,mean,min,stddev,p50,p75,p95,p98,p99,p999,mean_rate,m1_rate,m5_rate,m15_rate,rate_unit,duration_unit", timerFormat, timer.getCount(), convertDuration(snapshot.getMax()), convertDuration(snapshot.getMean()), convertDuration(snapshot.getMin()), convertDuration(snapshot.getStdDev()), convertDuration(snapshot.getMedian()), convertDuration(snapshot.get75thPercentile()), convertDuration(snapshot.get95thPercentile()), convertDuration(snapshot.get98thPercentile()), convertDuration(snapshot.get99thPercentile()), convertDuration(snapshot.get999thPercentile()), convertRate(timer.getMeanRate()), convertRate(timer.getOneMinuteRate()), convertRate(timer.getFiveMinuteRate()), convertRate(timer.getFifteenMinuteRate()), getRateUnit(), getDurationUnit()); }
private void logTimer(String name, Timer timer) { final Snapshot snapshot = timer.getSnapshot(); loggerProxy.log(marker, "type={}, name={}, count={}, min={}, max={}, mean={}, stddev={}, median={}, " + "p75={}, p95={}, p98={}, p99={}, p999={}, mean_rate={}, m1={}, m5={}, " + "m15={}, rate_unit={}, duration_unit={}", "TIMER", prefix(name), timer.getCount(), convertDuration(snapshot.getMin()), convertDuration(snapshot.getMax()), convertDuration(snapshot.getMean()), convertDuration(snapshot.getStdDev()), convertDuration(snapshot.getMedian()), convertDuration(snapshot.get75thPercentile()), convertDuration(snapshot.get95thPercentile()), convertDuration(snapshot.get98thPercentile()), convertDuration(snapshot.get99thPercentile()), convertDuration(snapshot.get999thPercentile()), convertRate(timer.getMeanRate()), convertRate(timer.getOneMinuteRate()), convertRate(timer.getFiveMinuteRate()), convertRate(timer.getFifteenMinuteRate()), getRateUnit(), getDurationUnit()); }