use of com.amazonaws.services.cloudwatch.model.MetricDatum in project camel by apache.
the class CwProducer method getMetricData.
private List<MetricDatum> getMetricData(Exchange exchange) {
Object body = exchange.getIn().getBody();
if (body instanceof List) {
return CastUtils.cast((List<?>) body);
}
if (body instanceof MetricDatum) {
return Arrays.asList((MetricDatum) body);
}
MetricDatum metricDatum = new MetricDatum().withMetricName(determineName(exchange)).withValue(determineValue(exchange)).withUnit(determineUnit(exchange)).withTimestamp(determineTimestamp(exchange));
setDimension(metricDatum, exchange);
return Arrays.asList(metricDatum);
}
use of com.amazonaws.services.cloudwatch.model.MetricDatum in project chassis by Kixeye.
the class MetricsCloudWatchReporter method addDatum.
private void addDatum(String name, double value, LinkedList<PutMetricDataRequest> requests, Date timestamp) {
if (logger.isDebugEnabled()) {
logger.debug("Adding Datum {} with value {} at {}", name, value, timestamp);
}
if (requests.isEmpty() || requests.getLast().getMetricData().size() == MAX_CLOUDWATCH_DATUM_PER_REQUEST) {
requests.add(createRequest());
}
PutMetricDataRequest request = requests.getLast();
MetricDatum datum = new MetricDatum().withTimestamp(timestamp).withValue(value).withMetricName(name).withUnit(StandardUnit.None).withDimensions(createDimensions());
request.withMetricData(datum);
}
Aggregations