Customizing Error Grouping

Honeybadger groups similar exceptions together using rules which we've found to work the best in most cases. The default information we use to group errors is:

  1. The file name, method name, and line number of the error's location
  2. The class name of the error
  3. The component/controller name

We use this information to construct a "fingerprint" of the exception. Exceptions with the same fingerprint are treated as the same error in Honeybadger.

You can customize the grouping for each exception by changing the error class name, component, or stack traceā€”or by sending a custom fingerprint.

There are two ways you can customize the fingerprint: globally (for all exceptions that are reported from your app), and locally (when calling Honeybadger.notify).

Customizing the Grouping for all Exceptions

The Honeybadger.before_notify callback in conjunction with the Notice#fingerprint method allows you to change the fingerprint of a notice to properly group the same notices.

ruby
Honeybadger.configure do |config| config.before_notify do |notice| notice.fingerprint = [notice.error_class, notice.component, notice.backtrace.join(',')].join(':') end end

The notice parameter gives you access to useful details about the exception, such as the url where it occurred and the parsed_backtrace, an array of hashes representing each line in its backtrace. For a full list of available properties, see the API reference.

Customizing the Grouping for Honeybadger.notify

The :fingerprint option can be used to override the fingerprint for an exception reported with Honeybadger.notify:

ruby
Honeybadger.notify(exception, fingerprint: 'a unique string')