mof-statsdclient
v1.0.7
Published
middleware of floodesh, which provides a statsd client that allows you to send data to statsd server and automatically has some statistics sent that generally apply to all requests.
Downloads
5
Maintainers
Readme
mof-statsdclient
middleware of floodesh, which provides a statsd client that allows you to send data to statsd server and automatically has some statistics sent that generally apply to all requests.
Install
current version 1.0.2
npm install mof-statsdclient
include the following into your package.json
"dependencies": {
"mof-statsdclient":"^1.0.1"
}
Usage
const Statsdmw = require('mof-statsdclient')
This module exports two Object:
- StatsdClient, sends data to statsd server, currently support three datatypes: count, gauge, timer(check metric types for detail)
let config = {
"gearman":{
"servers":[{"host":"192.168.98.116"}]
},
"mongodb":"mongodb://192.168.98.116:27017/test",
"schedule":{
"concurrent":10,
"rate":6000
},
"statsd":{
"host":"localhost", // host of statsd server
"port":8125 // port that statsd server listens to
},
"request":{
"retry":3
}
}
let statsdClient = new Statsdmw.client(config.statsd);
/* api for sending data
statsdClient.count(name, value[, sampleRate]);
statsdClient.gauge(name, value[, sampleRate]);
statsdClient.timer(name, value[, sampleRate]);
*/
// statsdClient can be closed by calling
statsdClient.close();
- parsed middleware, sends the following metrics to statsd server automatically
- request_count(send 1 on every request)
- queue_time(time gap between being added to queue and being called by bottleneck)
- requestmw_time(time consumed by request middleware)
- network_time(time gap between sending request and getting response)
- reponsemw_time(time consumed by response middleware)
- parse_time(time consumed by user's parse function)
- total_time(time gap between being called by bottleneck and successfully being parsed)
// has to pass a statsdClient to middleware
worker.parsedmw.use(Statsdmw.middleware(statsdClient));