Use Your Existing Newrelic Key on Heroku

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.

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s

%d bloggers like this: