diff --git a/lib/process_metrics.js b/lib/process_metrics.js index a89d35d..b99a637 100644 --- a/lib/process_metrics.js +++ b/lib/process_metrics.js @@ -1,4 +1,4 @@ -var process_metrics = function (metrics, flushInterval) { +var process_metrics = function (metrics, flushInterval, ts, flushCallback) { var starttime = Date.now(); var key; var counter_rates = {}; @@ -81,8 +81,7 @@ var process_metrics = function (metrics, flushInterval) { //add processed metrics to the metrics_hash metrics.counter_rates = counter_rates; metrics.timer_data = timer_data; - - return metrics; + flushCallback(ts, metrics); } exports.process_metrics = process_metrics diff --git a/stats.js b/stats.js index a647af2..19e6c93 100644 --- a/stats.js +++ b/stats.js @@ -71,10 +71,11 @@ function flushMetrics() { } }); - metrics_hash = pm.process_metrics(metrics_hash, flushInterval) + pm.process_metrics(metrics_hash, flushInterval, time_stamp, function emitFlush() { + // Flush metrics to each backend. + backendEvents.emit('flush', time_stamp, metrics_hash); + }); - // Flush metrics to each backend. - backendEvents.emit('flush', time_stamp, metrics_hash); }; var stats = {