var async = require('async');

var context;
var publishTimer;

function publishToDashboard() {
    async.waterfall([
        function(callback) {
            context.consuler.getKeyValue(context.keys.request, function(result) {
                callback(null, result);
            });
        },
        function(requests, callback) {
            context.consuler.getKeyValue(context.keys.allocation, function(result) {
                callback(null, requests, result);
            });
        },
        function(requests, allocations, callback) {
            var timestamp = new Date();
            context.AwsHandler.publishMultiple([
                {
                    MetricName: context.strings.requestCount,
                    Dimensions: [],
                    Timestamp: timestamp,
                    Unit: "Count",
                    Value: requests
                },
                {
                    MetricName: context.strings.allocationCount,
                    Dimensions: [],
                    Timestamp: timestamp,
                    Unit: "Count",
                    Value: allocations
                }
            ]);
        }
    ], function (err, results) {});
}

module.exports = function (c) {
    context = c;
    publishTimer = setInterval(publishToDashboard, 60000);
}

var async = require('async');

var context;
var publishTimer;

function publishToDashboard() {
    async.waterfall([
        function(callback) {
            context.consuler.getKeyValue(context.keys.request, function(result) {
                callback(null, result);
            });
        },
        function(requests, callback) {
            context.consuler.getKeyValue(context.keys.allocation, function(result) {
                callback(null, requests, result);
            });
        },
        function(requests, allocations, callback) {
            var timestamp = new Date();
            context.AwsHandler.publishMultiple([
                {
                    MetricName: context.strings.requestCount,
                    Dimensions: [],
                    Timestamp: timestamp,
                    Unit: "Count",
                    Value: requests.length - 1
                },
                {
                    MetricName: context.strings.allocationCount,
                    Dimensions: [],
                    Timestamp: timestamp,
                    Unit: "Count",
                    Value: allocations.length - 1
                }
            ]);
        }
    ], function (err, results) {});
}

module.exports = function (c) {
    if (context.config.aws && context.config.aws.cloudwatch) {
        context = c;
        publishTimer = setInterval(publishToDashboard, 50000);
    }
}

Fix values sent to CloudWatch for requests and allocations. Check that CloudWatch is available and change timer to 50 seconds.
Fix values sent to CloudWatch for requests and allocations. Check that CloudWatch is available and change timer to 50 seconds.
