$ cnpm install axm
PMX is a module that allows you to create advanced interactions with Keymetrics I/O.
With it you can:

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');
pmx.emit('user:register', {
user : 'Alex registered',
email : 'thorustor@gmail.com'
});
var pmx = require('pmx');
pmx.action('db:clean', { comment : 'Description for this action' }, function(reply) {
clean.db(function() {
/**
* reply() must be called at the end of the action
*/
reply({success : 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.
pmx.catchAll();
pmx.notify({ success : false });
pmx.notify('This is an error');
pmx.notify(new Error('This is an error'));
Monitor routes, latency and codes. REST complient.
pmx.http(); // 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:
Values that can be read instantly.
var probe = pmx.probe();
var metric = probe.metric({
name : 'Realtime user',
value : function() {
return Object.keys(users).length;
}
});
Things that increment or decrement.
var probe = pmx.probe();
var counter = probe.counter({
name : 'Downloads'
});
http.createServer(function(req, res) {
counter.inc();
req.on('end', function() {
counter.dec();
});
});
Things that are measured as events / interval.
var probe = pmx.probe();
var meter = probe.meter({
name : 'req/min',
seconds : 60
});
http.createServer(function(req, res) {
meter.mark();
res.end({success: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 = pmx.probe();
var histogram = probe.histogram({
name : 'latency',
measurement : 'mean'
});
var latency = 0;
setInterval(function() {
latency = Math.round(Math.random() * 100);
histogram.update(latency);
}, 100);
measurement option can be:
MIT
Copyright 2013 - present © cnpmjs.org | Home |