roqua-support 0.1.15 → 0.1.16
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +4 -0
- data/Gemfile.lock +1 -1
- data/lib/roqua-support/version.rb +1 -1
- data/lib/roqua/support/errors.rb +19 -17
- data/spec/roqua/support/errors_spec.rb +38 -27
- metadata +2 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: fdc528029ceea9027cdb56ce3299bc59a64817e4
|
4
|
+
data.tar.gz: b3eaa1c5921dd5684c595486580533d790a6dc5d
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 2fb16cd904080b1b5e22ed7bd14afda38139ee53b34583967a55a1cd986a54fc4e621adeed1fb64b1ec434f63b5012dc7da3ec317202aac624dd69108945677a
|
7
|
+
data.tar.gz: c6c44518398a0e3a012bcfdcac524c9527de98183cb37930a7175e97e9fa51d59b7362e51309025b7e8579af37fd6fc54baf84df89713a33d2ddce08e45647d5
|
data/CHANGELOG.md
CHANGED
data/Gemfile.lock
CHANGED
data/lib/roqua/support/errors.rb
CHANGED
@@ -11,44 +11,45 @@ module Roqua
|
|
11
11
|
|
12
12
|
def self.report(exception, context = {})
|
13
13
|
return if const_defined?(:Rails) and Rails.env.test?
|
14
|
-
parameters, controller = merge_parameters(context)
|
14
|
+
parameters, controller, skip_backtrace = merge_parameters(context)
|
15
|
+
notification_urls = []
|
15
16
|
# Notify Airbrake
|
16
|
-
|
17
|
+
notification_urls << notify_airbrake(exception, controller, parameters)
|
17
18
|
# Notify AppSignal
|
18
|
-
notify_appsignal(exception, parameters)
|
19
|
+
notification_urls << notify_appsignal(exception, parameters)
|
19
20
|
# Notify Roqua logging
|
20
|
-
log_exception(exception, parameters,
|
21
|
+
log_exception(exception, parameters, notification_urls.compact, skip_backtrace)
|
21
22
|
end
|
22
23
|
|
23
24
|
private
|
24
25
|
|
25
26
|
def self.merge_parameters(context)
|
26
27
|
begin
|
27
|
-
if context.is_a?(Hash)
|
28
|
+
if context.is_a?(Hash)
|
28
29
|
controller = context.delete :controller
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
30
|
+
skip_backtrace = context.delete :skip_backtrace
|
31
|
+
if extra_parameters.is_a?(Hash)
|
32
|
+
parameters = extra_parameters.merge(context)
|
33
|
+
else
|
34
|
+
parameters = context
|
35
|
+
end
|
33
36
|
elsif extra_parameters.is_a?(Hash)
|
34
37
|
parameters = extra_parameters
|
35
38
|
end
|
36
|
-
[parameters, controller]
|
39
|
+
[parameters, controller, skip_backtrace]
|
37
40
|
rescue Exception
|
38
41
|
end
|
39
42
|
end
|
40
43
|
|
41
|
-
def self.log_exception(exception, parameters = {},
|
44
|
+
def self.log_exception(exception, parameters = {}, notification_urls = [], skip_backtrace = false)
|
42
45
|
begin
|
43
46
|
if Roqua.respond_to?(:logger)
|
44
47
|
exception_info = {class_name: exception.class.to_s,
|
45
48
|
message: exception.message,
|
46
49
|
parameters: parameters}
|
47
|
-
if
|
48
|
-
|
49
|
-
|
50
|
-
exception_info[:backtrace] = exception.backtrace
|
51
|
-
end
|
50
|
+
exception_info[:notification_urls] = notification_urls if notification_urls.present?
|
51
|
+
exception_info[:backtrace] = exception.backtrace unless skip_backtrace
|
52
|
+
puts exception_info.inspect
|
52
53
|
Roqua.logger.error('roqua.exception', exception_info)
|
53
54
|
end
|
54
55
|
rescue Exception
|
@@ -70,7 +71,8 @@ module Roqua
|
|
70
71
|
end
|
71
72
|
end
|
72
73
|
request_data ||= {parameters: parameters}
|
73
|
-
Airbrake.notify_or_ignore(exception, request_data)
|
74
|
+
uuid = Airbrake.notify_or_ignore(exception, request_data)
|
75
|
+
"https://airbrake.io/locate/#{uuid}" if uuid
|
74
76
|
end
|
75
77
|
rescue Exception
|
76
78
|
end
|
@@ -17,24 +17,45 @@ describe 'Error reporting' do
|
|
17
17
|
Roqua.logger = logwrapper
|
18
18
|
end
|
19
19
|
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
20
|
+
context 'when the Roqua logger is defined' do
|
21
|
+
it 'supports default extra params' do
|
22
|
+
Roqua::Support::Errors.stub(extra_parameters: {organization: 'some_org'})
|
23
|
+
Roqua.logger.should_receive(:error).with('roqua.exception',
|
24
|
+
class_name: 'Exception',
|
25
|
+
message: 'exception_message',
|
26
|
+
backtrace: ['back', 'trace', 'lines'],
|
27
|
+
parameters: {organization: 'some_org'})
|
28
|
+
Roqua::Support::Errors.report exception
|
29
|
+
end
|
30
|
+
|
31
|
+
it 'sends notifications to the eventlog' do
|
32
|
+
Roqua.logger.should_receive(:error).with('roqua.exception',
|
33
|
+
class_name: 'Exception',
|
34
|
+
message: 'exception_message',
|
35
|
+
backtrace: ['back', 'trace', 'lines'],
|
36
|
+
parameters: {})
|
37
|
+
Roqua::Support::Errors.report exception
|
38
|
+
end
|
28
39
|
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
40
|
+
it 'skips the backtrace when the skip_backtrace flag is set' do
|
41
|
+
Roqua.logger.should_receive(:error).with('roqua.exception',
|
42
|
+
class_name: 'Exception',
|
43
|
+
message: 'exception_message',
|
44
|
+
parameters: {})
|
45
|
+
Roqua::Support::Errors.report exception, skip_backtrace: true
|
46
|
+
end
|
47
|
+
|
48
|
+
it 'logs notification_urls when present' do
|
49
|
+
stub_const('Airbrake', double('Airbrake', notify_or_ignore: 'uuid'))
|
50
|
+
Roqua.logger.should_receive(:error)
|
51
|
+
.with('roqua.exception',
|
52
|
+
class_name: 'Exception',
|
53
|
+
message: 'exception_message',
|
54
|
+
backtrace: ['back', 'trace', 'lines'],
|
55
|
+
notification_urls: ['https://airbrake.io/locate/uuid'],
|
56
|
+
parameters: {})
|
57
|
+
Roqua::Support::Errors.report exception
|
58
|
+
end
|
38
59
|
end
|
39
60
|
|
40
61
|
context 'when Airbrake is defined' do
|
@@ -101,14 +122,4 @@ describe 'Error reporting' do
|
|
101
122
|
Roqua::Support::Errors.report exception
|
102
123
|
end
|
103
124
|
end
|
104
|
-
|
105
|
-
it 'supports default extra params' do
|
106
|
-
Roqua::Support::Errors.stub(extra_parameters: {organization: 'some_org'})
|
107
|
-
Roqua.logger.should_receive(:error).with('roqua.exception',
|
108
|
-
class_name: 'Exception',
|
109
|
-
message: 'exception_message',
|
110
|
-
backtrace: ['back', 'trace', 'lines'],
|
111
|
-
parameters: {organization: 'some_org'})
|
112
|
-
Roqua::Support::Errors.report exception
|
113
|
-
end
|
114
125
|
end
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: roqua-support
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.16
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Marten Veldthuis
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2014-11-
|
11
|
+
date: 2014-11-19 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: activesupport
|