keymetrics I/O adapter
PMX is a module that allows you to create advanced interactions with Keymetrics I/O.
With it you can:
- Trigger remote actions / functions
- Analyze custom metrics / variables (with utilities like Histogram/Counter/Metric/Meters)
- Report errors (uncaught exceptions and custom errors)
- Emit events
- Analyze HTTP latency
Install PMX and add it to your package.json via:
$ npm install pmx --save
Then init the module to monitor HTTP, Errors and diverse metrics.
var pmx = require'pmx'init;
Emit events and get historical and statistics:
var pmx = require'pmx';pmxemit'user:register'user : 'Alex registered'email : 'email@example.com';
var pmx = require'pmx';pmxaction'db:clean' comment : 'Description for this action'cleandb/*** reply() must be called at the end of the action*/replysuccess : true;;;
Note: in case of exceptions in the function, your app will not be affected
Enable catch all errors. This module is enabled by default if you called pmx with the init() function.
pmxnotify success : false ;pmxnotify'This is an error';pmxnotify'This is an error';
Monitor routes, latency and codes. REST complient.
pmxhttp; // You must do this BEFORE any require('http')
This module is enabled by default if you called pmx with the init() function.
Measure critical segments of you code thanks to 4 kind of probes:
- Simple metrics: Values that can be read instantly
- Monitor variable value
- Counter: Things that increment or decrement
- Downloads being processed, user connected
- Meter: Things that are measured as events / interval
- Request per minute for a http server
- Histogram: Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution
- Monitor the mean of execution of a query into database
Values that can be read instantly.
var probe = pmxprobe;var metric = probemetricname : 'Realtime user'return Objectkeysuserslength;;
Things that increment or decrement.
var probe = pmxprobe;var counter = probecountername : 'Downloads';httpcreateServercounterinc;reqon'end'counterdec;;;
Things that are measured as events / interval.
var probe = pmxprobe;var meter = probemetername : 'req/min'seconds : 60;httpcreateServermetermark;resendsuccess:true;;
seconds option is the measurement rate of the meter, default is 1 seconds
Keeps a resevoir of statistically relevant values biased towards the last 5 minutes to explore their distribution.
var probe = pmxprobe;var histogram = probehistogramname : 'latency'measurement : 'mean';var latency = 0;setIntervallatency = MathroundMathrandom * 100;histogramupdatelatency;100;
measurement option can be:
- min: The lowest observed value.
- max: The highest observed value.
- sum: The sum of all observed values.
- variance: The variance of all observed values.
- mean: The average of all observed values.
- stddev: The stddev of all observed values.
- count: The number of observed values.
- median: 50% of all values in the resevoir are at or below this value.
- p75: See median, 75% percentile.
- p95: See median, 95% percentile.
- p99: See median, 99% percentile.
- p999: See median, 99.9% percentile.