Tracking Ruby Errors on Heroku

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.

On this page:

Installation

The first step is to add the honeybadger gem to your Gemfile:

ruby
gem 'honeybadger'

Tell bundler to install:

bash
bundle install

You 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.

bash
bundle exec honeybadger heroku install [YOUR API KEY HERE]

This will automatically add a HONEYBADGER_API_KEY environment variable to your remote Heroku config and configure deploy notifications.

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:

sh
bundle exec honeybadger heroku install_deploy_notification

If the honeybadger CLI command fails for whatever reason, you can add the deploy hook manually by running:

sh
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=asdf" --app app-name

You 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).