Remove statsCached from console backend

This commit is contained in:
Brian Hatfield 2013-04-10 23:48:22 -04:00
Родитель 61fb8a096b
Коммит bc6146fc08
1 изменённых файлов: 2 добавлений и 18 удалений

Просмотреть файл

@ -6,33 +6,17 @@ function ConsoleBackend(startupTime, config, emitter){
this.lastException = startupTime;
this.config = config.console || {};
this.statsCache = {
counters: {},
timers: {}
};
// attach
emitter.on('flush', function(timestamp, metrics) { self.flush(timestamp, metrics); });
emitter.on('status', function(callback) { self.status(callback); });
};
ConsoleBackend.prototype.flush = function(timestamp, metrics) {
var self = this;
console.log('Flushing stats at', new Date(timestamp * 1000).toString());
// merge with previously sent values
Object.keys(self.statsCache).forEach(function(type) {
if(!metrics[type]) return;
Object.keys(metrics[type]).forEach(function(name) {
var value = metrics[type][name];
self.statsCache[type][name] || (self.statsCache[type][name] = 0);
self.statsCache[type][name] += value;
});
});
var out = {
counters: this.statsCache.counters,
timers: this.statsCache.timers,
counters: metrics.counters,
timers: metrics.timers,
gauges: metrics.gauges,
timer_data: metrics.timer_data,
counter_rates: metrics.counter_rates,