Skip to content

Latest commit

 

History

History
191 lines (144 loc) · 3.55 KB

MIGRATION_GUIDE.md

File metadata and controls

191 lines (144 loc) · 3.55 KB

Migrating from v5 to v6

<Request>.routeConfig.metrics access

V5

const metrics = request.routeConfig.metrics;
const metrics = reply.request.routeConfig.metrics;

V6

const metrics = request.routeOptions.metrics;
const metrics = reply.request.routeOptions.metrics;

Migrating from v4 to v5

<Request|Reply>.context.config.metrics access

V4

const metrics = request.context.config.metrics;
const metrics = reply.context.config.metrics;

V5

const metrics = request.routeConfig.metrics;
const metrics = reply.request.routeConfig.metrics;

Migrating from v1 to v2

Dats client options

All the client options are now scoped under a client key in the config object.

V1

const fastify = require('fastify')();

fastify.register(require('@immobiliarelabs/fastify-metrics'), {
    host: 'udp://someip:someport',
    namespace: 'ns',
    // All the other dats options
});

V2

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.

Metrics collections setup

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).

V1

const fastify = require('fastify')();

fastify.register(require('@immobiliarelabs/fastify-metrics'), {
    sampleInterval: 1000,
    collect: {
        hits: true,
        timing: true,
        errors: true,
        health: true,
    },
});

V2

health metric

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,
    },
});

routes metrics

const fastify = require('fastify')();

fastify.register(require('@immobiliarelabs/fastify-metrics'), {
    routes: {
        responseTime: true,
        hits: true,
        errors: true,
    },
});

Route id configuration

We moved the key routeId inside a metrics object to avoid possible clashes. Also, all the routes without an id will be ignored.

V1

app.get(
    {
        config: {
            routeId: 'someId',
        },
    },
    async () => {
        return { ok: true };
    }
);

V2

app.get(
    {
        config: {
            metrics: {
                routeId: 'someId',
            },
        },
    },
    async () => {
        return { ok: true };
    }
);