roqua-support 0.1.15 → 0.1.16

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: f4788085a81572cc52f7a47204ee8a09b3b3f6f0
4
- data.tar.gz: 79dbac1200543744c31be14fcf3a1917ad6f8bd3
3
+ metadata.gz: fdc528029ceea9027cdb56ce3299bc59a64817e4
4
+ data.tar.gz: b3eaa1c5921dd5684c595486580533d790a6dc5d
5
5
  SHA512:
6
- metadata.gz: 83f0fa54714281bee536b2c060de57584dbd30d1abaaa012774460308fb66efffe256d2d7faf10f00ec9e4b21e90ac95fac7a2af54953bf8f71d63cfd54092ad
7
- data.tar.gz: f4f248b249452af42275bfbdae0492951a8092e1e34e1c2ad40a02291a4a44d16a4618ac85264fcdeaf65b486b78abbf3ee3be9314785b433e11d21d8626d81a
6
+ metadata.gz: 2fb16cd904080b1b5e22ed7bd14afda38139ee53b34583967a55a1cd986a54fc4e621adeed1fb64b1ec434f63b5012dc7da3ec317202aac624dd69108945677a
7
+ data.tar.gz: c6c44518398a0e3a012bcfdcac524c9527de98183cb37930a7175e97e9fa51d59b7362e51309025b7e8579af37fd6fc54baf84df89713a33d2ddce08e45647d5
data/CHANGELOG.md CHANGED
@@ -1,3 +1,7 @@
1
+ ## 0.1.16 / 2014-11-19
2
+
3
+ * Add support for skipping the backtrace in the logs
4
+
1
5
  ## 0.1.15 / 2014-11-18
2
6
 
3
7
  * log Airbrake UUID when reporting exceptions
data/Gemfile.lock CHANGED
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- roqua-support (0.1.15)
4
+ roqua-support (0.1.16)
5
5
  activesupport (>= 3.2, < 5.0)
6
6
 
7
7
  GEM
@@ -1,5 +1,5 @@
1
1
  module Roqua
2
2
  module Support
3
- VERSION = '0.1.15'
3
+ VERSION = '0.1.16'
4
4
  end
5
5
  end
@@ -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
- airbrake_id = notify_airbrake(exception, controller, parameters)
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, airbrake_id)
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) && extra_parameters.is_a?(Hash)
28
+ if context.is_a?(Hash)
28
29
  controller = context.delete :controller
29
- parameters = extra_parameters.merge(context)
30
- elsif context.is_a?(Hash)
31
- controller = context.delete :controller
32
- parameters = context
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 = {}, airbrake_id = nil)
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 airbrake_id.present?
48
- exception_info[:airbrake_notification] = "https://airbrake.io/locate/#{airbrake_id}"
49
- else
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
- it 'sends notifications to the eventlog' do
21
- Roqua.logger.should_receive(:error).with('roqua.exception',
22
- class_name: 'Exception',
23
- message: 'exception_message',
24
- backtrace: ['back', 'trace', 'lines'],
25
- parameters: {})
26
- Roqua::Support::Errors.report exception
27
- end
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
- it 'sends the airbrake notification id to the eventlog when present' do
30
- stub_const('Airbrake', double('Airbrake', notify_or_ignore: 'airbrake_notification_uuid'))
31
- Roqua.logger.should_receive(:error)
32
- .with('roqua.exception',
33
- class_name: 'Exception',
34
- message: 'exception_message',
35
- airbrake_notification: 'https://airbrake.io/locate/airbrake_notification_uuid',
36
- parameters: {})
37
- Roqua::Support::Errors.report exception
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.15
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-18 00:00:00.000000000 Z
11
+ date: 2014-11-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: activesupport