Installing New Relic without adding license key to repo Installing New Relic without adding license key to repo ruby-on-rails ruby-on-rails

Installing New Relic without adding license key to repo


I use the Figaro gem to handle secret keys with ENV environment variables, similar to you. For New Relic, I have:

config/application.yml (.gitignored and not pushed to source control)

# ...NEW_RELIC_LICENSE_KEY: {{MY_KEY}}

which is then referenced in config/newrelic.yml:

# ...license_key: <%= ENV['NEW_RELIC_LICENSE_KEY'] %>

A file called config/application.example.yml gets pushed up to the source code repo with instructions to put your own license key in:

config/application.example.yml

# ...NEW_RELIC_LICENSE_KEY: # put your license key here

Also see this StackOverflow Q&A for more details:
What should be removed from public source control in Ruby on Rails?


I got a useful answer on IRC. newrelic.yml is erb interpolated. Meaning I can just add <%= ENV["NEWRELIC"] %> to the yml file.


Yes to the above answers. also, If you're on Heroku. After installing the NewRelic Addon, you can download newrelic.yml file and change license_key: to:

license_key: <%= ENV['NEW_RELIC_LICENSE_KEY']%>

This will use the NEW_RELIC_LICENSE_KEY env variable set by the NewRelic addon