We had an existing Newrelic account and wanted to track some other apps on Heroku. I thought getting our Newrelic key into the Heroku apps would be the easiest solution. Here’s what I did.
Add this to Gemfile:
gem ‘newrelic_rpm’
Add a Heroku config:
heroku config:add NEWRELIC_LICENSE_KEY
=YOUR_KEY
Add this to environment.rb or a lib somewhere:
if ENV['NEWRELIC_LICENSE_KEY']
NewRelic::Control.instance['license_key'] = ENV['NEWRELIC_LICENSE_KEY']
NewRelic::Agent.agent.shutdown
NewRelic::Control.instance.start_agent
end
I have a feeling I didn’t do this the easiest way but it works. Or that I’m breaking some terms of service.
Advertisement