code: public List<Metric> getAverages(int span) {
          Map<String,Metric> accum = new LinkedHashMap<>();
          int count = span / period;
          if (count > dataList.size())
              count = dataList.size();
          for (int i = dataList.size() - count; i < dataList.size(); i++) {
              MetricData metricData = dataList.get(i);
              for (Metric metric : metricData.getMetrics()) {
                  Metric total = accum.get(metric.getName());
                  if (total == null) {
                      total = new Metric(metric.getId(), metric.getName(), metric.getValue());
                      accum.put(metric.getName(), total);
                  }
                  else {
                      total.setValue(total.getValue() + metric.getValue());
                  }
              }
          }
          for (Metric metric : accum.values()) {
              metric.setValue(Math.round((double)metric.getValue() / count));
          }
          return new ArrayList<>(accum.values());
      }
docs: Accumulated averages.