Skip to content

Latest commit

History

24 Commits

Folders and files

NameName
Last commit message
Last commit date

Repository files navigation

Build Status

Node Stat Tracker

A generic stat tracker for NodeJS that can support many instances and different reporting backends.

Tested for NodeJS: 4+

Usage

vardummy_backend={counts: {},gauges: {},timings: {},count: function(key,num){this.counts[key]+=num;},gauge: function(key,amount){this.gauges[key]=amount;},timings: function(key,time){if(!this.timings[key]){this.timings[key]=[]}this.timings[key].push(time);}}vartracker=newStatTracker.Tracker({});functiontrack_this(){varprofiler=tracker.profiler('profile_scope');
... Somecomputation ...
tracker.count('step1_num_runs',1,["sometag"]);profiler.tick('first_step');
... Somecomputation ...
tracker.count('step2_num_runs',1);profiler.end();}

Backend Interface

A backend is a JavaScript prototype that implements the following:

functionBackend(config){}Backend.prototype.count=function(metric,value,tags){};Backend.prototype.time=function(metric,value,tags){};Backend.prototype.gauge=function(metric,value,tags){};module.exports=Backend;

The initialization config is provided by StatTracker backend_config property.

Default Backends

Node Stat Tracker comes with two backends:

  • statsd_backend: Uses node-statsd for sending StatsD packets.
  • logger_backend: Logs the values using bunyan or config provided logger.

About

NodeJS generic stat tracker

Resources

Stars

2 stars

Watchers

9 watching

Forks

Releases

Packages

Used by

Contributors

Languages