rollbar 1.3.2 → 1.4.0

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: 55ced1d6252f0c0b4881f16dc7ff96ca6bc2c62c
4
- data.tar.gz: 1b014694a4e209dc360f771f2b78157c1dae993c
3
+ metadata.gz: 7162276edce6487cb188a1ae5b7bacfd690f5f8f
4
+ data.tar.gz: d9f6433968083985d404cc46ce34d5607e46b7ff
5
5
  SHA512:
6
- metadata.gz: bdd18fce475312ed6945d0c1ce3a6500dd58abde4bfefef007dc22124fc3a72dc7289e52719865b9e637720a409bb9dc63c44e04a2b6ebf9dacfc2f49707dbee
7
- data.tar.gz: 7856923253bb7ad7e7fb396bd607d50c2bcffcd50dda2c559a37b910be3bac58f1655ef771235816c5ad4ab2f5aca35d64af76655cadf217a95929ece7010504
6
+ metadata.gz: f689341a99194085a8f73f2e28c52dbce73ed44ad0bf9e81066cfd3aa7ca90e4a2ef071dd1c1e07ecb1ae80b6141f2fc5c901f7293baea0dfe64c048f4dec355
7
+ data.tar.gz: 447bfcd210fa8bd59eb05ee72cd53fa6a623019f76dd4c14eefd0e015c0a336e427b6f6dd7e432779199fc9fc76485c0cdd8cc1e4d7785b89d8fed5e11020889
data/CHANGELOG.md CHANGED
@@ -1,5 +1,11 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.0
4
+
5
+ Possible breaking changes:
6
+
7
+ - `exception_level_filters` is now applied only to "uncaught" errors (i.e. those detected by middlewares) but not to direct calls to `Rollbar.error`. If you were previously using `Rollbar.error` (or `Rollbar.warning`, etc.), the new behavior is *probably* desirable, but if it isn't, you can get the old behavior via `Rollbar.error(e, :use_exception_level_filters => true)`. The middlewares that ship with the gem also now pass this new flag.
8
+
3
9
  ## 1.3.2
4
10
 
5
11
  Bug fixes:
data/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v1.3.2)](https://travis-ci.org/rollbar/rollbar-gem/branches)
1
+ # Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v1.4.0)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
2
 
3
3
  <!-- RemoveNext -->
4
4
  Ruby gem for reporting exceptions, errors, and log messages to [Rollbar](https://rollbar.com).
@@ -9,7 +9,7 @@ Ruby gem for reporting exceptions, errors, and log messages to [Rollbar](https:/
9
9
 
10
10
  Add this line to your application's Gemfile:
11
11
 
12
- gem 'rollbar', '~> 1.3.2'
12
+ gem 'rollbar', '~> 1.4.0'
13
13
 
14
14
  And then execute:
15
15
 
@@ -294,6 +294,12 @@ By default, all uncaught exceptions are reported at the "error" level, except fo
294
294
 
295
295
  If you'd like to customize this list, see the example code in ```config/initializers/rollbar.rb```. Supported levels: "critical", "error", "warning", "info", "debug", "ignore". Set to "ignore" to cause the exception not to be reported at all.
296
296
 
297
+ This behavior applies to uncaught exceptions, not direct calls to `Rollbar.error()`, `Rollbar.warning()`, etc. If you are making a direct call to one of the log methods and want exception level filters to apply, pass an extra keyword argument:
298
+
299
+ ```ruby
300
+ Rollbar.error(exception, :use_exception_level_filters => true)
301
+ ```
302
+
297
303
  ## Silencing exceptions at runtime
298
304
 
299
305
  If you just want to disable exception reporting for a single block, use ```Rollbar.silenced```:
@@ -15,7 +15,7 @@ module BetterErrors
15
15
  controller = env['action_controller.instance']
16
16
  request_data = controller.rollbar_request_data rescue nil
17
17
  person_data = controller.rollbar_person_data rescue nil
18
- exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception)
18
+ exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception, :use_exception_level_filters => true)
19
19
  rescue => e
20
20
  Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
21
21
  end
@@ -10,7 +10,7 @@ module Rollbar
10
10
  rescue Exception => e
11
11
  if job.attempts >= ::Rollbar.configuration.dj_threshold
12
12
  data = ::Rollbar.configuration.report_dj_data ? job : nil
13
- ::Rollbar.scope(:request => data).error(e)
13
+ ::Rollbar.scope(:request => data).error(e, :use_exception_level_filters => true)
14
14
  end
15
15
  raise e
16
16
  end
@@ -4,7 +4,7 @@ module Rollbar
4
4
  exception_message = exception.respond_to?(:message) ? exception.message : 'No Exception Message'
5
5
  Rollbar.log_debug "[Rollbar] Reporting exception: #{exception_message}"
6
6
 
7
- exception_data = Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception)
7
+ exception_data = Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception, :use_exception_level_filters => true)
8
8
 
9
9
  if exception_data.is_a?(Hash)
10
10
  env['rollbar.exception_uuid'] = exception_data[:uuid]
@@ -1,7 +1,7 @@
1
1
  module Goalie
2
2
  class CustomErrorPages
3
3
  alias_method :orig_render_exception, :render_exception
4
-
4
+
5
5
  private
6
6
 
7
7
  def render_exception(env, exception)
@@ -10,7 +10,7 @@ module Goalie
10
10
  controller = env['action_controller.instance']
11
11
  request_data = controller.rollbar_request_data rescue nil
12
12
  person_data = controller.rollbar_person_data rescue nil
13
- exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception)
13
+ exception_data = Rollbar.scope(:request => request_data, :person => person_data).error(exception, :use_exception_level_filters => true)
14
14
  rescue => e
15
15
  Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e}"
16
16
  end
data/lib/rollbar/rake.rb CHANGED
@@ -9,7 +9,7 @@ module Rollbar
9
9
  alias_method :orig_display_error_message, :display_error_message
10
10
 
11
11
  def display_error_message(ex)
12
- Rollbar.error(ex)
12
+ Rollbar.error(ex, :use_exception_level_filters => true)
13
13
  orig_display_error_message(ex)
14
14
  end
15
15
  end
@@ -12,7 +12,7 @@ if Sidekiq::VERSION < '3'
12
12
  params = msg.reject{ |k| PARAM_BLACKLIST.include?(k) }
13
13
  scope = { :request => { :params => params } }
14
14
 
15
- Rollbar.scope(scope).error(e)
15
+ Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
16
16
  raise
17
17
  end
18
18
  end
@@ -30,7 +30,7 @@ else
30
30
  params = context.reject{ |k| PARAM_BLACKLIST.include?(k) }
31
31
  scope = { :request => { :params => params } }
32
32
 
33
- Rollbar.scope(scope).error(e)
33
+ Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
34
34
  end
35
35
  end
36
36
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "1.3.2"
2
+ VERSION = "1.4.0"
3
3
  end
data/lib/rollbar.rb CHANGED
@@ -125,10 +125,14 @@ module Rollbar
125
125
  end
126
126
  end
127
127
 
128
- return 'ignored' if ignored?(exception)
128
+ use_exception_level_filters = extra && extra.delete(:use_exception_level_filters) == true
129
129
 
130
- exception_level = filtered_level(exception)
131
- level = exception_level if exception_level
130
+ return 'ignored' if ignored?(exception, use_exception_level_filters)
131
+
132
+ if use_exception_level_filters
133
+ exception_level = filtered_level(exception)
134
+ level = exception_level if exception_level
135
+ end
132
136
 
133
137
  begin
134
138
  report(level, message, exception, extra)
@@ -193,9 +197,9 @@ module Rollbar
193
197
 
194
198
  private
195
199
 
196
- def ignored?(exception)
200
+ def ignored?(exception, use_exception_level_filters = false)
197
201
  return false unless exception
198
- return true if filtered_level(exception) == 'ignore'
202
+ return true if use_exception_level_filters && filtered_level(exception) == 'ignore'
199
203
  return true if exception.instance_variable_get(:@_rollbar_do_not_report)
200
204
 
201
205
  false
@@ -762,7 +766,7 @@ module Rollbar
762
766
  scope[:person] = person_data if person_data
763
767
 
764
768
  Rollbar.scoped(scope) do
765
- Rollbar.notifier.log(level, exception)
769
+ Rollbar.notifier.log(level, exception, :use_exception_level_filters => true)
766
770
  end
767
771
  end
768
772
 
@@ -32,8 +32,12 @@ describe Rollbar::Delayed, :reconfigure_notifier => true do
32
32
  Delayed::Worker.backend = DummyBackend::Job
33
33
  end
34
34
 
35
+ let(:expected_args) do
36
+ [kind_of(FailingJob::TestException), { :use_exception_level_filters => true}]
37
+ end
38
+
35
39
  it 'sends the exception' do
36
- expect_any_instance_of(Rollbar::Notifier).to receive(:error).with(kind_of(FailingJob::TestException))
40
+ expect_any_instance_of(Rollbar::Notifier).to receive(:error).with(*expected_args)
37
41
 
38
42
  expect do
39
43
  Delayed::Job.enqueue(FailingJob.new)
@@ -26,7 +26,7 @@ describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
26
26
  let(:uncaught_level) { Rollbar.configuration.uncaught_exception_level }
27
27
 
28
28
  it 'reports the error to Rollbar' do
29
- expect(Rollbar).to receive(:log).with(uncaught_level, exception)
29
+ expect(Rollbar).to receive(:log).with(uncaught_level, exception, :use_exception_level_filters => true)
30
30
  expect { request.get('/will_crash') }.to raise_error(exception)
31
31
  end
32
32
 
@@ -42,7 +42,7 @@ describe Rollbar::Middleware::Sinatra, :reconfigure_notifier => true do
42
42
  end
43
43
 
44
44
  let(:expected_report_args) do
45
- [uncaught_level, exception]
45
+ [uncaught_level, exception, { :use_exception_level_filters => true }]
46
46
  end
47
47
 
48
48
  describe '#call' do
@@ -12,7 +12,7 @@ describe Rollbar::Rake do
12
12
 
13
13
  it 'reports error to Rollbar' do
14
14
  expect(Rollbar::Rake).not_to receive(:skip_patch)
15
- expect(Rollbar).to receive(:error).with(exception)
15
+ expect(Rollbar).to receive(:error).with(exception, :use_exception_level_filters => true)
16
16
  expect(application).to receive(:orig_display_error_message).with(exception)
17
17
 
18
18
  Rollbar::Rake.patch! # Really here Rake is already patched
@@ -276,7 +276,7 @@ describe Rollbar do
276
276
  Rollbar.last_report.should_not be_nil
277
277
  end
278
278
 
279
- it 'should allow callables to set exception filtered level' do
279
+ it 'should allow callables to set exception filtered level with :use_exception_level_filters option' do
280
280
  callable_mock = double
281
281
  Rollbar.configure do |config|
282
282
  config.exception_level_filters = { 'NameError' => callable_mock }
data/spec/rollbar_spec.rb CHANGED
@@ -731,25 +731,48 @@ describe Rollbar do
731
731
  Rollbar.error(exception).should == 'disabled'
732
732
  end
733
733
 
734
- it 'should ignore ignored exception classes' do
735
- Rollbar.configure do |config|
736
- config.exception_level_filters = { 'NameError' => 'ignore' }
734
+ context 'using :use_exception_level_filters option as true' do
735
+ it 'sends the correct filtered level' do
736
+ Rollbar.configure do |config|
737
+ config.exception_level_filters = { 'NameError' => 'warning' }
738
+ end
739
+
740
+ Rollbar.error(exception, :use_exception_level_filters => true)
741
+ expect(Rollbar.last_report[:level]).to be_eql('warning')
737
742
  end
738
743
 
739
- logger_mock.should_not_receive(:info)
740
- logger_mock.should_not_receive(:warn)
741
- logger_mock.should_not_receive(:error)
744
+ it 'ignore ignored exception classes' do
745
+ Rollbar.configure do |config|
746
+ config.exception_level_filters = { 'NameError' => 'ignore' }
747
+ end
742
748
 
743
- Rollbar.error(exception)
749
+ logger_mock.should_not_receive(:info)
750
+ logger_mock.should_not_receive(:warn)
751
+ logger_mock.should_not_receive(:error)
752
+
753
+ Rollbar.error(exception, :use_exception_level_filters => true)
754
+ end
744
755
  end
745
756
 
746
- it 'sends the correct filtered level' do
747
- Rollbar.configure do |config|
748
- config.exception_level_filters = { 'NameError' => 'warning' }
757
+ context 'if not using :use_exception_level_filters option' do
758
+ it 'sends the level defined by the used method' do
759
+ Rollbar.configure do |config|
760
+ config.exception_level_filters = { 'NameError' => 'warning' }
761
+ end
762
+
763
+ Rollbar.error(exception)
764
+ expect(Rollbar.last_report[:level]).to be_eql('error')
749
765
  end
750
766
 
751
- Rollbar.error(exception)
752
- expect(Rollbar.last_report[:level]).to be_eql('warning')
767
+ it 'ignore ignored exception classes' do
768
+ Rollbar.configure do |config|
769
+ config.exception_level_filters = { 'NameError' => 'ignore' }
770
+ end
771
+
772
+ Rollbar.error(exception)
773
+
774
+ expect(Rollbar.last_report[:level]).to be_eql('error')
775
+ end
753
776
  end
754
777
 
755
778
  it "should work with an IO object as rack.errors" do
@@ -813,6 +836,7 @@ describe Rollbar do
813
836
  it 'should allow callables to set exception filtered level' do
814
837
  callable_mock = double
815
838
  saved_filters = Rollbar.configuration.exception_level_filters
839
+
816
840
  Rollbar.configure do |config|
817
841
  config.exception_level_filters = { 'NameError' => callable_mock }
818
842
  end
@@ -822,7 +846,7 @@ describe Rollbar do
822
846
  logger_mock.should_not_receive(:warn)
823
847
  logger_mock.should_not_receive(:error)
824
848
 
825
- Rollbar.error(exception)
849
+ Rollbar.error(exception, :use_exception_level_filters => true)
826
850
  end
827
851
 
828
852
  it 'should not report exceptions when silenced' do
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.2
4
+ version: 1.4.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2015-01-09 00:00:00.000000000 Z
11
+ date: 2015-01-13 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json