Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Vungle/node_stat_tracker

Open more actions menu

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

24 Commits
24 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

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

  var dummy_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);
    }

  }

  var tracker = new StatTracker.Tracker({});
  function track_this() {
    var profiler = tracker.profiler('profile_scope');

    ... Some computation ...
    tracker.count('step1_num_runs', 1, ["sometag"]);

    profiler.tick('first_step');

    ... Some computation ...
    tracker.count('step2_num_runs', 1);

    profiler.end();
  }

Backend Interface

A backend is a JavaScript prototype that implements the following:

function Backend(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

Watchers

Forks

Packages

No packages published
Morty Proxy This is a proxified and sanitized view of the page, visit original site.