JSPM

pstats

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

Monkey patch for Q to send your promises' stats to graphite.

Package Exports

  • pstats

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 (pstats) to support the "exports" field. If that is not possible, create a JSPM override to customize the exports field for this package.

Readme

This module applies patches Q library to extend promises with stats method.

var StatsD = require('node-statsd').StatsD;
var statsClient = new StatsD({prefix: 'project.'});

require('pstats')(statsClient);

longAsyncOperation()
    .then(anotherLongAsyncOperation)
    .stats('operations.xxx');

This will send following stats to graphite:

Counters:
    project.operations.xxx.attempted +1
    project.operations.xxx.succeeded +1
    or
    project.operations.xxx.failed +1
Timing:
    project.operations.xxx dt

Start time is the moment when your promise chain is being constructed (stats method called).