event-reporting-handler 0.1.7 → 0.1.8
Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 32e9440fdc8f06399a819f19b8aee99da4de05af
|
4
|
+
data.tar.gz: 2695f1a86ac60276230edef0ae7c73eef44fecc5
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 7a1a2849d779a4e8f4995045f0a0661193990757c62f23337103aa76478bb13f3b711e33ccce515e507e30cf728bfc3ed5aa76471d67c34a4d7537063ec20f1f
|
7
|
+
data.tar.gz: 4cf32e35c3ce33bf6504a2e68bce43d20ce8eed7a0f210b59d374a62ae60580e9d8330e89ff2b7316d22757190a8d5393a144ee856ecfc3a80323a31bbc82a40
|
data/.rubocop.yml
ADDED
@@ -0,0 +1,44 @@
|
|
1
|
+
---
|
2
|
+
AllCops:
|
3
|
+
Exclude:
|
4
|
+
- 'Guardfile'
|
5
|
+
- 'Rakefile'
|
6
|
+
- 'Vagrantfile'
|
7
|
+
- 'Policyfile.rb'
|
8
|
+
- 'Berksfile'
|
9
|
+
- 'Thorfile'
|
10
|
+
- 'Gemfile'
|
11
|
+
- 'metadata.rb'
|
12
|
+
- 'test/**/*'
|
13
|
+
- 'bin/**'
|
14
|
+
- 'vendor/**/*'
|
15
|
+
AlignParameters:
|
16
|
+
Enabled: false
|
17
|
+
ClassLength:
|
18
|
+
Enabled: false
|
19
|
+
CyclomaticComplexity:
|
20
|
+
Enabled: false
|
21
|
+
Documentation:
|
22
|
+
Enabled: false
|
23
|
+
Encoding:
|
24
|
+
Enabled: false
|
25
|
+
Style/FileName:
|
26
|
+
Enabled: false
|
27
|
+
LineLength:
|
28
|
+
Enabled: false
|
29
|
+
MethodLength:
|
30
|
+
Enabled: false
|
31
|
+
Metrics/AbcSize:
|
32
|
+
Enabled: false
|
33
|
+
PerceivedComplexity:
|
34
|
+
Enabled: false
|
35
|
+
SingleSpaceBeforeFirstArg:
|
36
|
+
Enabled: false
|
37
|
+
Style/ClassAndModuleChildren:
|
38
|
+
Enabled: false
|
39
|
+
Style/FileName:
|
40
|
+
Enabled: false
|
41
|
+
Style/GuardClause:
|
42
|
+
Enabled: false
|
43
|
+
Style/PercentLiteralDelimiters:
|
44
|
+
Enabled: false
|
@@ -4,24 +4,22 @@ $LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
|
4
4
|
require 'event_reporting_handler/version'
|
5
5
|
|
6
6
|
Gem::Specification.new do |spec|
|
7
|
-
spec.name =
|
7
|
+
spec.name = 'event-reporting-handler'
|
8
8
|
spec.version = BloombergLP::EventReportingHandler::VERSION
|
9
|
-
spec.authors = [
|
10
|
-
spec.email = [
|
9
|
+
spec.authors = ['Shahul Khajamohideen']
|
10
|
+
spec.email = ['skhajamohid1@bloomberg.net']
|
11
11
|
|
12
|
-
spec.summary =
|
12
|
+
spec.summary = 'Chef handler to send events to http url. Also sends chef run failures to sentry'
|
13
13
|
spec.description = spec.summary
|
14
|
-
spec.homepage =
|
15
|
-
|
14
|
+
spec.homepage = 'https://github.com/sh9189/event-reporting-handler'
|
16
15
|
|
17
16
|
spec.files = `git ls-files -z`.split("\x0").reject { |f| f.match(%r{^(test|spec|features)/}) }
|
18
|
-
spec.bindir = "exe"
|
19
17
|
spec.executables = spec.files.grep(%r{^exe/}) { |f| File.basename(f) }
|
20
|
-
spec.require_paths = [
|
18
|
+
spec.require_paths = ['lib']
|
21
19
|
|
22
|
-
spec.add_development_dependency
|
23
|
-
spec.add_development_dependency
|
24
|
-
spec.add_development_dependency
|
20
|
+
spec.add_development_dependency 'bundler', '~> 1.10'
|
21
|
+
spec.add_development_dependency 'rake', '~> 10.0'
|
22
|
+
spec.add_development_dependency 'rspec'
|
25
23
|
|
26
|
-
spec.add_runtime_dependency 'sentry-raven', '~> 0.
|
24
|
+
spec.add_runtime_dependency 'sentry-raven', '~> 0.9.4'
|
27
25
|
end
|
@@ -8,48 +8,47 @@ require 'raven'
|
|
8
8
|
module BloombergLP
|
9
9
|
module EventReportingHandler
|
10
10
|
class HttpEventReporter < Chef::EventDispatch::Base
|
11
|
+
def initialize(http_url, sentry_config, run_status)
|
12
|
+
@http_url = http_url
|
13
|
+
@node = run_status.node
|
14
|
+
Raven.configure(true) do |config|
|
15
|
+
config.ssl_verification = sentry_config['verify_ssl'] || true
|
16
|
+
config.dsn = sentry_config['dsn']
|
17
|
+
config.logger = ::Chef::Log
|
18
|
+
config.current_environment = node.chef_environment
|
19
|
+
config.environments = [node.chef_environment]
|
20
|
+
config.send_modules = Gem::Specification.respond_to?(:map)
|
21
|
+
end
|
22
|
+
Raven.logger.debug 'Raven ready to report errors'
|
23
|
+
end
|
11
24
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
config.dsn = sentry_config['dsn']
|
18
|
-
config.logger = ::Chef::Log
|
19
|
-
config.current_environment = node.chef_environment
|
20
|
-
config.environments = [node.chef_environment]
|
21
|
-
config.send_modules = Gem::Specification.respond_to?(:map)
|
22
|
-
end
|
23
|
-
Raven.logger.debug "Raven ready to report errors"
|
24
|
-
end
|
25
|
-
|
26
|
-
def run_started(run_status)
|
27
|
-
@chef_run_id = run_status.run_id
|
28
|
-
@node_fqdn = @node.name
|
29
|
-
publish_event(:run_started)
|
30
|
-
end
|
31
|
-
|
25
|
+
def run_started(run_status)
|
26
|
+
@chef_run_id = run_status.run_id
|
27
|
+
@node_fqdn = @node.name
|
28
|
+
publish_event(:run_started)
|
29
|
+
end
|
32
30
|
|
33
|
-
|
34
|
-
def run_completed(
|
31
|
+
# Called at the end a successful Chef run.
|
32
|
+
def run_completed(_node)
|
35
33
|
publish_event(:run_completed)
|
36
34
|
end
|
37
35
|
|
38
36
|
# Called at the end of a failed Chef run.
|
39
37
|
def run_failed(exception)
|
40
38
|
sentry_event_id = report_to_sentry(exception)
|
41
|
-
publish_event(:run_failed,
|
39
|
+
publish_event(:run_failed, sentry_event_id: sentry_event_id)
|
42
40
|
end
|
43
41
|
|
44
42
|
private
|
43
|
+
|
45
44
|
def report_to_sentry(exception)
|
46
|
-
Raven.logger.info
|
45
|
+
Raven.logger.info 'Logging run failure to Sentry server'
|
47
46
|
if exception
|
48
47
|
evt = Raven::Event.capture_exception(exception)
|
49
48
|
else
|
50
|
-
evt = Raven::Event.new do |
|
51
|
-
|
52
|
-
|
49
|
+
evt = Raven::Event.new do |event|
|
50
|
+
event.message = 'Unknown error during Chef run'
|
51
|
+
event.level = :error
|
53
52
|
end
|
54
53
|
end
|
55
54
|
# Use the node name, not the FQDN
|
@@ -58,9 +57,8 @@ module BloombergLP
|
|
58
57
|
evt.id
|
59
58
|
end
|
60
59
|
|
61
|
-
|
62
|
-
|
63
|
-
json_to_publish = get_json_from_event(event,custom_attributes)
|
60
|
+
def publish_event(event, custom_attributes)
|
61
|
+
json_to_publish = get_json_from_event(event, custom_attributes)
|
64
62
|
uri = URI(@http_url)
|
65
63
|
res = Net::HTTP.start(uri.host, uri.port) do |http|
|
66
64
|
http.post(uri.path, json_to_publish, 'Content-Type' => 'application/json')
|
@@ -73,12 +71,10 @@ module BloombergLP
|
|
73
71
|
end
|
74
72
|
end
|
75
73
|
|
76
|
-
def get_json_from_event(event,custom_attributes)
|
74
|
+
def get_json_from_event(event, custom_attributes)
|
77
75
|
event = { deploy_event: { node_fqdn: @node_fqdn, sub_type: event, occurred_at: Time.now.to_s } }
|
78
76
|
event.merge(custom_attributes).to_json
|
79
77
|
end
|
80
|
-
|
81
|
-
|
82
78
|
end
|
83
79
|
end
|
84
80
|
end
|
@@ -8,19 +8,17 @@ require 'chef/handler'
|
|
8
8
|
module BloombergLP
|
9
9
|
module EventReportingHandler
|
10
10
|
class StartHandler < Chef::Handler
|
11
|
-
|
12
|
-
def initialize(http_url='',sentry_config={})
|
11
|
+
def initialize(http_url = '', sentry_config = {})
|
13
12
|
@http_url = http_url
|
14
13
|
@sentry_config = sentry_config
|
15
14
|
end
|
16
15
|
|
17
16
|
def report
|
18
17
|
Chef::Log.debug("Running start handler with http_url: #{@http_url} and sentry_config: #{@sentry_config} ")
|
19
|
-
http_event_reporter = HttpEventReporter.new(@http_url
|
18
|
+
http_event_reporter = HttpEventReporter.new(@http_url, @sentry_config, @run_status)
|
20
19
|
@run_status.events.register(http_event_reporter)
|
21
20
|
http_event_reporter.run_started(@run_status)
|
22
21
|
end
|
23
|
-
|
24
22
|
end
|
25
23
|
end
|
26
24
|
end
|
metadata
CHANGED
@@ -1,12 +1,12 @@
|
|
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.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Shahul Khajamohideen
|
8
8
|
autorequire:
|
9
|
-
bindir:
|
9
|
+
bindir: bin
|
10
10
|
cert_chain: []
|
11
11
|
date: 2015-12-21 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
@@ -58,14 +58,14 @@ dependencies:
|
|
58
58
|
requirements:
|
59
59
|
- - "~>"
|
60
60
|
- !ruby/object:Gem::Version
|
61
|
-
version: 0.
|
61
|
+
version: 0.9.4
|
62
62
|
type: :runtime
|
63
63
|
prerelease: false
|
64
64
|
version_requirements: !ruby/object:Gem::Requirement
|
65
65
|
requirements:
|
66
66
|
- - "~>"
|
67
67
|
- !ruby/object:Gem::Version
|
68
|
-
version: 0.
|
68
|
+
version: 0.9.4
|
69
69
|
description: Chef handler to send events to http url. Also sends chef run failures
|
70
70
|
to sentry
|
71
71
|
email:
|
@@ -76,6 +76,7 @@ extra_rdoc_files: []
|
|
76
76
|
files:
|
77
77
|
- ".gitignore"
|
78
78
|
- ".rspec"
|
79
|
+
- ".rubocop.yml"
|
79
80
|
- ".travis.yml"
|
80
81
|
- Gemfile
|
81
82
|
- LICENSE
|