We often have an error with a few thousand occurances and want to find out which code paths caused it.
Usage
Use auth-token from settings page, not your api-key.
ruby airbrake_backtraces.rb your-account your-auth-token error-id
Output
Trace 1: occurred 597 times ...funky backtraces... Trace 2: occurred 119 times ...funky backtraces... Trace 3: occurred 13 times ...funky backtraces...
Code
#! /usr/bin/env ruby
# lists all sources of a given error
# https://grosser.it/2012/09/08/airbrake-error-summary
#
# gem install airbrake-api
# USAGE: ruby airbrake_backtraces.rb your-account your-auth-token error-id
# https://your-account.airbrake.io/errors/ID
require "airbrake-api"
AirbrakeAPI.account = ARGV[0] || raise("need airbrake account as ARGV[0]")
AirbrakeAPI.auth_token = ARGV[1] || raise("need airbrake token as ARGV[1], go to airbrake -> settings, copy your auth token")
AirbrakeAPI.secure = true
error_id = ARGV[2] || raise("need error id")
compare_depth = (ARGV[3] || 4).to_i
notices = AirbrakeAPI.notices(error_id, :pages => 20)
backtraces = notices.select{|n| n.backtrace }.group_by do |notice|
notice.backtrace.first[1][0..compare_depth]
end
backtraces.sort_by{|k,t| t.size }.reverse.each_with_index do |(key, traces), index|
puts "Trace #{index + 1}: occurred #{traces.size} times"
puts key
puts ""
end