Closed sean-hill closed 8 years ago
Its insanely easy... basically copy and pasted from a project of mine...
var StatsD = require('node-statsd'),
options = require('../conf').get('statsd'),
os = require('os');
options.prefix = `${os.hostname().replace(/\./g,'_')}.${options.prefix}`;
var statsD = new StatsD(options);
Studio.use(Studio.plugin.timer(function(res){
var id = res.receiver.replace(/\//g,'.');
if(res.err){
id += '.error';
}
statsD.timing('services.'+id,res.time);
}));
I use it only for timing purposes... and studio timer already calculate and gives it for you.
Closing for now... reach me if needs to reopen
Thanks @ericholiveira. You're awesome. I guess the hard part is actually setting up statsd 😬
oh yes... sometimes configuring statsd might be a pain in the ass
I'd love to see an example of how to use the timer plugin with statsd, thanks :)