예제 #1
0
 private Delta<?> calculateDelta(Metric<?> value) {
   long delta = value.getValue().longValue();
   Long old = this.counts.replace(value.getName(), delta);
   if (old != null) {
     delta = delta - old;
   } else {
     this.counts.putIfAbsent(value.getName(), delta);
   }
   return new Delta<Long>(value.getName(), delta, value.getTimestamp());
 }
 @Override
 public void set(String group, Collection<Metric<?>> values) {
   String prefix = group;
   if (!prefix.endsWith(".")) {
     prefix = prefix + ".";
   }
   for (Metric<?> metric : values) {
     if (!metric.getName().startsWith(prefix)) {
       metric =
           new Metric<Number>(prefix + metric.getName(), metric.getValue(), metric.getTimestamp());
     }
     set(metric);
   }
   this.groups.add(group);
 }