process_handler 2.3.0 → 3.0.0
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 +4 -4
- data/Gemfile +1 -1
- data/lib/salemove/process_handler/cron_process.rb +1 -3
- data/lib/salemove/process_handler/notifier_factory.rb +19 -12
- data/lib/salemove/process_handler/pivot_process.rb +2 -14
- data/lib/salemove/process_handler/version.rb +1 -1
- data/process_handler.gemspec +2 -1
- data/spec/process_handler/airbrake_spec.rb +46 -48
- metadata +19 -5
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 3e495c8a8ec6bf3798941bd11f2792b9a28f1c95
|
4
|
+
data.tar.gz: 8923ae242c65ba6120b48184588b2534060ff831
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 337003df5486731c3b8addbb93e85159e664f20996fda1b22252e111d09831a1b735b3962f242f3f1ec44c88340025ca80356ebf468a1f610be5bc96b2870812
|
7
|
+
data.tar.gz: 33b8e7e9d3d0f4368a53f11610449b0e5394177cf286495a52d843885e077425d3ff486621ae9a107c8ad2e05e91ec3550b7bea80f79b4de5436c5049379bfc4
|
data/Gemfile
CHANGED
@@ -8,19 +8,20 @@ module Salemove
|
|
8
8
|
|
9
9
|
def self.get_notifier(process_name, conf)
|
10
10
|
if conf && conf[:type] == 'airbrake'
|
11
|
-
|
12
|
-
|
13
|
-
airbrake.
|
14
|
-
airbrake.secure = true
|
11
|
+
notifier_name = conf[:notifier_name] || :default
|
12
|
+
Airbrake.configure(notifier_name) do |airbrake|
|
13
|
+
airbrake.environment = conf.fetch(:environment)
|
15
14
|
airbrake.host = conf.fetch(:host)
|
16
|
-
airbrake.
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
15
|
+
airbrake.project_id = conf.fetch(:project_id)
|
16
|
+
airbrake.project_key = conf.fetch(:project_key)
|
17
|
+
airbrake.ignore_environments = conf[:ignore_environments] if conf[:ignore_environments]
|
18
|
+
airbrake.whitelist_keys = [
|
19
|
+
/_HOST$/, /_TCP$/, /_UDP$/, /_PROTO$/, /_ADDR$/, 'PWD',
|
20
|
+
'GEM_HOME', 'PATH', 'SERVICE_NAME', 'RUBY_MAJOR', 'RUBY_VERSION',
|
21
|
+
'RACK_ENV', 'RUN_ENV', 'HOME', 'RUBYGEMS_VERSION', 'BUNDLER_VERSION'
|
22
|
+
]
|
22
23
|
end
|
23
|
-
|
24
|
+
AirbrakeNotifier.new
|
24
25
|
elsif conf && conf[:type] == 'growl'
|
25
26
|
GrowlNotifier.new(process_name)
|
26
27
|
elsif conf && conf[:type] == 'terminal-notifier'
|
@@ -29,13 +30,19 @@ module Salemove
|
|
29
30
|
end
|
30
31
|
end
|
31
32
|
|
33
|
+
class AirbrakeNotifier
|
34
|
+
def notify_or_ignore(error, params)
|
35
|
+
Airbrake.notify(error, params)
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
32
39
|
class GrowlNotifier
|
33
40
|
def initialize(process_name)
|
34
41
|
@process_name = process_name
|
35
42
|
end
|
36
43
|
|
37
44
|
def notify_or_ignore(error, _)
|
38
|
-
Growl.notify
|
45
|
+
Growl.notify(error.message, title: "Error in #{@process_name}")
|
39
46
|
end
|
40
47
|
end
|
41
48
|
|
@@ -113,13 +113,7 @@ module Salemove
|
|
113
113
|
message = [exception.inspect, *exception.backtrace].join("\n")
|
114
114
|
@logger.error(message, input)
|
115
115
|
|
116
|
-
if @exception_notifier
|
117
|
-
@exception_notifier.notify_or_ignore(
|
118
|
-
exception,
|
119
|
-
cgi_data: ENV.to_hash,
|
120
|
-
parameters: input
|
121
|
-
)
|
122
|
-
end
|
116
|
+
@exception_notifier.notify_or_ignore(exception, input) if @exception_notifier
|
123
117
|
end
|
124
118
|
end
|
125
119
|
|
@@ -207,13 +201,7 @@ module Salemove
|
|
207
201
|
message = [exception.inspect, *exception.backtrace].join("\n")
|
208
202
|
@logger.error(message, input)
|
209
203
|
|
210
|
-
if @exception_notifier
|
211
|
-
@exception_notifier.notify_or_ignore(
|
212
|
-
exception,
|
213
|
-
cgi_data: ENV.to_hash,
|
214
|
-
parameters: input
|
215
|
-
)
|
216
|
-
end
|
204
|
+
@exception_notifier.notify_or_ignore(exception, input) if @exception_notifier
|
217
205
|
|
218
206
|
{ success: false, error: exception.message }
|
219
207
|
end
|
data/process_handler.gemspec
CHANGED
@@ -18,7 +18,8 @@ Gem::Specification.new do |spec|
|
|
18
18
|
spec.test_files = spec.files.grep(%r{^(test|spec|features)/})
|
19
19
|
spec.require_paths = ["lib"]
|
20
20
|
|
21
|
-
spec.add_dependency 'airbrake', '~> 4
|
21
|
+
spec.add_dependency 'airbrake', '~> 7.4'
|
22
|
+
spec.add_dependency 'timers', '~> 4.1.2'
|
22
23
|
spec.add_dependency 'sucker_punch', '~> 1.1' # for async airbrake notifications
|
23
24
|
spec.add_dependency 'growl'
|
24
25
|
spec.add_dependency 'terminal-notifier'
|
@@ -1,63 +1,61 @@
|
|
1
1
|
require 'spec_helper'
|
2
|
-
require 'airbrake'
|
3
|
-
require 'airbrake/notice'
|
4
2
|
require 'salemove/process_handler/notifier_factory'
|
3
|
+
require 'securerandom'
|
5
4
|
|
6
5
|
describe 'Airbrake configuration' do
|
7
|
-
|
8
|
-
let
|
9
|
-
let
|
10
|
-
let
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
# Uses Airbrake configuration's 'params_whitelist_filters' param for filtering
|
21
|
-
describe 'whitelist filtering' do
|
22
|
-
|
23
|
-
let (:custom_notice_args) {
|
24
|
-
{
|
25
|
-
:params_filters => [], # Remove blacklist to test whitelist
|
26
|
-
:parameters => {
|
27
|
-
'API_PORT_80_TCP_PROTO' => 'tcp',
|
28
|
-
'HOME' => '/home/sm',
|
29
|
-
'SECRET_PASS' => 'Parool123',
|
30
|
-
'SOME_PROTO_KEY' => 'value',
|
31
|
-
'PROTO_KEY' => 'abc123'
|
32
|
-
},
|
33
|
-
:cgi_data => {
|
34
|
-
'HTTP_HOST' => 'localhost:3001',
|
35
|
-
'RANDOM' => 'value',
|
36
|
-
'HOME' => 'sweet home'
|
37
|
-
}
|
38
|
-
}
|
6
|
+
let(:environment) { 'SOME_ENVIRONMENT' }
|
7
|
+
let(:config) { airbrake_config.merge(type: 'airbrake') }
|
8
|
+
let(:airbrake_config) { base_params }
|
9
|
+
let(:base_params) do
|
10
|
+
{
|
11
|
+
environment: environment,
|
12
|
+
host: 'localhost',
|
13
|
+
project_id: '123456',
|
14
|
+
project_key: 'abc123',
|
15
|
+
ignore_environments: ['dev'],
|
16
|
+
# Airbrake module raises an error when same notifier configured multiple times
|
17
|
+
# Provide a random notifier name for each test case
|
18
|
+
notifier_name: SecureRandom.hex
|
39
19
|
}
|
20
|
+
end
|
21
|
+
let(:airbrake) do
|
22
|
+
ProcessHandler::NotifierFactory.get_notifier('Process name', config)
|
23
|
+
end
|
40
24
|
|
41
|
-
|
42
|
-
|
43
|
-
expect
|
25
|
+
context 'when all params set' do
|
26
|
+
it 'does not raise an error' do
|
27
|
+
expect { airbrake }.not_to raise_error
|
44
28
|
end
|
29
|
+
end
|
45
30
|
|
46
|
-
|
47
|
-
|
48
|
-
expect(notice[:cgi_data]['HOME']).to eq 'sweet home'
|
49
|
-
end
|
31
|
+
context 'when project_id is not a number' do
|
32
|
+
let(:airbrake_config) { base_params.merge(project_id: 'abc') }
|
50
33
|
|
51
|
-
it '
|
52
|
-
expect
|
53
|
-
expect(notice[:parameters]['SOME_PROTO_KEY']).to eq filtered
|
54
|
-
expect(notice[:parameters]['PROTO_KEY']).to eq filtered
|
55
|
-
expect(notice[:cgi_data]['RANDOM']).to eq filtered
|
34
|
+
it 'raises error' do
|
35
|
+
expect { airbrake }.to raise_error
|
56
36
|
end
|
37
|
+
end
|
57
38
|
|
39
|
+
context 'when ignore_environments missing' do
|
40
|
+
before { base_params.delete(:ignore_environments) }
|
41
|
+
|
42
|
+
it 'does not raise an error' do
|
43
|
+
expect { airbrake }.not_to raise_error
|
44
|
+
end
|
58
45
|
end
|
59
46
|
|
60
|
-
|
61
|
-
|
47
|
+
shared_examples_for 'raises error if config param missing' do |key|
|
48
|
+
context "when #{key} missing" do
|
49
|
+
before { base_params.delete(key) }
|
50
|
+
|
51
|
+
it 'raises error' do
|
52
|
+
expect { airbrake }.to raise_error
|
53
|
+
end
|
54
|
+
end
|
62
55
|
end
|
56
|
+
|
57
|
+
it_behaves_like 'raises error if config param missing', :environment
|
58
|
+
it_behaves_like 'raises error if config param missing', :host
|
59
|
+
it_behaves_like 'raises error if config param missing', :project_id
|
60
|
+
it_behaves_like 'raises error if config param missing', :project_key
|
63
61
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: process_handler
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version:
|
4
|
+
version: 3.0.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- SaleMove TechMovers
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2018-
|
11
|
+
date: 2018-11-16 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: airbrake
|
@@ -16,14 +16,28 @@ dependencies:
|
|
16
16
|
requirements:
|
17
17
|
- - "~>"
|
18
18
|
- !ruby/object:Gem::Version
|
19
|
-
version: '4
|
19
|
+
version: '7.4'
|
20
20
|
type: :runtime
|
21
21
|
prerelease: false
|
22
22
|
version_requirements: !ruby/object:Gem::Requirement
|
23
23
|
requirements:
|
24
24
|
- - "~>"
|
25
25
|
- !ruby/object:Gem::Version
|
26
|
-
version: '4
|
26
|
+
version: '7.4'
|
27
|
+
- !ruby/object:Gem::Dependency
|
28
|
+
name: timers
|
29
|
+
requirement: !ruby/object:Gem::Requirement
|
30
|
+
requirements:
|
31
|
+
- - "~>"
|
32
|
+
- !ruby/object:Gem::Version
|
33
|
+
version: 4.1.2
|
34
|
+
type: :runtime
|
35
|
+
prerelease: false
|
36
|
+
version_requirements: !ruby/object:Gem::Requirement
|
37
|
+
requirements:
|
38
|
+
- - "~>"
|
39
|
+
- !ruby/object:Gem::Version
|
40
|
+
version: 4.1.2
|
27
41
|
- !ruby/object:Gem::Dependency
|
28
42
|
name: sucker_punch
|
29
43
|
requirement: !ruby/object:Gem::Requirement
|
@@ -118,7 +132,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
118
132
|
version: '0'
|
119
133
|
requirements: []
|
120
134
|
rubyforge_project:
|
121
|
-
rubygems_version: 2.
|
135
|
+
rubygems_version: 2.2.5
|
122
136
|
signing_key:
|
123
137
|
specification_version: 4
|
124
138
|
summary: ''
|