com.codahale.metrics.Snapshot类的使用及代码示例

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

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

Snapshot介绍

[英]A statistical snapshot of a Snapshot.
[中]快照的统计快照。

代码示例

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

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

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

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

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdateMeanMetric() {
  double newMean = INITIAL_MEAN + 5;
  when(snapshot.getMean()).thenReturn(newMean);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(MEAN).get(), Matchers.<Object>is(newMean));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdateMaxMetric() {
  long newMax = INITIAL_MAX + 10;
  when(snapshot.getMax()).thenReturn(newMax);
  timerAdapter.updateMonitorables();
  assertThat(extractMonitorables(timerAdapter).get(MAX).get(), Matchers.<Object>is(newMax));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdateMinMetric() {
  long newMin = INITIAL_MIN - 5;
  when(snapshot.getMin()).thenReturn(newMin);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(MIN).get(), Matchers.<Object>is(newMin));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdateMedianMetric() {
  double newMedian = INITIAL_MEDIAN + 5;
  when(snapshot.getMedian()).thenReturn(newMedian);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(MEDIAN).get(), Matchers.<Object>is(newMedian));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdateStdDevMetric() {
  double newStdDev = INITIAL_STDDEV + 5;
  when(snapshot.getStdDev()).thenReturn(newStdDev);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(STDDEV).get(), Matchers.<Object>is(newStdDev));
}

代码示例来源:origin: performancecopilot/parfait

@Before
public void setUp() {
  when(histogram.getSnapshot()).thenReturn(snapshot);
  when(snapshot.getMax()).thenReturn(INITIAL_MAX);
  when(snapshot.getMin()).thenReturn(INITIAL_MIN);
  when(snapshot.getMedian()).thenReturn(INITIAL_MEDIAN);
  when(snapshot.getMean()).thenReturn(INITIAL_MEAN);
  when(snapshot.getStdDev()).thenReturn(INITIAL_STDDEV);
  when(histogram.getCount()).thenReturn(INITIAL_COUNT);
  histogramAdapter = new HistogramAdapter(histogram, NAME, DESCRIPTION);
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdate99thMetric() {
  double new99thMetric = INITIAL_99th + 5;
  when(snapshot.get99thPercentile()).thenReturn(new99thMetric);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(NINETY_NINETH).get(), Matchers.<Object>is(new99thMetric));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdate95thMetric() {
  double new95thMetric = INITIAL_95th + 5;
  when(snapshot.get95thPercentile()).thenReturn(new95thMetric);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(NINETY_FIFTH).get(), Matchers.<Object>is(new95thMetric));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdate999thMetric() {
  double new999thMetric = INITIAL_THREE_NINES + 5;
  when(snapshot.get999thPercentile()).thenReturn(new999thMetric);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(THREE_NINES).get(), Matchers.<Object>is(new999thMetric));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdate75thMetric() {
  double new75thMetric = INITIAL_75th + 5;
  when(snapshot.get75thPercentile()).thenReturn(new75thMetric);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(SEVENTY_FIFTH).get(), Matchers.<Object>is(new75thMetric));
}

代码示例来源:origin: performancecopilot/parfait

@Test
public void shouldUpdate98thMetric() {
  double new98thMetric = INITIAL_98th + 5;
  when(snapshot.get98thPercentile()).thenReturn(new98thMetric);
  adapter.updateMonitorables();
  assertThat(extractMonitorables(adapter).get(NINETY_EIGHTH).get(), Matchers.<Object>is(new98thMetric));
}

代码示例来源:origin: palominolabs/metrics-guice

@Test
public void aTimedAnnotatedMethod() throws Exception {
  instance.doAThing();
  final Timer metric = registry.getTimers().get(name(InstrumentedWithTimed.class,
    "things"));
  assertMetricSetup(metric);
  assertThat("Guice creates a timer which records invocation length",
    metric.getCount(),
    is(1L));
  assertThat("Guice creates a timer which records invocation duration without underestimating too much",
    metric.getSnapshot().getMax(),
    is(greaterThan(NANOSECONDS.convert(5, MILLISECONDS))));
  assertThat("Guice creates a timer which records invocation duration without overestimating too much",
    metric.getSnapshot().getMax(),
    is(lessThan(NANOSECONDS.convert(15, MILLISECONDS))));
}

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

private void reportHistogram(Metric metric, Snapshot snapshot) {
 send(metric.attribute("stat", "min").value(snapshot.getMin()));
 send(metric.attribute("stat", "max").value(snapshot.getMax()));
 send(metric.attribute("stat", "mean").value(snapshot.getMean()));
 send(metric.attribute("stat", "stddev").value(snapshot.getStdDev()));
 send(metric.attribute("stat", "median").value(snapshot.getMedian()));
 send(metric.attribute("stat", "p75").value(snapshot.get75thPercentile()));
 send(metric.attribute("stat", "p99").value(snapshot.get99thPercentile()));
}

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

metrics.getTrashedConnections().getValue()));
Snapshot snapshot = metrics.getRequestsTimer().getSnapshot();
prefix = prefix + ".requests_timer";
ret.add(newDataPointSet(prefix, "max", now,
    snapshot.getMax()));
    snapshot.getMin()));
    snapshot.getMean()));
    snapshot.size()));

代码示例来源:origin: weibocom/motan

.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),
    (result.totalCount / MotanConstants.STATISTIC_PEROID), result.maxCount, result.minCount);
Snapshot snapshot =
    InternalMetricsFactory.getRegistryInstance(entry.getKey())
        .histogram(HISTOGRAM_NAME).getSnapshot();
if (totalResult.totalCount > 0) {
  LoggerUtil.accessStatsLog(
      "[motan-totalAccessStatistic] app: {} module: {} total_count: {} slow_count: {} p75: {} p95: {} p98: {} p99: {} p999: {} biz_excp: {} other_excp: {} avg_time: {}ms biz_time: {}ms avg_tps: {}",
      application, module, totalResult.totalCount, totalResult.slowCount,
      mbFormat.format(snapshot.get75thPercentile()), mbFormat.format(snapshot.get95thPercentile()),
      mbFormat.format(snapshot.get98thPercentile()), mbFormat.format(snapshot.get99thPercentile()),
      mbFormat.format(snapshot.get999thPercentile()), totalResult.bizExceptionCount,
      totalResult.otherExceptionCount, mbFormat.format(totalResult.costTime / totalResult.totalCount),
      mbFormat.format(totalResult.bizTime / totalResult.totalCount),

相关文章