ActionHero and NewRelic

actionhero javascript node.js 
2014-03-10
↞ See all posts


There is now a plugin for ActionHero + New Relic if you ar using actionhero version 10 or later.

evantahler/ah-newrelic-plugin

As ActionHero matures, integrating with production monitoring tools becomes a required feature. I recently discussed integrating with airbrake, and now it’s time to talk newrelic.

For those of you that don’t know, NewRelic is a great tool to monitor the guts of you application in production, including tracing request durations, errors, etc. We use it at work. NewRelic’s JS package was really easy to work with, and all you need is the following initializer:

  1. install the newrelic agent by adding newrelic to package.json
  2. copy over the newrelic config file to the root of your app with cp node*modules/newrelic/newrelic.js ./newrelic.js
1newrelic = require("newrelic"); 2 3exports.newrelic = function (api, next) { 4 api.newrelic = {}; 5 6 api.newrelic.middleware = function (connection, actionTemplate, next) { 7 if (connection.type === "web") { 8 // for now, the node newrelic agent only supports HTTP requests 9 newrelic.setTransactionName(actionTemplate.name); 10 } 11 next(connection, true); 12 }; 13 14 api.newrelic.errorReporter = function (type, err, extraMessages, severity) { 15 newrelic.noticeError(err); 16 }; 17 18 api.newrelic._start = function (api, next) { 19 // load the newrelic middleware into actionhero 20 api.actions.preProcessors.push(api.newrelic.middleware); 21 // load the newrelic error reporter into actionhero 22 api.exceptionHandlers.reporters.push(api.newrelic.errorReporter); 23 // optional: ignore certain actions 24 // newrelic.setIgnoreTransaction('actionName'); 25 next(); 26 }; 27 28 api.newrelic._stop = function (api, next) { 29 next(); 30 }; 31 32 next(); 33};

I was kicked into action by this issue on the newrelic JS project.

In your newrelic.js config file, there are a number of options you can configure, such as moving the log location, etc.

Here is the complete list of options.

Originally published at 10 Mar 2014

Hi, I'm Evan

I write about Technology, Software, and Startups. I use my Product Management, Software Engineering, and Leadership skills to build teams that create world-class digital products.

Get in touch