metricify
v2.0.1
Published
Metrics Done Easy
Downloads
6
Readme
metricify
Metrics Done Easy
Install
npm install metricify --save
Usage
function optionalCallbackOnAllMetersFinish(meterResult){
console.log(JSON.stringify(meterResult, null, 3));
}
var Metrics = require('metricify');
var factory = new Metrics(optionalCallbackOnAllMetersFinish);
var myMeter = factory.meter('myMeter');
//do some stuff
for(var i = 0; i < 10000; ++i){}
myMeter.end();
//factory.getMeters(); returns meter min/max and data points
//factory.calcMetrics(); //returns detailed stats using stats-lite
Promises
// creates a meter that starts at function call, and ends when promise is resolved
// lets you force the scope incase your function calls assuming some scope
factory.promiseMeter('my-meter-name', functionThatResultsInPromise, argumentsToFunctionCallAsArray, forceScope)