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.

Support passing license_key into newrelic.agent.initialize

See original GitHub issue

Is your feature request related to a problem? Please describe.

I’d like to have the option to pass the license key directly into the agent initialization function. I don’t want to include it in the newrelic.ini file, since the key is a secret and is only available to the application during deployment.

Feature Description

if my_app.config["environment"] in ("stage", "live"):
    newrelic.agent.initialize(
        config_file="newrelic.ini",
        environment=my_app.config["environment"],
        log_level=my_app.config["loglevel"],
        license_key=my_app.config["new_relic_license_key"],  # <-- this is what would it look like
    )
    newrelic.agent.register_application()

Describe Alternatives

I could also have newrelic read the license key from the env, but our app doesn’t use the env for configuration as of yet. And splitting configuration options over multiple avenues would be a bad design, so we’d rather not do it.

As a workaround, we currently manipulate os.environ before importing any newrelic modules.

Additional Context

I tried to write a PR myself, but the config parsing for newrelic is wild, and I couldn’t get it to work by myself.

Priority

[Nice to Have]

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:11 (6 by maintainers)

github_iconTop GitHub Comments

1reaction
a-feldcommented, Oct 26, 2020

OH! You’re in the EU! Ha!! OK. You’ll also need to set the host!

from newrelic.core.config import default_host
newrelic.agent.global_settings().host = default_host("YOUR_KEY_HERE")
0reactions
a-feldcommented, Oct 26, 2020

Yeah thanks for bringing this up! We should probably consider API usage when using an EU license key. This is something we’ll chat about on the team!

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python agent configuration | New Relic Documentation
The only required Python agent configuration setting is the license key. The license key identifies the account where the agent reports application data....
Read more >
Python agent admin script: Advanced usage
Type 'newrelic-admin help <command>' for help on any of the commands ... agent configuration file is generated, only the license key option in...
Read more >
initialize (Python agent API) - New Relic Documentation
This is called to initialize the Python agent with a specified configuration file when the agent is being manually integrated with a Python...
Read more >
Invalid license key, the agent is no longer reporting information
Getting invalid license when launching my application. Tried all the solutions from newrelic discussions page. Still getting the same error.
Read more >
Java agent configuration: Config file | New Relic Documentation
New Relic's Java agent config settings for APM, including transaction tracer, errors, custom instrumentation, distributed tracing, system properties, etc.
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