/**
  * Sample all the mutable metrics and put the snapshot in the builder
  *
  * @param builder to contain the metrics snapshot
  * @param all get all the metrics even if the values are not changed.
  */
 public void snapshot(MetricsRecordBuilder builder, boolean all) {
   for (Entry<String, MetricsTag> entry : tags()) {
     builder.add(entry.getValue());
   }
   for (Entry<String, MetricMutable> entry : metrics()) {
     entry.getValue().snapshot(builder, all);
   }
 }
Пример #2
0
 public void updateSnapshotRangeMetrics(MetricsRecordBuilder metricsRecordBuilder) {
   long prior = 0;
   for (int i = 0; i < getRange().length; i++) {
     long val = getRangeVals().get(i);
     if (val > 0) {
       metricsRecordBuilder.addCounter(
           Interns.info(name + "_" + getRangeType() + "_" + prior + "-" + getRange()[i], desc),
           val);
     }
     prior = getRange()[i];
   }
   long val = getRangeVals().get(getRange().length);
   if (val > 0) {
     metricsRecordBuilder.addCounter(
         Interns.info(
             name + "_" + getRangeType() + "_" + getRange()[getRange().length - 1] + "-inf", desc),
         getRangeVals().get(getRange().length));
   }
 }