本文整理了Java中com.codahale.metrics.Timer.getSnapshot()
方法的一些代码示例,展示了Timer.getSnapshot()
的具体用法。这些代码示例主要来源于Github
/Stackoverflow
/Maven
等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Timer.getSnapshot()
方法的具体详情如下:
包路径:com.codahale.metrics.Timer
类名称:Timer
方法名:getSnapshot
暂无
代码示例来源:origin: resilience4j/resilience4j
@Override
public Snapshot getSnapshot() {
return successfulCallsTimer.getSnapshot();
}
}
代码示例来源:origin: stagemonitor/stagemonitor
public void writeValues(Timer timer, JsonGenerator jg) throws IOException {
writeMetered(timer, jg);
writeTimerSnapshot(timer.getSnapshot(), jg);
}
}
代码示例来源:origin: stagemonitor/stagemonitor
public int compare(Timer o1, Timer o2) {
return Double.compare(o2.getSnapshot().getMean(), o1.getSnapshot().getMean());
}
});
代码示例来源:origin: stagemonitor/stagemonitor
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;
}
代码示例来源:origin: signalapp/Signal-Server
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();
}
代码示例来源:origin: stagemonitor/stagemonitor
/**
* 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;
}
代码示例来源:origin: apache/incubator-gobblin
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);
}
代码示例来源:origin: stagemonitor/stagemonitor
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');
}
代码示例来源:origin: Graylog2/graylog2-server
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;
}
代码示例来源:origin: apache/incubator-gobblin
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);
}
代码示例来源:origin: com.zaxxer/HikariCP
/** {@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);
}
}
代码示例来源:origin: stagemonitor/stagemonitor
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);
}
}
代码示例来源:origin: apache/incubator-gobblin
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()));
代码示例来源:origin: spotify/helios
private void reportTimer(String name, Timer timer) {
final Metric metric = createMetric(name, "timer")
.attribute("unit", "ns");
reportHistogram(metric, timer.getSnapshot());
reportMetered(metric, timer);
}
代码示例来源:origin: stagemonitor/stagemonitor
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;
}
代码示例来源:origin: kairosdb/kairosdb
metrics.getTrashedConnections().getValue()));
Snapshot snapshot = metrics.getRequestsTimer().getSnapshot();
prefix = prefix + ".requests_timer";
ret.add(newDataPointSet(prefix, "max", now,
代码示例来源:origin: apache/incubator-gobblin
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());
}
代码示例来源:origin: io.dropwizard.metrics/metrics-core
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()));
}
代码示例来源:origin: io.dropwizard.metrics/metrics-core
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());
}
代码示例来源:origin: io.dropwizard.metrics/metrics-core
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());
}
内容来源于网络,如有侵权,请联系作者删除!