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

Response time and "Some modules were uninstrumented"

nodejs
apm

#1

Hi guys, I need a little help here. I have a big problems with APMs in NewRelic in scope of NodeJS apps.

Currently I have more then 30 NodeJS apps. Some time ago I found that “Web transactions time” are very low (about 100-300ms for some massive APIs). I have RunScope with tests and it told me that response time is 5-20 secs, which is normal. Making request manually I got also 5-20 secs. So RunScope told me real response time. But NewRelic told me about 100-300 ms…

I forgot about it until now. Yesterday I updated newRelic agent almost on all apps up to 4.1.0 version, updated agent config (to use new features, like disabling agent APIs, managing labels and other tweaks).
Before this update, my apps use different versions (1.x.x and 2.x.x, some of them used NativeMetricsModule, some of them didnt). So After after they all use 4.1.0 and that version has NativeModule into itself. That module in all servers has been installed successfully.

And today I went into APMs, set time period to “Last 30 minutes” and discovered that all apps in APM has next warning:
“Some modules were uninstrumented during the current time window: redis, mysql, mongodb. Make sure require(‘newrelic’); is the first line of the application’s main module.”

Some apps even dont use redis and mongodb modules, and those modules doesn’t exist in package.json…

Plus to it, “Web transactions time” drops to unbelievable 5-14 ms which are far away from real numbers…

Yes, I have checked that newrelic is at higher location in file as it could be. All me apps loads file with next first lines:

‘use strict’

// Check env variable and require newrelic when run in production
if (process.env.NODE_ENV === ‘production’) {
require(‘newrelic’);
}

// App setting up code

I have read the docs which told us to “require newrelic the first module”, so what’s wrong here ???

What should I do or try ?


#2

Guys, seriously ? 12 days have passed and no help ? :persevere:


#3

@iyeremenko,

Apologies for the delay.

First, the “Some modules were uninstrumented during the current time window: redis, mysql, mongodb” message is something we often see why users start their app with PM2. This is further supported by your statement that you do not even use those modules. The problem here is that PM2 has probes for redis, mysql, and mongodb and they are getting loaded first. Our agent checks the require cache to determine if a module we instrument has been loaded before us, and these probes trigger this logic. A couple of things you can try to remove this banner:

  • Pass --node-args="-r newrelic" to your PM2 start command, or add node_args to your ecosystem.json or other PM2 config file (see PM2 Options documentation). This should ensure that newrelic gets loaded first.
  • We have also seen adding "pmx": false to your PM2 configuration file to help as well.

As for response time measurement, the Node agent measures response time based on when it starts tracing an incoming request until some action is done that we recognize as the end of said Transaction. For supported frameworks like Express, this is often wherever res.send() is called. In the case of using our Custom Instrumentation API, a call to transaction.end() will do the trick.

The agent will start a transaction when your code hits the first piece of wrapped code. For supported frameworks, the agent wraps the middleware functions that handle the URL routes. If you are using Custom Instrumentation like startWebTransaction() or startBackgroundTransaction(), then the timing will begin when it reaches this call.

  • Can you let me know what framework you are using (with versions) and a link to your app in APM?
  • Any additional information about how these massive APIs are being hit and handled by your application code will be really helpful

Here is our Compatibility and requirements doc for the Node agent.

Best regards,
Jon


#4

Hey @jhaapala I tried to do that but not works.

My post deploy command line:
'post-deploy': '. ~/.nvm/nvm.sh && nvm use && npm install && pm2 reload ecosystem.config.js --env production --node-args="-r newrelic"'

The panel still displays the message
Some modules were uninstrumented during the current time window: mongodb, redis, mysql. Make sure require('newrelic'); is the first line of the application's main module.


#5

@bruno_nonato_quaresm,

Where you able to try adding "pmx": false to your PM2 configuration file?

One thing to note is that in this case the banner can be safely ignored. We can tell that the reason for these “uninstrumented” modules is because they are PM2 probes. You can check this by setting the logging.level to trace and looking in the newrelic_agent.log file for the “uninstrumented” message. You should see the full path to the “uninstrumented” module will be in the pmx directory.

Best regards,
Jon


#6

Thanks @jhaapala I’ll do that.

My concern is that my Mongodb transactions are not displayed on the board. I think by solving this message this will be fixed right?


#7

@bruno_nonato_quaresm,

Can you set the logging.level to trace and looking in the newrelic_agent.log file for the following message:

The newrelic module must be the first module required.\nThe following modules were required before newrelic and are not being instrumented

This will list the path to the module that the agent missed. Can you paste the full message here?

Best regards,
Jon


#8


any help will be appreciated


#9

above is the error log with trace


#10

Hi @dasra.khadka, just wondering if you could give more details on your issue? It looks from the logs like the tmongodb module is being required ahead of New Relic, is that correct? If so could you give more details of the frameworks used in your application and make sure newrelic.js is the first required module :slight_smile: