JSPM

  • ESM via JSPM
  • ES Module Entrypoint
  • Export Map
  • Keywords
  • License
  • Repository URL
  • TypeScript Types
  • README
  • Created
  • Published
  • Downloads 2
  • Score
    100M100P100Q35714F
  • License MIT

Core library to add performance metrics to your Node.js application.

Package Exports

  • metricador

This package does not declare an exports field, so the exports above have been automatically detected and optimized by JSPM instead. If any package subpath is missing, it is recommended to post an issue to the original package (metricador) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

Build Status codecov.io david-dm Inline docs Code Climate

Metricador

Core library to add performance metrics to your Node.js application. Supports using metric implementations such as Counters and Histograms to send data over to specialized backends (such as Graphite).

Usage

Top level of your app:

var metricador = require('metricador');

var metricRegistry = metricador.registry;
var metricPublishers = [
  metricador.publishers.console.json.get(registry),
  metricador.publishers.graphite.json.get(registry, '<hostname_or_ip_of_Graphite_server>')
];
var metricReporter = new metricador.Reporter(metricPublishers);

Inside one of your app controllers:

var metricador = require('metricador');

var metricRegistry = metricador.registry;
var hitCounter = metricRegistry.counter("myapp.controllers.registration.hits");
var responseTimes = metricRegistry.histogram("myapp.controllers.registration.responsetimes");

// ...Business logic...
hitCounter.incrementAndGet();
responseTimes.update(timeElapsed);

Every 30 seconds the reporter will output something similar to the standard console:

{
  'myapp.controllers.registration.hits': 3401,
  'myapp.controllers.registration.responsetimes.0_100': 2001,
  'myapp.controllers.registration.responsetimes.100_250': 2400,
  'myapp.controllers.registration.responsetimes.250_500': 230,
  'myapp.controllers.registration.responsetimes.500_1000': 20,
  'myapp.controllers.registration.responsetimes.1000_1500': 1,
  'myapp.controllers.registration.responsetimes.1500_Inf': 3
}

Since we registered a Graphite publisher it will also send the data to the Graphite server for plotting.

License

MIT