honeybadger-ruby
honeybadger-ruby copied to clipboard
Allow users to customize default fingerprint for grouping
The default Ruby fingerprint is calculated server-side in our processing pipeline. Users can customize the fingerprint client-side using before_notify filter. This works fine for users who want to control grouping themselves. Some users want to customize the default grouping rather than replace it, and that's where things get tricky.
Our default fingerprint requires the application trace, which isn't currently exposed to the user on the client-side. When you access notice.backtrace in a before_notify callback, the return value is a Ruby backtrace array—not our internal Backtrace instance. The Backtrace instance is where the application trace is parsed out, so it's necessary if you want to approximate our default server-side fingerprint client-side. The return value of notice.backtrace was an intentional choice. Users understand a Ruby backtrace object; they understand a Honeybadger backtrace object less. Unfortunately, having access to the additional information contained in the Backtrace object would be useful here.
With this background information in mind, here's how you'd approximate our default Ruby fingerprint on the client-side today:
# config/initializers/honeybadger.rb
Honeybadger.configure do |config|
config.before_notify do |notice|
backtrace = Honeybadger::Backtrace.parse(
notice.backtrace,
filters: Honeybadger::Notice::BACKTRACE_FILTERS,
config: Honeybadger.config
)
l = backtrace.application_lines.first || backtrace.lines.first
notice.fingerprint = [notice.error_class,
notice.component, "#{l&.filtered_file}:#{l&.filtered_method}:#{l&.filtered_number}"].join(":")
end
end
As you can see, this depends on internal APIs, which are currently private. The goal of this issue is to implement a public feature for this advanced use case, without complicating the default experience. There are a few ways we could go—this introduction is intended to start the discussion.