express2

Express Error Monitoring

Quickly Identify and Fix Express Errors with Airbrake

Using Airbrake with Express.js

This example Node.js application uses Express.js and sets up Airbrake to report errors and performance data. To adapt this example to your app, follow these steps:

  1. Install the package:
    npm install @airbrake/node
  2. Include the required Airbrake libraries in your app.js:
    const Airbrake = require('@airbrake/node');
    const airbrakeExpress = require('@airbrake/node/dist/instrumentation/express');
  3. Configure Airbrake with your project's credentials:
    const airbrake = new Airbrake.Notifier({
      projectId: process.env.AIRBRAKE_PROJECT_ID,
      projectKey: process.env.AIRBRAKE_PROJECT_KEY,
    });
  4. This middleware should be added before any routes are defined:
    app.use(airbrakeExpress.makeMiddleware(airbrake));
  5. The error handler middleware should be defined last. For more info on how this works, see the official Express error handling doc.
    app.use(airbrakeExpress.makeErrorHandler(airbrake));
  6. The last step is to run your app. To test that you've configured Airbrake correctly, you can throw an error inside any of your routes:
    app.get('/hello/:name', function hello(_req, _res) {
      throw new Error('Hello from Airbrake!');
    });

Any unhandled errors that are thrown will now be reported to Airbrake. See the basic usage to learn how to manually send errors to Airbrake.

Note: to see this all in action, take a look at our example app.js file and to run the example, follow the next steps.

Running the example app

If you want to run this example application locally, follow these steps:

  1. Clone the airbrake-js repo:
    git clone git@github.com:airbrake/airbrake-js.git
  2. Navigate to this directory:
    cd airbrake-js/packages/node/examples/express
  3. Run the following commands while providing your `project ID` and `project API key`
    npm install
    AIRBRAKE_PROJECT_ID=your-id AIRBRAKE_PROJECT_KEY=your-key node app.js
    firefox localhost:3000

Frictionless error monitoring for Express

You monitor your servers and your apps, but is anyone monitoring your user experience? Every minute that your customer experience is compromised costs you more than just money. It costs you goodwill. Airbrake can help.

Capturing Express exceptions is easy with the Airbrake Express error monitoring tool. Airbrake installs in minutes and monitors your Express applications 24 hours/day, 7 days/week, notifying you in real-time to all new errors that occur. Detailed stack traces, environment, and user reports make Express error handling easy. With Airbrake, there's no more sifting through massive log reports for that elusive error. Instead, you receive instant insight into the line of code that broke, the environment in which it occurred, and the deploy it's tied to.

 

Airbrake makes drilling down and understanding what's happening with your Express app easy so that you can quickly fix the problem using:

  • Stack traces, parameters, and affected users - locate, assess, and resolve errors in a timely manner
  • Error trends and deploy tracking - simplifying the job of managing and triaging errors
  • Custom workflow integrations - collaborate within your team to prioritize and triage errors

 

Finding the root cause of your application exceptions is easier than ever with Airbrake Express. Airbrake assists you in locating the error's file, the method, and even the line of code. With proprietary and customizable grouping algorithms, cutting through the noise and focusing on fixing the errors that matter most has never been so easy. Let Airbrake help you handle errors so you can get back to the business of delighting your users.

KEY FEATURES: 

Blazing fast, real-time errors alerts

Lightweight notifier installs quickly and won't impact your app performance

Receive error notifications via email, Slack, or webhooks

Fast error search and filtering within your Airbrake dashboard

Advanced data security including SOC-2 Compliance and SAML Single Sign-On - included with all Airbrake plans

Integrates with GitHub, Trello, Slack, JIRA, Pivotal Tracker, GitHub Enterprise, GitLab, GitLab CE/EE, Bitbucket, Lighthouse, Flowdock, Campfire, Assembla, custom webhooks and other 3rd party apps

Dupe error detection

Customizable error filtering

Unlimited users and projects

Comprehensive read & write API

Deploy tracking to monitor code quality

Performance insight about your total app health including your code, production environment, and the user experience.