Fastify Transaction Monitoring

Fastify

Code Execution Monitoring for Fastify applications

Requirement

  • Fastify >= 3.x

Install

Install the latest version of the module using the npm command below:

npm install @palzin-apm/palzin-nodejs --save

Configure the Ingestion Key and URL

You need an Ingestion Key and URL to create a Palzin Monitor (APM) instance. Obtain a new key by creating a project in your Palzin Monitor (APM) dashboard.

PALZIN_APM_INGESTION_KEY=[ingestion key]
PALZIN_APM_URL=[your palzin domain]

Initialization

It's important that Palzin is required in the first line of the script, before you require any other modules - i.e., before http, mysql, etc.

This means that you should require Palzin in your application's main file (usually index.js, server.js, or app.js). Here's an example of how Palzin Monitor (APM) is normally initialized in a NodeJS script:

const palzin = require('@palzin-apm/palzin-nodejs')({
    url: 'xxxxxxxxx',
    ingestionKey: 'xxxxxxxxxxxxx'
});


// Init Fastify instance
const fastify = require('fastify')()

// Register Palzin Monitor integration
fastify.register(palzin.fastify());

// Continue with your code!
// ...

HTTP Request Monitoring

Send an HTTP request to your fastify app to see the first data in your dashboard.

Some of the most used modules will be autowired by default.

Exclude paths

If you want to turn off monitoring in some parts of your application you can pass a JSON object to the registering function with excludePaths property to define which routes you want to exclude:

fastify.register(palzin.fastify({
    excludePaths: [
        '/posts',
        '/posts/:id',
        '/admin'
    ]
}))

You can also use the wildcard character * to match a subset of your urls:

fastify.register(palzin.fastify({
    excludePaths: [
        // Single wildcard
        '/posts*',
        // More wildcards
        '/admin/*/posts*'
    ]
}))

Access the Palzin Monitor instance

Palzin Monitor will decorate the fastify instance with a new property to access Palzin Monitor anywhere in your application:

fastify.palzin.addSegment(...);

It's mandatory to call the Palzin Monitor instance inside your fastify instance to allow automatic tasks identification.

Custom Segments

By default, Palzin Monitor (APM) reports many different tasks based on the application's dependencies. However, you can "wrap" specific parts of your code that you consider relevant to create a more complete picture of the executed statements during an execution cycle and their performance.

Learn more about custom segments.

Last updated: 1 year ago

Want to get started with Palzin Monitor? We offer a no-strings-attached
15 days trial. No credit card required.

It takes less than a minutes to setup your first monitoring.