Class: BloombergLP::EventReportingHandler::HttpEventReporter

Inherits:
Chef::EventDispatch::Base
  • Object
show all
Defined in:
lib/event_reporting_handler/http_event_reporter.rb

Instance Method Summary collapse

Constructor Details

#initialize(http_url, sentry_config, run_status) ⇒ HttpEventReporter

Returns a new instance of HttpEventReporter.



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

def initialize(http_url,sentry_config,run_status)
  @http_url = http_url
  @node = run_status.node
  Raven.configure(true) do |config|
    config.ssl_verification = sentry_config['verify_ssl'] || true
    config.dsn = sentry_config['dsn']
    config.logger = ::Chef::Log
    config.current_environment = node.chef_environment
    config.environments = [node.chef_environment]
    config.send_modules = Gem::Specification.respond_to?(:map)
  end
  Raven.logger.debug "Raven ready to report errors"
end

Instance Method Details

#run_completed(node) ⇒ Object

Called at the end a successful Chef run.



34
35
36
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 34

def run_completed(node)
  publish_event(:run_completed)
end

#run_failed(exception) ⇒ Object

Called at the end of a failed Chef run.



39
40
41
42
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 39

def run_failed(exception)
  sentry_event_id = report_to_sentry(exception)
  publish_event(:run_failed, {sentry_event_id: sentry_event_id})
end

#run_started(run_status) ⇒ Object



26
27
28
29
30
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 26

def run_started(run_status)
  @chef_run_id = run_status.run_id
  @node_fqdn = @node.name
  publish_event(:run_started)
end