Fastify with AllStak

Add error tracking and request monitoring to your Fastify app with the AllStak plugin.

Source repository:
AllStak/allstak-fastify
Source README:
README.md
SDK version:
0.2.1
Installation source:
npm
Last verified:
2026-05-31

Installation

Install the SDK and Fastify.

npm install @allstak/fastify fastify

Configuration

Register the plugin before your routes.

import Fastify from 'fastify';
import allstakFastify from '@allstak/fastify';

const app = Fastify();

await app.register(allstakFastify, {
  apiKey: process.env.ALLSTAK_API_KEY,
  environment: process.env.NODE_ENV ?? 'production',
  release: process.env.ALLSTAK_RELEASE,
  serviceName: 'checkout-api',
  captureRequestHeaders: true,
});

Basic example

The repo ships a runnable example at examples/fastify-demo/server.ts.

Capturing errors

Errors are captured automatically via the plugin's onError hook. Capture manually with the exported captureException.

import { captureException } from '@allstak/fastify';

captureException(new Error('checkout failed'), { level: 'error' });

Tracking requests

The plugin uses Fastify onRequest/onResponse/onError hooks to capture method, path, status, duration, and server spans, and injects response propagation headers (traceparent, baggage). Automatic — no manual hook needed.

Best practices

  • Register the plugin before defining routes.
  • Set serviceName and release.
  • captureRequestHeaders adds request-header context when needed.