Closed Yurichz closed 1 year ago
Hi @Yurichz ,
Thanks for the question.
As mentioned in the README.md, it is not advised to use the interceptor anymore. (When I have a bit more time I'll remove the interceptor from the repo).
Now the heavy lifting is done by the New Relic Node Agent, so as long as the newrelic
npm package is installed and the configuration file is present (with correct parameters), the data is going to be sent to New Relic.
Instead of creating conditional statements in your project, I'd advise using either:
If you decide to go for option 1. In your newrelic.ts
config file you can use the agent_enabled
property and set it accordingly depending on the environment you run your project in.
Alternatively - option 2 - instead of using the config file, you could use environment variables in your environments The one that is able to control whether to send data to NR or not is NEW_RELIC_ENABLED
Hope it helps.
Ty) I have one more method, if some-one need:
if (process.env.NODE_ENV === 'production') {
// eslint-disable-next-line global-require
const newrelic = require('newrelic');
newrelic.instrumentLoadedModule(
'app',
app,
);
}
Try to write: (const newrelic = require('newrelic')) only in condition, if you try to write upper, new relic will always send data, no matter if you write: ( newrelic.instrumentLoadedModule( 'app', app, ); ) In condition.
I need collect data only in production, and if i try something like this:
If i'll be in development (NODE_ENV=development) new relic collects information anyway, why? If i delete this interceptor he don't collect them.