Send a correct backtrace and some other nice things to airbrake on resque errors
This commit is contained in:
parent
a2bfc4a487
commit
1df654d416
2 changed files with 14 additions and 10 deletions
|
|
@ -10,33 +10,37 @@ module ResqueJobLogging
|
|||
error = e
|
||||
end
|
||||
}*1000
|
||||
|
||||
log_string += "ms=#{time} "
|
||||
args.each_with_index{|arg,idx| log_string += "arg#{idx.succ}=\"#{arg.to_s[0..30]}\" "}
|
||||
|
||||
if error
|
||||
log_string += "status=error "
|
||||
log_string << "error_class=#{error.class} error_message='#{error.message}' "
|
||||
log_string << "orig_error_message='#{error.original_error.message}'" if error.respond_to?(:original_error)
|
||||
log_string << "annotated_source='#{error.annoted_source_code.to_s}' " if error.respond_to?(:annoted_source_code)
|
||||
log_string << "app_backtrace='#{application_trace(error).join(";")}' "
|
||||
backtrace = application_trace(error)
|
||||
log_string << "app_backtrace='#{backtrace.join(";")}' "
|
||||
notify_hoptoad(error, args, backtrace) if AppConfig[:hoptoad_api_key].present?
|
||||
else
|
||||
log_string += "status=complete "
|
||||
end
|
||||
log_string += "ms=#{time} "
|
||||
args.each_with_index{|arg,idx| log_string += "arg#{idx.succ}=\"#{arg.to_s[0..30]}\" "}
|
||||
|
||||
Rails.logger.info(log_string)
|
||||
if error
|
||||
notify_hoptoad(error, args) if AppConfig[:hoptoad_api_key].present?
|
||||
raise error
|
||||
end
|
||||
raise error if error
|
||||
end
|
||||
|
||||
def notify_hoptoad(error, job_arguments)
|
||||
def notify_hoptoad(error, job_arguments, backtrace)
|
||||
puts "Notifying hoptoad"
|
||||
HoptoadNotifier.notify(
|
||||
:error_class => error.class,
|
||||
:error_message => error.message,
|
||||
:backtrace => backtrace,
|
||||
:parameters => {
|
||||
:job_class => self.name,
|
||||
:arguments => job_arguments.map!{|a| a.to_s[0..30]}
|
||||
:arguments => job_arguments.map!{|a| a.to_s[0..30]},
|
||||
:controller => "Resque",
|
||||
:action => self.name
|
||||
}
|
||||
) if Rails.env.production?
|
||||
end
|
||||
|
|
|
|||
|
|
@ -34,7 +34,7 @@ describe ResqueJobLogging do
|
|||
Rails.logger.should_receive(:info)
|
||||
AppConfig.should_receive(:[]).with(:hoptoad_api_key).and_return("what")
|
||||
error = RuntimeError.new("GRAAAAAAAAAGH")
|
||||
ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error, ["stuff"])
|
||||
ResqueJobLoggingDummy.should_receive(:notify_hoptoad).with(error, ["stuff"], anything)
|
||||
proc {
|
||||
ResqueJobLoggingDummy.around_perform_log_job("stuff"){raise error }
|
||||
}.should raise_error
|
||||
|
|
|
|||
Loading…
Reference in a new issue