Add statsd logging for your endpoints in Fastify
You need to use Fastify version 0.31 or newer, the hook used (onSend) was added in this version
npm install --save fastify-statsd
Add it to you project with register and you are done!
// Register the plugin
fastify.register(require('fastify-statsd'), { host: 'localhost', port: 8125, metric_name: 'my_endpoint' });This plugin allows you to specify the following options:
metric_nameis used when prefixing metric names sent to statsdhoststatsd host, defaults to 'localhost'portstatsd port number, defaults to 8125