Express

This feature requires AppSignal for Node.js version 3.0.0 or higher.
This feature requires Express version 4.0.0 or higher.

Default instrumentations can be disabled via the disableDefaultInstrumentations config option. You can read more about how to configure this in our Configuration Options documentation.

The AppSignal for Node.js integration for Express.

Installation

Express is instrumented automatically by the AppSignal for Node.js package. In order for errors occurring in your Express application to be forwarded to AppSignal, follow the instructions below to setup the error handler middleware.

Error Handler

The module contains middleware to send any errors that take place in your Express application to AppSignal.

Node.js
import { expressErrorHandler } from "@appsignal/nodejs"; // or: const { expressErrorHandler } = require("@appsignal/nodejs"); const app = express(); // add this after all routes, but before any other error handlers app.use(expressErrorHandler());

Only exceptions with status code 500 and above will be reported to AppSignal automatically. To send exceptions to AppSignal with other status codes, you can use custom exception handling.

Features

The Express integration will send AppSignal a child span representing the execution time of each middleware, as well as a child span for the request handler.

The integration will use the request route as the name of the action. Request query parameters will be sent.

The request body will be sent if req.body is present (for example, when using a body parsing middleware such as body-parser)

The request cookies will be sent if req.cookies is present (for example, when using a cookie parsing middleware such as cookie-parser)

When using the error handler middleware, any errors raised by the request handler or any of the middlewares will be reported to AppSignal.