in lib/statistics.js [99:125]
var _publish = function() {
var toSend = null;
if(cwMetrics.length == 0) {
if(config.debug) {
console.log("Metrics published to Amazon CloudWatch");
}
// Don't call CloudWatch is we have no metrics in this namespace
callback(null);
return;
} else if(cwMetrics.length > 20) {
// Cloudwatch only accepts up to 20
toSend = cwMetrics.slice(0, 20);
cwMetrics = cwMetrics.slice(20);
} else {
toSend = cwMetrics;
cwMetrics = [];
}
cloudWatch.putMetricData({ Namespace: config.cloudWatchNamespace, MetricData: toSend }, function(err, data) {
if(err) {
console.error("Error pushing metrics to AWS CloudWatch: ", err);
callback(null);
} else {
_publish();
}
});
};