Express

Upgrading from AppSignal for Node.js 2.x? Read about integration changes between 2.x and 3.x in the Migration Guide.

The AppSignal for Node.js integration for Express (express) v4.0.0+.

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.

import { expressErrorHandler } from "@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.

Need more help?

Contact us and speak directly with the engineers working on AppSignal. They will help you get set up, tweak your code and make sure you get the most out of using AppSignal.

Contact us

Start a trial - 30 days free

AppSignal is a great way to monitor your Ruby, Elixir & Node.js applications. Works great with Rails, Phoenix, Express and other frameworks, with support for background jobs too. Let's improve your apps together.

Start a trial