Lazy initialization / configuration
See original GitHub issueIs your feature request related to a problem? Please describe.
When using node-newrelic
, the only way to configure the instance is by using a newrelic.js
or an environment variable. It’s a bad practice to leave secrets such as the license key in your codebase and while an environment variable is somewhat more secure, it is still visible in the console when using AWS Lambda for instance.
In my specific use case I am using AWS Lambda and I want to retrieve the license key from AWS SecretsManager. This means I need to do a call to this service and since this is async, it is always “too late” to configure node-newrelic
since this is immediately intialized.
Feature Description
I would like to initialize node-newrelic
manually in which you can pass a configuration object. To make it backwards compatible you can leave the default export use a named export, such as createInstance
.
This does mean that node-newrelic
should not break or give warnings on a missing newrelic.js
or NEW_RELIC_NO_CONFIG_FILE
.
For example:
import { createInstance } from 'newrelic';
const newrelic = createInstance({
app_name: ['My Application'],
license_key: 'license key here',
});
Describe Alternatives
I have considered using a Node.js child process or workers, so first retrieving the secrets from AWS SecretsManager, then setting a custom process.env.NEW_RELIC_LICENSE_KEY
and then spawn a subprocess, but seems to tedious just to avoid this problem.
Additional context
I would be willing to help adding this feature.
Priority
Really Want
Issue Analytics
- State:
- Created 3 years ago
- Reactions:3
- Comments:5 (2 by maintainers)
Top GitHub Comments
This is not a priority given our strategic direction. We are closing this one out.
If you want to, you can use this Lambda project (layer or container) to get SSM Parameters injected as real ENV vars. https://github.com/customink/crypteia Hope that helps with this issue.