Class: Denouncer::Notifiers::AirbrakeNotifier

Inherits:
BaseNotifier
  • Object
show all
Defined in:
lib/denouncer/notifiers/airbrake_notifier.rb

Instance Attribute Summary

Attributes inherited from BaseNotifier

#config

Instance Method Summary collapse

Methods inherited from BaseNotifier

#get_current_timestamp, #get_error_cause, #initialize

Constructor Details

This class inherits a constructor from Denouncer::Notifiers::BaseNotifier

Instance Method Details

#nameString

Returns:

  • (String)


9
10
11
# File 'lib/denouncer/notifiers/airbrake_notifier.rb', line 9

def name
  'airbrake'
end

#notify(error, metadata = nil) ⇒ Object

Sends an error notification via amqp.

Parameters:

  • error (StandardError)
  • metadata (Hash) (defaults to: nil)


26
27
28
29
30
31
32
# File 'lib/denouncer/notifiers/airbrake_notifier.rb', line 26

def notify(error,  = nil)
  Airbrake.notify(error,
    api_key: config[:api_key],
    error_message: error.message,
    backtrace: error.backtrace
  )
end

#set_configuration!(options) ⇒ Object



13
14
15
16
17
18
19
20
# File 'lib/denouncer/notifiers/airbrake_notifier.rb', line 13

def set_configuration!(options)
  raise "Airbrake configuration error: :api_key is nil!" if options[:api_key].nil?
  require 'airbrake'
  Airbrake.configure do |config|
    config.api_key = options[:api_key]
  end
  return options
end