const metrics = request.routeConfig.metrics;
const metrics = reply.request.routeConfig.metrics;
const metrics = request.routeOptions.metrics;
const metrics = reply.request.routeOptions.metrics;
const metrics = request.context.config.metrics;
const metrics = reply.context.config.metrics;
const metrics = request.routeConfig.metrics;
const metrics = reply.request.routeConfig.metrics;
All the client options are now scoped under a client
key in the config object.
const fastify = require('fastify')();
fastify.register(require('@immobiliarelabs/fastify-metrics'), {
host: 'udp://someip:someport',
namespace: 'ns',
// All the other dats options
});
const fastify = require('fastify')();
fastify.register(require('@immobiliarelabs/fastify-metrics'), {
client: {
host: 'udp://someip:someport',
namespace: 'ns',
// All the other dats options
},
});
For a list of all Dats
options see here.
The flags to enable, disable and configure the colelction of some metrics have been modified and brought outside the collect
key in the options (which we removed).
const fastify = require('fastify')();
fastify.register(require('@immobiliarelabs/fastify-metrics'), {
sampleInterval: 1000,
collect: {
hits: true,
timing: true,
errors: true,
health: true,
},
});
const fastify = require('fastify')();
fastify.register(require('@immobiliarelabs/fastify-metrics'), {
health: true,
});
With a custom sampleInterval
:
const fastify = require('fastify')();
fastify.register(require('@immobiliarelabs/fastify-metrics'), {
health: {
sampleInterval: 1000,
},
});
const fastify = require('fastify')();
fastify.register(require('@immobiliarelabs/fastify-metrics'), {
routes: {
responseTime: true,
hits: true,
errors: true,
},
});
We moved the key routeId
inside a metrics
object to avoid possible clashes.
Also, all the routes without an id will be ignored.
app.get(
{
config: {
routeId: 'someId',
},
},
async () => {
return { ok: true };
}
);
app.get(
{
config: {
metrics: {
routeId: 'someId',
},
},
},
async () => {
return { ok: true };
}
);