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.

Agent does not use documented defaults when configuring using environment variables

See original GitHub issue

Description

The documentation for the NodeJS Agent says that you can configure the agent using either a newrelic.js file or environment variables.

In the documentation, you list the newrelic.js property path, the corresponding environment variable for the property, e.g. application_loggingNEW_RELIC_APPLICATION_LOGGING_ENABLED, followed by the default value of the configuration setting.

However—for example, application logging for logs in context—if the agent is being configured by environment variables but the corresponding environment variable is not set, then the feature is not turned on.

Expected Behavior

I expected that since the default value for the configuration setting application_logging applied also to the environment variable NEW_RELIC_APPLICATION_LOGGING_ENABLED. However, apparently one must explicitly set the environment variable in order for the feature to be enabled. Note that this is not limited to just application logging. NO default configuration is applied when using environment variables as the means of agent configuration.

The documentation is extremely unclear in this regard when one chooses to configure the agent via environment variables.

If the configuration setting’s default is true, for example, then I shouldn’t have to do anything, in the configuration file nor via setting environment variables, in order for the default behavior to apply.

Steps to Reproduce

  1. Configure the Node JS agent using environment variables.
  2. Be sure to set NEW_RELIC_NO_CONFIG_FILE=true for good measure.
  3. Set the bare minimum environment variables required: NEW_RELIC_APPLICATION_NAME and NEW_RELIC_LICENSE_KEY.
  4. Start your application.
  5. Don’t profit–i.e., no application logs will be sent to new relic, browser agent monitoring will be disabled, no metrics will be sent, basically, all the things the documentation says the agent defaults to enabling.

Suggested Remedies

  1. Actually have the agent internally configured according to the documented default settings, only altering the agent behavior if an end-user configures the agent differently via the acceptable configuration methods
  2. Update the documentation to explicitly state that environment variables MUST be set in order to configure the agent no matter what the stated default settings are.

Of the two, I prefer the first option because it means less work for the end-user and requires no updates to the documentation. It Just Works as the user expects according to the documentation.

Issue Analytics

  • State:closed
  • Created a year ago
  • Comments:6 (2 by maintainers)

github_iconTop GitHub Comments

1reaction
fourpastmidnightcommented, May 26, 2022

Ugh, right, there’s the default that application logging is enabled–but you have to explicitly turn on forwarding. OK, that makes sense. I’m getting all twisted around in the myriad of environment configuration variables. 😄 I was just trying to make sure I’m providing the bare minimum configuration. Thanks @bizob2828!

1reaction
fourpastmidnightcommented, May 26, 2022

And just to remove any confusion/doubt, I fixed my app and redeployed. When I do not set NEW_RELIC_APPLICATION_LOGGING_ENABLED=true, my application logs are not sent to New Relic. And as I mentioned on #1209, my logs also are not updated with New Relic-specific properties nor have my timestapms altered. However, if I set NEW_RELIC_APPLICATION_LOGGING_ENABLED=true explicitly and restart my app, then my logs are updated as discussed in #1209, and the logs show up in New Relic. So I don’t think (at least for application logging) that the default setting(s) are taking effect.

I noticed this too, the other day, when I was looking for more info in APM and didn’t see much there. So on a whim, I decided to set NEW_RELIC_APPLICATION_LOGGING_METRICS_ENABLED=true, too, and things started to light up in New Relic.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python agent configuration | New Relic Documentation
The agent config file overrides environment variables. Environment variables override the agent defaults. Here are detailed descriptions of each configuration ...
Read more >
Agents - Configuration File Reference | Consul
An agent can only join and communicate with other agents within its admin partition. Review the Admin Partitions documentation for more details. By...
Read more >
Amazon ECS container agent configuration
The Amazon ECS container agent supports a number of configuration options, most of which should be set through environment variables.
Read more >
Environment variables for the agent - Formant
If the default value is empty, nothing occurs unless the environment variable is set to some value.
Read more >
OpenTelemetry Environment Variable Specification
SDKs MAY choose to allow configuration via the environment variables in this specification, but are not required to. If they do, they SHOULD...
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