code: private Iterable<PutMetricDataRequest> toPutMetricDataRequests(Map<String, MetricDatum> uniqueMetrics) {
          // Opportunistically generates some machine metrics whenever there
          // is metrics consolidation
          for (MetricDatum datum: machineMetricFactory.generateMetrics()) {
              summarize(datum, uniqueMetrics);
          }
          List<PutMetricDataRequest> list = new ArrayList<PutMetricDataRequest>();
          List<MetricDatum> data = new ArrayList<MetricDatum>();
          for (MetricDatum m: uniqueMetrics.values()) {
              data.add(m);
              if (data.size() == CloudWatchMetricConfig.MAX_METRICS_DATUM_SIZE) {
                  list.addAll(newPutMetricDataRequests(data));
                  data.clear();
              }
          }
  
          if (data.size() > 0) {
              list.addAll(newPutMetricDataRequests(data));
          }
          return list;
      }
docs: Consolidates the input metrics into a list of PutMetricDataRequest, each
  within the maximum size limit imposed by CloudWatch.