The honeybadger gem 4.0 has been released!

Last week we released version 4.0.0 of the honeybadger Ruby gem. This release includes a long-awaited feature which makes it even easier to customize your error reports before they are sent to Honeybadger. We also did some much-needed refactoring, and made a few removals and deprecations for good measure. Don't worry, though—most of the API remains unchanged, so upgrading should be a relatively painless process for most users.

Last week we released version 4.0.0 of the honeybadger Ruby gem. This release includes a long-awaited feature which makes it even easier to customize your error reports before they are sent to Honeybadger. We also did some much-needed refactoring, and made a few removals and deprecations for good measure. Don't worry, though—most of the API remains unchanged, so upgrading should be a relatively painless process for most users.

Introducing the before_notify callback

Prior versions of the honeybadger gem provided three callbacks which could be used to to customize various aspects of reported errors:

  1. Honeybadger.backtrace_filter — a callback to modify the backtrace that is reported to Honeybadger
  2. Honeybadger.exception_fingerprint — a callback to customize the grouping of errors in Honeybadger
  3. Honeybadger.exception_filter — a callback to determine if the error report should be skipped entirely

Beyond these callbacks, there was no global way to change other data in error reports, such as the error message, tags, or request data—beyond rescuing and reporting exceptions locally. That's where the new before_notify callback comes in. In fact, the new callback is so versatile that it's completely replacing all three of the previous callbacks, which are now deprecated.

Moving forward, you can use a before_notify callback to accomplish all of these tasks, and more. Multiple callbacks are also supported, which provides greater flexibility when configuring Honeybadger:

Honeybadger.configure do |config|

  # Ignore an error report
  # Replaces Honeybadger.exception_filter
  config.before_notify do |notice|
    notice.halt! if notice.controller == 'auth'
  end

  # Modify the backtrace
  # Replaces Honeybadger.backtrace_filter
  config.before_notify do |notice|
    notice.backtrace.reject!{|l| l =~ /gem/ }
  end

  # Customize error grouping
  # Replaces Honeybadger.exception_fingerprint
  config.before_notify do |notice|
    notice.fingerprint = 'new fingerprint'
  end

  # Change all the properties!
  config.before_notify do |notice|
    notice.api_key = 'custom api key'
    notice.error_message = "badgers!"
    notice.error_class = 'MyError'
    notice.backtrace = ["/path/to/file.rb:5 in `method'"]
    notice.fingerprint = 'some unique string'
    notice.tags = ['foo', 'bar']
    notice.context = { user: 33 }
    notice.controller = 'MyController'
    notice.action = 'index'
    notice.parameters = { q: 'badgers?' }
    notice.session = { uid: 42 }
    notice.url = "/badgers"
  end

end

We're excited about the new before_notify callback, and believe it will open up a lot of new options moving forward!

Upgrading to 4.x

For most users on 3.x, upgrading should be uneventful. If you're using the three callbacks which I mentioned above, then you'll need to update them to use before_notify instead, and potentially make a few other minor changes, as part of the public API for Notice (the object passed in to the callback) has changed slightly.

For more information:

What to do next:
  1. Try Honeybadger for FREE
    Honeybadger helps you find and fix errors before your users can even report them. Get set up in minutes and check monitoring off your to-do list.
    Start free trial
    Easy 5-minute setup — No credit card required
  2. Get the Honeybadger newsletter
    Each month we share news, best practices, and stories from the DevOps & monitoring community—exclusively for developers like you.
    author photo

    Joshua Wood

    Josh is Honeybadger's resident bug hunter and technical debt collector. Once enthusiastically referred to as a "human exception tracker", he spends his days crafting the middleware, plugins, and gems which keep the 'badger fat and happy through a steady diet of fresh data.

    More articles by Joshua Wood
    Stop wasting time manually checking logs for errors!

    Try the only application health monitoring tool that allows you to track application errors, uptime, and cron jobs in one simple platform.

    • Know when critical errors occur, and which customers are affected.
    • Respond instantly when your systems go down.
    • Improve the health of your systems over time.
    • Fix problems before your customers can report them!

    As developers ourselves, we hated wasting time tracking down errors—so we built the system we always wanted.

    Honeybadger tracks everything you need and nothing you don't, creating one simple solution to keep your application running and error free so you can do what you do best—release new code. Try it free and see for yourself.

    Start free trial
    Simple 5-minute setup — No credit card required

    Learn more

    "We've looked at a lot of error management systems. Honeybadger is head and shoulders above the rest and somehow gets better with every new release."
    — Michael Smith, Cofounder & CTO of YvesBlue

    Honeybadger is trusted by top companies like: