зеркало из https://github.com/microsoft/statsd.git
Merge pull request #289 from bmhatfield/fix-console
Remove caching from the console backend
This commit is contained in:
Коммит
18510c0979
|
@ -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,
|
||||
|
|
Загрузка…
Ссылка в новой задаче