Fastify for Cloud Functions for Firebase

Adds performance instrumentation for Fastify. (default)

For more information on setting up Sentry Fastify support, see the Fastify Sentry documentation.

Import name: Sentry.fastifyIntegration

This integration is enabled by default when performance monitoring is enabled. If you'd like to modify your default integrations, read this.

The fastifyIntegration adds instrumentation for the Fastify framework to capture spans using @opentelemetry/instrumentation-fastify.

Copied
Sentry.init({
  integrations: [Sentry.fastifyIntegration()],
});

A function that decides whether an error is captured. By default, errors with a 5xx status code (and errors with a 2xx status code or lower) are captured, and errors with a 3xx or 4xx status code aren't.

Copied
declare function shouldHandleError(
  error: Error,
  request: FastifyRequest,
  reply: FastifyReply,
): boolean;

If you use TypeScript, cast the request and reply to get full type safety:

Copied
import type { FastifyRequest, FastifyReply } from "fastify";

Sentry.fastifyIntegration({
  shouldHandleError(error, minimalRequest, minimalReply) {
    const request = minimalRequest as FastifyRequest;
    const reply = minimalReply as FastifyReply;
    return reply.statusCode >= 500;
  },
});

  • fastify: ^3.21.0 || ^4.0.0
Was this helpful?
Help improve this content
Our documentation is open source and available on GitHub. Your contributions are welcome, whether fixing a typo (drat!) or suggesting an update ("yeah, this would be better").