Heroku integration guide
Typical installation time: 1 minute
Hi there! You’ve found Honeybadger’s guide to Ruby exception and error tracking on Heroku. Once installed, Honeybadger will automatically report exceptions wherever they may happen:
- During a web request
- In a background job
- In a rake task
- When a process crashes (
at_exit)
If you’re new to Honeybadger, read our Getting Started guide to become familiar with our Ruby gem. For a refresher on working with exceptions in Ruby, check out the Honeybadger guide to Ruby exceptions.
Installation
Section titled “Installation”The first step is to add the honeybadger gem to your Gemfile:
gem 'honeybadger'Tell bundler to install:
bundle installYou can configure Honeybadger on your dynos like so:
Note: This last step isn’t necessary if you’re using our Heroku add-on, as it adds our API key to your Heroku config automatically.
bundle exec honeybadger heroku install PROJECT_API_KEYThis will automatically add a HONEYBADGER_API_KEY environment variable to your
remote Heroku config and configure deploy notifications.
honeybadger heroku install only supports our US region today: it doesn’t set
the EU region hosts, and the deploy notification
webhook it adds points at the US API. Set your Heroku config yourself instead:
heroku config:set HONEYBADGER_API_KEY=PROJECT_API_KEY HONEYBADGER_CONNECTION_HOST=eu-api.honeybadger.io HONEYBADGER_CONNECTION_UI_HOST=eu-app.honeybadger.ioThen add the deploy notification webhook, pointing at the EU API:
heroku webhooks:add -i api:release -l notify -u "https://eu-api.honeybadger.io/v1/deploys/heroku?environment=production&api_key=PROJECT_API_KEY" --app app-nameReplace app-name with your Heroku app’s name, and change environment if
this app isn’t your production environment.
Tracking deployments
Section titled “Tracking deployments”To learn more about tracking deployments, see the Tracking deployments section of the Getting Started guide.
Deploy tracking via Heroku is implemented using Heroku’s app webhooks. If you ran the Installation command already, then you should already have deployment tracking installed. Otherwise, to install the addon and configure it for Honeybadger, run the following CLI command from your project root:
bundle exec honeybadger heroku install_deploy_notificationIf the honeybadger CLI command fails for whatever reason, you can add the deploy hook manually by running:
heroku webhooks:add -i api:release -l notify -u "https://api.honeybadger.io/v1/deploys/heroku?repository=git@github.com/username/projectname&environment=production&api_key=PROJECT_API_KEY" --app app-nameYou should replace the repository, api_key, and app options with your own
values. You may also want to change the environment (set to production by
default).
If your account is in our EU region, don’t use
install_deploy_notification, since it always adds a webhook for our US
region. Use the manual command with eu-api.honeybadger.io in place of
api.honeybadger.io.
For more about manual use of Heroku deploy tracking, see the Heroku Deployments guide.