Open dylanbathurst opened 8 years ago
If I remember correctly, if disabled, doing require('newrelic')
won't return anything. At least that's what I believe to have been the case when I wrote this originally. I am not currently working on a project that is using this so I'd have a hard time testing it.
I think the best solution is to see if on the latest version of the newrelic client you can get back an instance of the newrelic
client when NEW_RELIC_ENABLED=false
. If that is the case, I'd accept a PR that always does require('newrelic')
so the client is always available even if it doesn't actually send anything.
Here are all of the available environment variables with descriptions: https://www.npmjs.com/package/newrelic#configuring-the-module
When instrumenting node-env-newrelic I like having it in the global namespace so I can use it in other files without having to
require
it. I've set it up like this in my app.js file:I'm running into errors though on my local development when
NEW_RELIC_DISABLED=true
but my code uses newrelic api methods in my controllers like:Have you run into this issue at all? Is there a solution already?
One solution I thought would be to add a default or fallback configuration like
console.log
ordebug
to the initor
Then this module would somehow hijack any method calls such as
.addCustomParameter()
and replace them withconsole.log()
ordebug()