mof-statsd
mof-statsd which is a wrapper of statsd-client is a middleware of floodesh
Install
npm install mof-statsd
Usage
const Worker = const request = const statsd = const options = host:"host of statsd daemon" port:8125 debug: fase; worker;// make sure statsd middlerware is before middleware which have to use statsdworker;
The mof-request default sends a counting
metric while requesting, and also a counting
metric if error. Once a response comes back, it sends a timing
metric wich represents a network latency.
Customise
Below is an example for sending a metric in your middleware:
//example.jsmodule{ //send a counter metric ctx; //a `timing` metric //first we set a beginning time ctxts = ; //... // then we send the diff, statsd automatically compute the diff between the moment calling the fucntion and the beginning time ctx;}