question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Lazy initialization / configuration

See original GitHub issue

Is 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:closed
  • Created 3 years ago
  • Reactions:3
  • Comments:5 (2 by maintainers)

github_iconTop GitHub Comments

2reactions
rr0214commented, Aug 18, 2021

This is not a priority given our strategic direction. We are closing this one out.

0reactions
metaskillscommented, Oct 14, 2022

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.

Read more comments on GitHub >

github_iconTop Results From Across the Web

A Quick Guide to the Spring @Lazy Annotation - Baeldung
When we put @Lazy annotation over the @Configuration class, it indicates that all the methods with @Bean annotation should be loaded lazily.
Read more >
Lazy (Spring Framework 6.0.3 API)
Annotation Interface Lazy ... Indicates whether a bean is to be lazily initialized. May be used on any class directly or indirectly annotated...
Read more >
Spring @Lazy Bean Initialization - HowToDoInJava
Spring @Lazy allows lazy bean creation either to specific beans or we can configure the lazy loading globally at the application level.
Read more >
How to use @Lazy in Spring - javabydeveloper Java Tutorials
If Lazy is present on a @Configuration class, this indicates that all @Bean methods within that @Configuration should be lazily initialized.
Read more >
Spring Boot @Lazy - lazy bean initialization with @Lazy
@Lazy annotation indicates whether a bean is to be lazily initialized. It can be used on @Component and @Bean definitions. A @Lazy bean...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found