Class: Adhearsion::Reporter::AirbrakeNotifier

Inherits:
Object
  • Object
show all
Includes:
Singleton
Defined in:
lib/adhearsion/reporter/airbrake_notifier.rb

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.method_missing(m, *args, &block) ⇒ Object



38
39
40
# File 'lib/adhearsion/reporter/airbrake_notifier.rb', line 38

def self.method_missing(m, *args, &block)
  instance.send m, *args, &block
end

Instance Method Details

#initObject



12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/adhearsion/reporter/airbrake_notifier.rb', line 12

def init
  @notifier = Toadhopper.new Reporter.config.api_key, :notify_host => Reporter.config.url
  @options = {
    framework_env: Adhearsion.config.platform.environment,
    notifier_name: 'adhearsion-reporter',
    notifier_version: Adhearsion::Reporter::VERSION,
    project_root: Adhearsion.config.platform[:root],
    environment: {
      'HOSTNAME' => Socket.gethostname,
      'AHN_VERSION' => Adhearsion::VERSION
    }
  }
end

#notify(ex) ⇒ Object



26
27
28
29
30
31
32
33
34
35
36
# File 'lib/adhearsion/reporter/airbrake_notifier.rb', line 26

def notify(ex)
  return unless should_post?
  response = @notifier.post!(ex, @options)
  if !response.errors.empty? || !(200..299).include?(response.status.to_i)
    logger.error "Error posting exception to #{Reporter.config.url}! Response code #{response.status}"
    response.errors.each do |error|
      logger.error "#{error}"
    end
    logger.warn "Original exception message: #{ex.message}"
  end
end