event-reporting-handler 0.1.11 → 0.1.13
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0f4f0c775e3fec7b961f4ebc74dbc6ce02dd844f
|
4
|
+
data.tar.gz: e897db6be1413c14a9b5e11114a6f37fafe235c0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: a6da9d937ea4aff4e30ce408ac78755fed97d7536290dd8752e141577e2a06b753476a742017f0326644725e936282ffce176b26e44c19addad0136f2f3578ee
|
7
|
+
data.tar.gz: 9ebc9ea704fdcebb9fc74cecce1a086a13e181d3e85a6de33e0e9edda3a35dad0bb605ae8348bcfa3694ec576820a96a759fa86b8cbefa901c91332123e8cece
|
data/README.md
CHANGED
@@ -1,27 +1,30 @@
|
|
1
|
-
#
|
1
|
+
# event-reporting-handler
|
2
2
|
|
3
3
|
Chef handler to send chef run events to a http url. Also reports chef run failures to sentry.
|
4
4
|
|
5
|
-
##
|
5
|
+
## Usage
|
6
6
|
|
7
|
-
|
7
|
+
StartHandler class requires two arguments to construct an object, a http url to send chef run events and a sentry config. The sentry config is a hash that should atleast include sentry dsn to send messages on a chef run failure.
|
8
8
|
|
9
|
+
The simplest way to use 'event-reporting-handler' is by adding 'event-reporting-handler' as start handler using [chef client cookbook](https://github.com/chef-cookbooks/chef-client).
|
10
|
+
For example,
|
9
11
|
```ruby
|
10
|
-
|
12
|
+
node.default['chef_client']['load_gems']['sentry-raven'] = {
|
13
|
+
:version => '0.9.4'
|
14
|
+
}
|
15
|
+
node.default['chef_client']['load_gems']['event-reporting-handler'] = {
|
16
|
+
:require_name => 'event_reporting_handler',
|
17
|
+
:version => '0.1.11'
|
18
|
+
}
|
19
|
+
|
20
|
+
node.default['chef_client']['config']['start_handlers'] = [
|
21
|
+
{
|
22
|
+
:class => "BloombergLP::EventReportingHandler::StartHandler",
|
23
|
+
:arguments => [ some_http_url, {dsn: some_sentry_dsn }]
|
24
|
+
}
|
25
|
+
]
|
11
26
|
```
|
12
27
|
|
13
|
-
And then execute:
|
14
|
-
|
15
|
-
$ bundle
|
16
|
-
|
17
|
-
Or install it yourself as:
|
18
|
-
|
19
|
-
$ gem install chef-events-handler
|
20
|
-
|
21
|
-
## Usage
|
22
|
-
|
23
|
-
|
24
|
-
|
25
28
|
## Contributing
|
26
29
|
|
27
30
|
Bug reports and pull requests are welcome on GitHub at https://github.com/sh9189/chef-events-handler.
|
@@ -3,13 +3,16 @@
|
|
3
3
|
# Copyright 2015, Bloomberg Finance L.P.
|
4
4
|
#
|
5
5
|
require 'chef/event_dispatch/base'
|
6
|
+
require 'chef/whitelist'
|
6
7
|
require 'raven'
|
7
8
|
|
9
|
+
|
8
10
|
module BloombergLP
|
9
11
|
module EventReportingHandler
|
10
12
|
class HttpEventReporter < Chef::EventDispatch::Base
|
11
|
-
def initialize(
|
12
|
-
@http_url =
|
13
|
+
def initialize(http_config, sentry_config, run_status)
|
14
|
+
@http_url = http_config['url']
|
15
|
+
@whitelist_attributes = Chef::Whitelist.filter(node, http_config['whitelist_attributes'])
|
13
16
|
@node = run_status.node
|
14
17
|
Raven.configure(true) do |config|
|
15
18
|
config.ssl_verification = sentry_config['verify_ssl'] || true
|
@@ -58,7 +61,7 @@ module BloombergLP
|
|
58
61
|
end
|
59
62
|
|
60
63
|
def publish_event(event, custom_attributes = {})
|
61
|
-
json_to_publish = get_json_from_event(event, custom_attributes)
|
64
|
+
json_to_publish = get_json_from_event(event, custom_attributes.merge(whitelist_attributes))
|
62
65
|
uri = URI(@http_url)
|
63
66
|
res = Net::HTTP.start(uri.host, uri.port) do |http|
|
64
67
|
http.post(uri.path, json_to_publish, 'Content-Type' => 'application/json')
|
@@ -8,14 +8,14 @@ require 'chef/handler'
|
|
8
8
|
module BloombergLP
|
9
9
|
module EventReportingHandler
|
10
10
|
class StartHandler < Chef::Handler
|
11
|
-
def initialize(
|
12
|
-
@
|
11
|
+
def initialize(http_config = {}, sentry_config = {})
|
12
|
+
@http_config = http_config
|
13
13
|
@sentry_config = sentry_config
|
14
14
|
end
|
15
15
|
|
16
16
|
def report
|
17
|
-
Chef::Log.debug("Running start handler with
|
18
|
-
http_event_reporter = HttpEventReporter.new(@
|
17
|
+
Chef::Log.debug("Running start handler with http_config: #{@http_config} sentry_config: #{@sentry_config} ")
|
18
|
+
http_event_reporter = HttpEventReporter.new(@http_config, @sentry_config, @run_status)
|
19
19
|
@run_status.events.register(http_event_reporter)
|
20
20
|
end
|
21
21
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: event-reporting-handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.13
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shahul Khajamohideen
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date:
|
11
|
+
date: 2016-01-27 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: bundler
|
@@ -106,7 +106,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
106
106
|
version: '0'
|
107
107
|
requirements: []
|
108
108
|
rubyforge_project:
|
109
|
-
rubygems_version: 2.
|
109
|
+
rubygems_version: 2.5.1
|
110
110
|
signing_key:
|
111
111
|
specification_version: 4
|
112
112
|
summary: Chef handler to send events to http url. Also sends chef run failures to
|