Request Metrics for Node.js

Our npm package can now send us request metrics for Connect, Express and other Node.js web frameworks (or you can roll your own!).

Today we're apathetically announcing that we now support monitoring request metrics for web apps written in Node.js. This change may give some Node customers (whatever) deeper insight into their web applica... SORRY (sry), I can't do this. We try to live up to our name and not care at Honeybadger, but the truth is that we DO care. Not only do we care, but we're unbelievably stoked to announce that we're bringing our performance monitoring tools to Node.

This week we released version v1.1 of our honeybadger npm package. This release is the next step forward for our Node.js monitoring suite, on the heels of version v1.0 which really stepped up our Node game.

In v1.0 we brought new tools for monitoring popular Node.js frameworks and platforms such as middlware for Connect and Express, built-in support for monitoring AWS Lambda, and more.

With v1.1, we've added a new middleware for Connect/Express apps called Honeybadger.metricsHandler(). A simple express app might look like this:

var express = require('express');
var Honeybadger = require('honeybadger');

var app = express();

app.use(Honeybadger.metricsHandler);
app.use(Honeybadger.requestHandler);

app.all('/fail', function (req, res) {
  throw(new Error('This was thrown in an Express app.'));
});

app.listen(3000, function () {
  console.log('Example app listening on port 3000!');
});

app.use(Honeybadger.errorHandler);

Notice that we're using the new metricsHandler middlware before the normal requestHandler (which ensures asynchonous errors are reported) and the errorHandler middleware (which actually reports the errors).

For Connect or Express, that's the only change required to see your request metrics in Honeybadger:

Node.js request metrics

For other frameworks, we've added a Honeybadger.timing() method which can be used to send us request metrics manually:

var startAt = process.hrtime();

// Process request here.

// Calculate the time difference in milliseconds.
var diff = process.hrtime(startAt);
var time = diff[0] * 1e3 + diff[1] * 1e-6;åç

Honeybadger.timing("app.request.200", time)

The format for request metrics is app.request.STATUS_CODE, where status code is the integer status code of the response (i.e. 200, 301, 500, etc.). Still pretty easy, right?

So that's it. In the coming months we'll be working to make performance monitoring for Node even better. In the meantime, we hope that monitoring your request metrics will help you keep your Node.js apps performing at their best. Let me know what you think!


Feedback is welcome! Have a comment, question, suggestion, or bug report? Email me, submit an issue, or send a pull request.

Need a Honeybadger account? Start your free trial and monitor your Node app today!

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo

    Joshua Wood

    Josh is Honeybadger's resident bug hunter and technical debt collector. Once enthusiastically referred to as a "human exception tracker", he spends his days crafting the middleware, plugins, and gems which keep the 'badger fat and happy through a steady diet of fresh data.

    More articles by Joshua Wood
    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release."
    — Michael Smith, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: