.withNamespace(this.namespace).withMetricName(this.metric)
.withDimensions(toDimensionList(this.dimensions))
.withStatistics(this.statistics).withPeriod(this.period)
.withStartTime(this.queryInterval.getStart().toDate())
.withEndTime(this.queryInterval.getEnd().toDate());
GetMetricStatisticsResult result = getClient().getApi()
.getMetricStatistics(request);
// sort result set
List<Datapoint> resultSet = Lists.newArrayList(result.getDatapoints());
Collections.sort(resultSet, new Comparator<Datapoint>() {
@Override
public int compare(Datapoint o1, Datapoint o2) {
return o1.getTimestamp().compareTo(o2.getTimestamp());
}
});
return new GetMetricStatisticsResult().withLabel(this.metric)
.withDatapoints(resultSet);
}