private void collectMeterReports(
     List<DBObject> docs, SortedMap<String, Meter> meters, Date timestamp) {
   if (meters.isEmpty()) return;
   for (Map.Entry<String, Meter> entry : meters.entrySet()) {
     final BasicDBObject report = getBasicDBObject(timestamp, entry.getKey(), "meter");
     final Meter v = entry.getValue();
     report.put("count", v.getCount());
     report.put("1-minute-rate", v.getOneMinuteRate());
     report.put("5-minute-rate", v.getFiveMinuteRate());
     report.put("15-minute-rate", v.getFifteenMinuteRate());
     report.put("mean-rate", v.getMeanRate());
     docs.add(report);
   }
 }
Esempio n. 2
0
  protected Map<String, Object> buildMeterMap(Meter m) {
    Map<String, Object> metrics = Maps.newHashMap();

    if (m == null) {
      return metrics;
    }

    Map<String, Object> rate = Maps.newHashMap();
    rate.put("one_minute", m.getOneMinuteRate());
    rate.put("five_minute", m.getFiveMinuteRate());
    rate.put("fifteen_minute", m.getFifteenMinuteRate());
    rate.put("total", m.getCount());
    rate.put("mean", m.getMeanRate());

    metrics.put("rate_unit", "events/second");
    metrics.put("rate", rate);

    return metrics;
  }