Your data. Anywhere you go.

New Relic for iOS or Android


Download on the App Store    Android App on Google play


New Relic Insights App for iOS


Download on the App Store


Learn more

Close icon

The Uninstrumented Modules Banner from the Node Agent


#1

Why am I seeing this banner?

You may have run across this banner and disregarded it because your data was showing up in APM. This banner appears when our agent noticed other modules loaded before it. This can negatively affect instrumentation so it’s best if you fix it. If you have seen this banner, let’s take a look at some possible causes and try to nix it.

And you might see a similar message in your New Relic logs.

Take Action:

So you went to the entry file of your app and either you put require('newrelic'); as line numero uno or you started scratching your head because it is the first line already.

Before you try any of these scenarios, this is your gentle nudge to upgrade the Node Agent if you’re on an older version.

Scenario 1: You are using Babel or another Transpiler

You might want to check the compiled output to see if New Relic is really and truly the first line after being compiled.

You can also use the require flag with New Relic ensuring that we are getting required upon startup with something like this:

node --require newrelic app.js

Scenario 2: You are using Webpack or another module bundler

Module bundlers can change the order that New Relic is required. While the use of Webpack isn’t officially supported, there may be a work-around that you can implement.

The newrelic module available on npm is intended to instrument server-side Node application such as Express, Hapi, Restify, etc. It does not on its own provide instrumentation of client-side code running in browsers. It should not be used as a part of an “isomorphic” JavaScript code that runs on both the server and client.

With that said, Webpack can also be used to bundle JavaScript specifically for Node applications. One such use case is transpiling code written in other scripting languages such as CoffeeScript, or to use hot module replacement.

When Webpack is creating the bundle, it scans all module dependencies defined by therequire() function. The newrelic Node module uses dynamic loading of some modules. For example, it only loads the modules it needs to instrument the frameworks/libraries used in the application. This makes it impossible for Webpack to know which dynamic modules to include at compile time. In effect, the newrelic Node module should not be bundled using a tool such as Webpack. It is not supported.

It is still however possible to use newrelic in a project that is bundled using Webpack. The newrelic module needs to be defined as an external module. This means that Webpack will not include it in its bundle, and the application will continue loading it using the native Node require() function. Note that this only works when running the application in Node, not in a browser. Browser is simply not supported.

Here is an example Webpack configuration file that will exclude the newrelic module:

module.exports = {
entry: [
“./index.js”
],

output: {
path: __dirname,
filename: “bundle.js”,

// export the bundle as a CommonJS module
// http://webpack.github.io/docs/configuration.html#output-librarytarget
libraryTarget: ‘commonjs’
},

// do not touch native Node modules (e.g. fs)
// http://webpack.github.io/docs/configuration.html#target
target: ‘node’,

externals: {
// define newrelic as an external library
// http://webpack.github.io/docs/configuration.html#externals
newrelic: true
}
}

Scenario 3 - Some Outdated Instances

If there are multiple instances reporting to the same app, and some that are outdated, simply get those old ones up to date.

Scenario 4 - Filename error

You have another file with the same name as the module. Fix: rename the file.

Scenario 5 - You are using CLS

If you are using Continuation-local Storage (CLS), this is a particular case where you would need to require CLS before newrelic.

Scenario 6 - Using conditional logic for New Relic can may cause it be loaded after other modules.

Try moving the conditional logic to your newrelic.js config file. For example:

if (process.env.NODE_ENV === ‘production’) {

module.exports.agent_enabled = true;

} else {

module.exports.agent_enabled = false;

}

Give that a go~!


My Node Transaction Names Look Funky And There Are Way Too Many