Permalink
Browse files

configurable caching in console.js

  • Loading branch information...
1 parent f35cfd9 commit dabd7d8dbcee69b78ac890206d8f1f2474ff2faa @vireshas committed Mar 23, 2013
Showing with 11 additions and 6 deletions.
  1. +4 −4 backends/console.js
  2. +7 −2 config.js
View
8 backends/console.js
@@ -5,10 +5,10 @@ function ConsoleBackend(startupTime, config, emitter){
this.lastFlush = startupTime;
this.lastException = startupTime;
this.config = config.console || {};
-
+ console.log(this.config)
this.statsCache = {
counters: {},
- //timers: {}
+ timers: {}
};
// attach
@@ -31,8 +31,8 @@ ConsoleBackend.prototype.flush = function(timestamp, metrics) {
});
var out = {
- counters: this.statsCache.counters,
- timers: metrics.timers,
+ counters: this.config.useCounterCache === true ? this.statsCache.counters : metrics.counters,
+ timers: this.config.useTimerCache === true ? this.statsCache.timers : metrics.timers,
gauges: metrics.gauges,
timer_data: metrics.timer_data,
counter_rates: metrics.counter_rates,
View
9 config.js
@@ -45,8 +45,12 @@ Optional Variables:
applies to both legacy and new namespacing
console:
- prettyprint: whether to prettyprint the console backend
- output [true or false, default: true]
+ prettyprint: whether to prettyprint the console backend
+ output [true or false, default: true]
+ useCounterCache: whether to use cache for console.js counters or not
+ values [true or false]
+ useTimerCache: whether to use cache for console.js timers or not
+ values [true or false]
log: log settings [object, default: undefined]
backend: where to log: stdout or syslog [string, default: stdout]
@@ -88,6 +92,7 @@ Optional Variables:
*/
{
graphitePort: 2003
+, console: {useCounterCache: true, useTimerCache: false}
, graphiteHost: "localhost"
, port: 8125
, backends: [ "./backends/graphite", "./backends/console" ]

0 comments on commit dabd7d8

Please sign in to comment.