com.yammer.metrics.core.Timer.sum()方法的使用及代码示例

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

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

Timer.sum介绍

[英]Returns the sum of all recorded durations.
[中]返回所有记录的持续时间之和。

代码示例

代码示例来源:origin: urbanairship/statshtable

@Override
  public double sum() {
    return t.sum();
  }
}

代码示例来源:origin: amient/kafka-metrics

@Override
public void processTimer(MetricName name, Timer timer, Long timestamp) {
  Map<String, Double> fields = new HashMap<String, Double>();
  fields.put("Count", Double.valueOf(timer.count()));
  fields.put("MeanRate", timer.meanRate());
  fields.put("FifteenMinuteRate", timer.fifteenMinuteRate());
  fields.put("FiveMinuteRate", timer.fiveMinuteRate());
  fields.put("OneMinuteRate", timer.oneMinuteRate());
  fields.put("Max", timer.max());
  fields.put("Mean", timer.mean());
  fields.put("Min", timer.min());
  fields.put("StdDev", timer.stdDev());
  fields.put("Sum", timer.sum());
  publish(createMeasurement(name, timestamp, fixedTags, fields));
}

代码示例来源:origin: com.ngdata/hbase-indexer-mr

private void copyIndexingMetricsToCounters(Context context) {
  final String COUNTER_GROUP = "HBase Indexer Metrics";
  SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics = Metrics.defaultRegistry().groupedMetrics(
      new IndexerMetricsUtil.IndexerMetricPredicate());
  for (Entry<String, SortedMap<MetricName, Metric>> metricsGroupEntry : groupedMetrics.entrySet()) {
    SortedMap<MetricName, Metric> metricsGroupMap = metricsGroupEntry.getValue();
    for (Entry<MetricName, Metric> metricEntry : metricsGroupMap.entrySet()) {
      MetricName metricName = metricEntry.getKey();
      Metric metric = metricEntry.getValue();
      String counterName = metricName.getType() + ": " + metricName.getName();
      if (metric instanceof Counter) {
        Counter counter = (Counter) metric;
        context.getCounter(COUNTER_GROUP, counterName).increment(counter.count());
      } else if (metric instanceof Meter) {
        Meter meter = (Meter) metric;
        context.getCounter(COUNTER_GROUP, counterName).increment(meter.count());
      } else if (metric instanceof Timer) {
        Timer timer = (Timer) metric;
        context.getCounter(COUNTER_GROUP, counterName).increment((long) timer.sum());
      }
    }
  }
}

代码示例来源:origin: NGDATA/hbase-indexer

private void copyIndexingMetricsToCounters(Context context) {
  final String COUNTER_GROUP = "HBase Indexer Metrics";
  SortedMap<String, SortedMap<MetricName, Metric>> groupedMetrics = Metrics.defaultRegistry().groupedMetrics(
      new IndexerMetricsUtil.IndexerMetricPredicate());
  for (Entry<String, SortedMap<MetricName, Metric>> metricsGroupEntry : groupedMetrics.entrySet()) {
    SortedMap<MetricName, Metric> metricsGroupMap = metricsGroupEntry.getValue();
    for (Entry<MetricName, Metric> metricEntry : metricsGroupMap.entrySet()) {
      MetricName metricName = metricEntry.getKey();
      Metric metric = metricEntry.getValue();
      String counterName = metricName.getType() + ": " + metricName.getName();
      if (metric instanceof Counter) {
        Counter counter = (Counter) metric;
        context.getCounter(COUNTER_GROUP, counterName).increment(counter.count());
      } else if (metric instanceof Meter) {
        Meter meter = (Meter) metric;
        context.getCounter(COUNTER_GROUP, counterName).increment(meter.count());
      } else if (metric instanceof Timer) {
        Timer timer = (Timer) metric;
        context.getCounter(COUNTER_GROUP, counterName).increment((long) timer.sum());
      }
    }
  }
}

相关文章