Ruby integration guide
Typical installation time: 3 minutes
Hi there! You’ve found Honeybadger’s guide to Ruby exception and error tracking. 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 installNext, you'll set the API key for this project.
bundle exec honeybadger install [Your project API key]This will do three things:
-
Generate a
honeybadger.ymlfile. If you don't like config files, you can place your API key in the$HONEYBADGER_API_KEYenvironment variable. - If Capistrano is installed, we'll add a require statement to Capfile.
- Send a test exception to your Honeybadger project.
Next, require the honeybadger gem after any other gems you’re using:
# ...require 'honeybadger'Honeybadger will detect any supported 3rd-party gems you’re using such as Sidekiq, Rake, etc. and integrate with them automatically.
To notify Honeybadger of an exception you’ve rescued, use Honeybadger.notify:
begin fail 'oops'rescue => exception Honeybadger.notify(exception)endFor additional ways to use Honeybadger.notify, check out the
Reporting errors chapter of our
Getting started guide.
For Rack-based web applications, see the Rack integration guide for instructions on how to automatically report exceptions in web requests.