com.codahale.metrics.Snapshot.get98thPercentile()方法的使用及代码示例

x33g5p2x  于2022-01-29 转载在 其他  
字(19.6k)|赞(0)|评价(0)|浏览(103)

本文整理了Java中com.codahale.metrics.Snapshot.get98thPercentile()方法的一些代码示例,展示了Snapshot.get98thPercentile()的具体用法。这些代码示例主要来源于Github/Stackoverflow/Maven等平台,是从一些精选项目中提取出来的代码,具有较强的参考意义,能在一定程度帮忙到你。Snapshot.get98thPercentile()方法的具体详情如下:
包路径:com.codahale.metrics.Snapshot
类名称:Snapshot
方法名:get98thPercentile

Snapshot.get98thPercentile介绍

[英]Returns the value at the 98th percentile in the distribution.
[中]返回分布中第98百分位的值。

代码示例

代码示例来源:origin: alibaba/jstorm

public static String histogramStr(AsmHistogramSnapshot snapshot) {
  StringBuilder sb = new StringBuilder(128);
  sb.append("histogram");
  Snapshot s = snapshot.getSnapshot();
  sb.append("(").append("id:").append(snapshot.getMetricId()).append(",min:").append(s.getMin()).append(",max:")
      .append(s.getMax()).append(",mean:").append(s.getMean()).append(",p50:").append(s.getMedian())
      .append(",p75:").append(s.get75thPercentile()).append(",p95:").append(s.get95thPercentile()).append(",p98:")
      .append(s.get98thPercentile()).append(",p99:").append(s.get99thPercentile()).append(")");
  return sb.toString();
}

代码示例来源:origin: signalapp/Signal-Server

private void writeSnapshot(JsonGenerator json, Snapshot snapshot) throws IOException {
 json.writeNumberField("max", snapshot.getMax());
 json.writeNumberField("mean", snapshot.getMean());
 json.writeNumberField("min", snapshot.getMin());
 json.writeNumberField("stddev", snapshot.getStdDev());
 json.writeNumberField("median", snapshot.getMedian());
 json.writeNumberField("p75", snapshot.get75thPercentile());
 json.writeNumberField("p95", snapshot.get95thPercentile());
 json.writeNumberField("p98", snapshot.get98thPercentile());
 json.writeNumberField("p99", snapshot.get99thPercentile());
 json.writeNumberField("p999", snapshot.get999thPercentile());
}

代码示例来源:origin: apache/hbase

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());
 }
}

代码示例来源:origin: apache/incubator-gobblin

private void printHistogram(Histogram histogram) {
 this.outputBufferPrintStream.printf(locale, "             count = %d%n", histogram.getCount());
 Snapshot snapshot = histogram.getSnapshot();
 this.outputBufferPrintStream.printf(locale, "               min = %d%n", snapshot.getMin());
 this.outputBufferPrintStream.printf(locale, "               max = %d%n", snapshot.getMax());
 this.outputBufferPrintStream.printf(locale, "              mean = %2.2f%n", snapshot.getMean());
 this.outputBufferPrintStream.printf(locale, "            stddev = %2.2f%n", snapshot.getStdDev());
 this.outputBufferPrintStream.printf(locale, "            median = %2.2f%n", snapshot.getMedian());
 this.outputBufferPrintStream.printf(locale, "              75%% <= %2.2f%n", snapshot.get75thPercentile());
 this.outputBufferPrintStream.printf(locale, "              95%% <= %2.2f%n", snapshot.get95thPercentile());
 this.outputBufferPrintStream.printf(locale, "              98%% <= %2.2f%n", snapshot.get98thPercentile());
 this.outputBufferPrintStream.printf(locale, "              99%% <= %2.2f%n", snapshot.get99thPercentile());
 this.outputBufferPrintStream.printf(locale, "            99.9%% <= %2.2f%n", snapshot.get999thPercentile());
}

代码示例来源:origin: Graylog2/graylog2-server

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;
}

代码示例来源:origin: signalapp/Signal-Server

private void writeTimedSnapshot(JsonGenerator json, Snapshot snapshot) throws IOException {
 json.writeNumberField("max", convertDuration(snapshot.getMax()));
 json.writeNumberField("mean", convertDuration(snapshot.getMean()));
 json.writeNumberField("min", convertDuration(snapshot.getMin()));
 json.writeNumberField("stddev", convertDuration(snapshot.getStdDev()));
 json.writeNumberField("median", convertDuration(snapshot.getMedian()));
 json.writeNumberField("p75", convertDuration(snapshot.get75thPercentile()));
 json.writeNumberField("p95", convertDuration(snapshot.get95thPercentile()));
 json.writeNumberField("p98", convertDuration(snapshot.get98thPercentile()));
 json.writeNumberField("p99", convertDuration(snapshot.get99thPercentile()));
 json.writeNumberField("p999", convertDuration(snapshot.get999thPercentile()));
}

代码示例来源:origin: io.dropwizard.metrics/metrics-core

private void printHistogram(Histogram histogram) {
  printIfEnabled(MetricAttribute.COUNT, String.format(locale, "             count = %d", histogram.getCount()));
  Snapshot snapshot = histogram.getSnapshot();
  printIfEnabled(MetricAttribute.MIN, String.format(locale, "               min = %d", snapshot.getMin()));
  printIfEnabled(MetricAttribute.MAX, String.format(locale, "               max = %d", snapshot.getMax()));
  printIfEnabled(MetricAttribute.MEAN, String.format(locale, "              mean = %2.2f", snapshot.getMean()));
  printIfEnabled(MetricAttribute.STDDEV, String.format(locale, "            stddev = %2.2f", snapshot.getStdDev()));
  printIfEnabled(MetricAttribute.P50, String.format(locale, "            median = %2.2f", snapshot.getMedian()));
  printIfEnabled(MetricAttribute.P75, String.format(locale, "              75%% <= %2.2f", snapshot.get75thPercentile()));
  printIfEnabled(MetricAttribute.P95, String.format(locale, "              95%% <= %2.2f", snapshot.get95thPercentile()));
  printIfEnabled(MetricAttribute.P98, String.format(locale, "              98%% <= %2.2f", snapshot.get98thPercentile()));
  printIfEnabled(MetricAttribute.P99, String.format(locale, "              99%% <= %2.2f", snapshot.get99thPercentile()));
  printIfEnabled(MetricAttribute.P999, String.format(locale, "            99.9%% <= %2.2f", snapshot.get999thPercentile()));
}

代码示例来源:origin: stagemonitor/stagemonitor

private void addSummaryMetric(SummaryMetricFamily summaryMetricFamily, MetricName name, Snapshot snapshot, double conversionFactor, long count) {
  summaryMetricFamily.addMetric(name.getTagValues(), count, -1, Arrays.asList(snapshot.getMedian() / conversionFactor,
      snapshot.get75thPercentile() / conversionFactor,
      snapshot.get95thPercentile() / conversionFactor,
      snapshot.get98thPercentile() / conversionFactor,
      snapshot.get99thPercentile() / conversionFactor,
      snapshot.get999thPercentile() / conversionFactor));
}

代码示例来源:origin: stagemonitor/stagemonitor

public static Snapshot snapshot(double mean, long max, long min, double stdDev, double p50, double p75, double p95,
              double p98, double p99, double p999) {
  final Snapshot snapshot = mock(Snapshot.class);
  when(snapshot.getMax()).thenReturn(max);
  when(snapshot.getMean()).thenReturn(mean);
  when(snapshot.getMin()).thenReturn(min);
  when(snapshot.getStdDev()).thenReturn(stdDev);
  when(snapshot.getMedian()).thenReturn(p50);
  when(snapshot.get75thPercentile()).thenReturn(p75);
  when(snapshot.get95thPercentile()).thenReturn(p95);
  when(snapshot.get98thPercentile()).thenReturn(p98);
  when(snapshot.get99thPercentile()).thenReturn(p99);
  when(snapshot.get999thPercentile()).thenReturn(p999);
  return snapshot;
}

代码示例来源: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 reportSnapshot(List<Point> points, String prefix, String name, Snapshot snapshot, long timestamp,
  boolean convertDuration) throws IOException {
 String baseMetricName = getKey(prefix, name);
 points.add(buildMetricAsPoint(getKey(baseMetricName, MIN), snapshot.getMin(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, MAX), snapshot.getMax(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, MEAN), snapshot.getMean(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, STDDEV), snapshot.getStdDev(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, MEDIAN), snapshot.getMedian(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, PERCENTILE_75TH), snapshot.get75thPercentile(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, PERCENTILE_95TH), snapshot.get95thPercentile(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, PERCENTILE_98TH), snapshot.get98thPercentile(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, PERCENTILE_99TH), snapshot.get99thPercentile(), convertDuration, timestamp));
 points.add(buildMetricAsPoint(getKey(baseMetricName, PERCENTILE_999TH), snapshot.get999thPercentile(), convertDuration, timestamp));
}

代码示例来源: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: stagemonitor/stagemonitor

private String reportHistogramSnapshot(Snapshot snapshot) {
  return "min=" + snapshot.getMin() + ","
      + "max=" + snapshot.getMax() + ","
      + "mean=" + snapshot.getMean() + ","
      + "p50=" + snapshot.getMedian() + ","
      + "std=" + snapshot.getStdDev() + ","
      + "p25=" + snapshot.getValue(0.25) + ","
      + "p75=" + snapshot.get75thPercentile() + ","
      + "p95=" + snapshot.get95thPercentile() + ","
      + "p98=" + snapshot.get98thPercentile() + ","
      + "p99=" + snapshot.get99thPercentile() + ","
      + "p999=" + snapshot.get999thPercentile();
}

代码示例来源:origin: stagemonitor/stagemonitor

private void printHistogramSnapshot(Snapshot snapshot, StringBuilder sb) {
  printDouble(snapshot.getMean(), sb);
  printDouble(snapshot.getMin(), sb);
  printDouble(snapshot.getMax(), sb);
  printDouble(snapshot.getStdDev(), sb);
  printDouble(snapshot.getMedian(), sb);
  printDouble(snapshot.get75thPercentile(), sb);
  printDouble(snapshot.get95thPercentile(), sb);
  printDouble(snapshot.get98thPercentile(), sb);
  printDouble(snapshot.get99thPercentile(), sb);
  printDouble(snapshot.get999thPercentile(), sb);
}

代码示例来源:origin: stagemonitor/stagemonitor

private String reportTimerSnapshot(Snapshot snapshot) {
  return "min=" + getDuration(snapshot.getMin()) + ","
      + "max=" + getDuration(snapshot.getMax()) + ","
      + "mean=" + getDuration(snapshot.getMean()) + ","
      + "p50=" + getDuration(snapshot.getMedian()) + ","
      + "std=" + getDuration(snapshot.getStdDev()) + ","
      + "p25=" + getDuration(snapshot.getValue(0.25)) + ","
      + "p75=" + getDuration(snapshot.get75thPercentile()) + ","
      + "p95=" + getDuration(snapshot.get95thPercentile()) + ","
      + "p98=" + getDuration(snapshot.get98thPercentile()) + ","
      + "p99=" + getDuration(snapshot.get99thPercentile()) + ","
      + "p999=" + getDuration(snapshot.get999thPercentile());
}

代码示例来源:origin: stagemonitor/stagemonitor

private void writeHistogramSnapshot(Snapshot snapshot, JsonGenerator jg) throws IOException {
  writeDoubleUnlessNaN(jg, "min", snapshot.getMin());
  writeDoubleUnlessNaN(jg, "max", snapshot.getMax());
  writeDoubleUnlessNaN(jg, "mean", snapshot.getMean());
  writeDoubleUnlessNaN(jg, "p50", snapshot.getMedian());
  writeDoubleUnlessNaN(jg, "std", snapshot.getStdDev());
  writeDoubleUnlessNaN(jg, "p25", snapshot.getValue(0.25));
  writeDoubleUnlessNaN(jg, "p75", snapshot.get75thPercentile());
  writeDoubleUnlessNaN(jg, "p95", snapshot.get95thPercentile());
  writeDoubleUnlessNaN(jg, "p98", snapshot.get98thPercentile());
  writeDoubleUnlessNaN(jg, "p99", snapshot.get99thPercentile());
  writeDoubleUnlessNaN(jg, "p999", snapshot.get999thPercentile());
}

代码示例来源:origin: stagemonitor/stagemonitor

private void printTimerSnapshot(Snapshot snapshot, StringBuilder sb) {
  printDouble(convertDuration(snapshot.getMean()), sb);
  printDouble(convertDuration(snapshot.getMin()), sb);
  printDouble(convertDuration(snapshot.getMax()), sb);
  printDouble(convertDuration(snapshot.getStdDev()), sb);
  printDouble(convertDuration(snapshot.getMedian()), sb);
  printDouble(convertDuration(snapshot.get75thPercentile()), sb);
  printDouble(convertDuration(snapshot.get95thPercentile()), sb);
  printDouble(convertDuration(snapshot.get98thPercentile()), sb);
  printDouble(convertDuration(snapshot.get99thPercentile()), sb);
  printDouble(convertDuration(snapshot.get999thPercentile()), sb);
}

代码示例来源:origin: apache/incubator-gobblin

private void reportSnapshot(String prefix, String name, Snapshot snapshot, long timestamp, boolean convertDuration)
  throws IOException {
 String baseMetricName = getKey(prefix, name);
 pushMetric(getKey(baseMetricName, MIN), snapshot.getMin(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, MAX), snapshot.getMax(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, MEAN), snapshot.getMean(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, STDDEV), snapshot.getStdDev(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, MEDIAN), snapshot.getMedian(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, PERCENTILE_75TH), snapshot.get75thPercentile(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, PERCENTILE_95TH), snapshot.get95thPercentile(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, PERCENTILE_98TH), snapshot.get98thPercentile(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, PERCENTILE_99TH), snapshot.get99thPercentile(), convertDuration, timestamp);
 pushMetric(getKey(baseMetricName, PERCENTILE_999TH), snapshot.get999thPercentile(), convertDuration, timestamp);
}

代码示例来源:origin: stagemonitor/stagemonitor

private void writeTimerSnapshot(Snapshot snapshot, JsonGenerator jg) throws IOException {
  writeDoubleUnlessNaN(jg, "min", convertDuration(snapshot.getMin()));
  writeDoubleUnlessNaN(jg, "max", convertDuration(snapshot.getMax()));
  writeDoubleUnlessNaN(jg, "mean", convertDuration(snapshot.getMean()));
  writeDoubleUnlessNaN(jg, "p50", convertDuration(snapshot.getMedian()));
  writeDoubleUnlessNaN(jg, "std", convertDuration(snapshot.getStdDev()));
  writeDoubleUnlessNaN(jg, "p25", convertDuration(snapshot.getValue(0.25)));
  writeDoubleUnlessNaN(jg, "p75", convertDuration(snapshot.get75thPercentile()));
  writeDoubleUnlessNaN(jg, "p95", convertDuration(snapshot.get95thPercentile()));
  writeDoubleUnlessNaN(jg, "p98", convertDuration(snapshot.get98thPercentile()));
  writeDoubleUnlessNaN(jg, "p99", convertDuration(snapshot.get99thPercentile()));
  writeDoubleUnlessNaN(jg, "p999", convertDuration(snapshot.get999thPercentile()));
}

代码示例来源:origin: alibaba/jstorm

public static MetricSnapshot convert(AsmHistogramSnapshot snapshot) {
  // some histograms are never updated, skip such metrics
  //if (snapshot.getSnapshot().getValues().length == 0) {
  //    return null;
  //}
  MetricSnapshot ret = new MetricSnapshot();
  ret.set_metricId(snapshot.getMetricId());
  ret.set_ts(TimeUtils.alignTimeToMin(snapshot.getTs()));
  ret.set_metricType(MetricType.HISTOGRAM.getT());
  Snapshot ws = snapshot.getSnapshot();
  ret.set_min(ws.getMin());
  ret.set_max(ws.getMax());
  ret.set_p50(ws.getMedian());
  ret.set_p75(ws.get75thPercentile());
  ret.set_p95(ws.get95thPercentile());
  ret.set_p98(ws.get98thPercentile());
  ret.set_p99(ws.get99thPercentile());
  ret.set_p999(ws.get999thPercentile());
  ret.set_mean(ws.getMean());
  ret.set_stddev(ws.getStdDev());
  ret.set_points(new byte[0]);
  ret.set_pointSize(0);
  return ret;
}

相关文章