use of com.amazonaws.services.cloudwatch.model.PutMetricDataRequest in project camel by apache.
the class CwComponentTest method useDefaultValuesForMetricUnitAndMetricValue.
@Test
public void useDefaultValuesForMetricUnitAndMetricValue() throws Exception {
template.send("direct:start", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
exchange.getIn().setHeader(CwConstants.METRIC_NAME, "errorCount");
}
});
ArgumentCaptor<PutMetricDataRequest> argument = ArgumentCaptor.forClass(PutMetricDataRequest.class);
verify(cloudWatchClient).putMetricData(argument.capture());
assertEquals("errorCount", argument.getValue().getMetricData().get(0).getMetricName());
assertEquals(Double.valueOf(1), argument.getValue().getMetricData().get(0).getValue());
assertEquals(StandardUnit.Count.toString(), argument.getValue().getMetricData().get(0).getUnit());
}
use of com.amazonaws.services.cloudwatch.model.PutMetricDataRequest in project camel by apache.
the class CwComponentTest method sendManuallyCreatedMetric.
@Test
public void sendManuallyCreatedMetric() throws Exception {
template.send("direct:start", ExchangePattern.InOnly, new Processor() {
public void process(Exchange exchange) throws Exception {
MetricDatum metricDatum = new MetricDatum().withMetricName("errorCount").withValue(Double.valueOf(0));
exchange.getIn().setBody(metricDatum);
}
});
ArgumentCaptor<PutMetricDataRequest> argument = ArgumentCaptor.forClass(PutMetricDataRequest.class);
verify(cloudWatchClient).putMetricData(argument.capture());
assertEquals("errorCount", argument.getValue().getMetricData().get(0).getMetricName());
assertEquals(Double.valueOf(0), argument.getValue().getMetricData().get(0).getValue());
}
use of com.amazonaws.services.cloudwatch.model.PutMetricDataRequest in project camel by apache.
the class CwProducer method process.
public void process(Exchange exchange) throws Exception {
List<MetricDatum> metricData = getMetricData(exchange);
PutMetricDataRequest request = new PutMetricDataRequest().withMetricData(metricData).withNamespace(determineNameSpace(exchange));
log.info("Sending request [{}] from exchange [{}]...", request, exchange);
getEndpoint().getCloudWatchClient().putMetricData(request);
}
use of com.amazonaws.services.cloudwatch.model.PutMetricDataRequest 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