Class: BloombergLP::EventReportingHandler::HttpEventReporter
- Inherits:
-
Chef::EventDispatch::Base
- Object
- Chef::EventDispatch::Base
- BloombergLP::EventReportingHandler::HttpEventReporter
- Defined in:
- lib/event_reporting_handler/http_event_reporter.rb
Instance Method Summary collapse
-
#initialize(http_config, sentry_config, run_status) ⇒ HttpEventReporter
constructor
A new instance of HttpEventReporter.
-
#run_completed(_node) ⇒ Object
Called at the end a successful Chef run.
-
#run_failed(exception) ⇒ Object
Called at the end of a failed Chef run.
- #run_started(run_status) ⇒ Object
Constructor Details
#initialize(http_config, sentry_config, run_status) ⇒ HttpEventReporter
Returns a new instance of HttpEventReporter.
13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 13 def initialize(http_config, sentry_config, run_status) @http_url = http_config['url'] @whitelist_attributes = Chef::Whitelist.filter(node, http_config['whitelist_attributes']) @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.
35 36 37 |
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 35 def run_completed(_node) publish_event(:run_completed) end |
#run_failed(exception) ⇒ Object
Called at the end of a failed Chef run.
40 41 42 43 |
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 40 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
28 29 30 31 32 |
# File 'lib/event_reporting_handler/http_event_reporter.rb', line 28 def run_started(run_status) @chef_run_id = run_status.run_id @node_fqdn = @node.name publish_event(:run_started) end |