rollbar 1.3.0 → 1.3.1

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: f16df0211259f30c790efadaf922efe258d549d5
4
- data.tar.gz: 4d2a670ebac6ddfdf7bdf27de563efdc20adfc74
3
+ metadata.gz: 7575d58a3d88f1967dac6cf9d70e78d2170c1bae
4
+ data.tar.gz: 32d7bf74f7276b35434601f0e89c018100f93fed
5
5
  SHA512:
6
- metadata.gz: 3c4379908512383a8328601c5dd13da3999c7492f9ca40b9b9e90809c9a210821616fb0da5eb80a443c7be19ae1c66127a4572816d38daf47b609fe66e78b0a1
7
- data.tar.gz: d584525530951ec2d9fd65f071726a84442307e8ea466bbc7d275a0918cb30018e76688c176dd16a2846d5701d5294a36fd8d7991dab70e0fb2c7e1dc94b29f6
6
+ metadata.gz: 64acb033938cea26fd519fcff644a23730d9872746020bfdcaaa0a8e62e7f68c4c75461f0730fa6c816cfd5d43e7ac365b00722d22918b82c6d9d0b172ff82bb
7
+ data.tar.gz: 97ba117f2544e3c6fff17839355babb8a9b020b9964802fdb83874f3d3fea9be51580fdb4ca34cdcda59fe35ea68f9631bb5556eca84f632a33f5f085e8a4d25
data/CHANGELOG.md CHANGED
@@ -1,5 +1,13 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.3.1
4
+
5
+ Bug fixes:
6
+
7
+ - Fix bug with smart truncation for messages. See [#195](https://github.com/rollbar/rollbar-gem/issues/195) and [#196](https://github.com/rollbar/rollbar-gem/issues/196)
8
+ - Safely catch exceptions in `process_payload` when called from an async handler. See [#196](https://github.com/rollbar/rollbar-gem/pull/196)
9
+
10
+
3
11
  ## 1.3.0
4
12
 
5
13
  Performance improvements:
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.0)](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.3.1)](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.0'
12
+ gem 'rollbar', '~> 1.3.1'
13
13
 
14
14
  And then execute:
15
15
 
@@ -410,11 +410,11 @@ You can supply your own handler using ```config.async_handler```. The object to
410
410
  ```ruby
411
411
  config.use_async
412
412
  config.async_handler = Proc.new { |payload|
413
- Thread.new { Rollbar.process_payload(payload) }
413
+ Thread.new { Rollbar.process_payload_safely(payload) }
414
414
  }
415
415
  ```
416
416
 
417
- Make sure you pass ```payload``` to ```Rollbar.process_payload``` in your own implementation.
417
+ Make sure you pass ```payload``` to ```Rollbar.process_payload_safely``` in your own implementation.
418
418
 
419
419
  ## Failover handlers
420
420
 
@@ -46,7 +46,7 @@ Rollbar.configure do |config|
46
46
  # config.use_async = true
47
47
  # Supply your own async handler:
48
48
  # config.async_handler = Proc.new { |payload|
49
- # Thread.new { Rollbar.process_payload(payload) }
49
+ # Thread.new { Rollbar.process_payload_safely(payload) }
50
50
  # }
51
51
 
52
52
  # Enable asynchronous reporting (using sucker_punch)
data/lib/rollbar.rb CHANGED
@@ -31,7 +31,7 @@ module Rollbar
31
31
  Rack::Multipart::UploadedFile
32
32
  ].freeze
33
33
  PUBLIC_NOTIFIER_METHODS = %w(debug info warn warning error critical log logger
34
- process_payload scope send_failsafe log_info log_debug
34
+ process_payload process_payload_safely scope send_failsafe log_info log_debug
35
35
  log_warning log_error silenced)
36
36
 
37
37
  class Notifier
@@ -180,6 +180,15 @@ module Rollbar
180
180
  else
181
181
  send_payload(payload)
182
182
  end
183
+ rescue => e
184
+ log_error("[Rollbar] Error processing the payload: #{e.class}, #{e.message}. Payload: #{payload.inspect}")
185
+ raise e
186
+ end
187
+
188
+ def process_payload_safely(payload)
189
+ process_payload(payload)
190
+ rescue => e
191
+ report_internal_error(e)
183
192
  end
184
193
 
185
194
  private
@@ -16,7 +16,7 @@ module Rollbar
16
16
 
17
17
  def call(payload)
18
18
  self.class.queue = queue_class.new(nil, :size => 5) do |payload|
19
- Rollbar.process_payload(payload)
19
+ Rollbar.process_payload_safely(payload)
20
20
  end
21
21
 
22
22
  self.class.queue.push(payload)
@@ -23,7 +23,7 @@ module Rollbar
23
23
  end
24
24
 
25
25
  def perform(payload)
26
- Rollbar.process_payload(payload)
26
+ Rollbar.process_payload_safely(payload)
27
27
  end
28
28
  end
29
29
  end
@@ -16,7 +16,7 @@ module Rollbar
16
16
  include ::Sidekiq::Worker
17
17
 
18
18
  def perform(*args)
19
- Rollbar.process_payload(*args)
19
+ Rollbar.process_payload_safely(*args)
20
20
  end
21
21
  end
22
22
  end
@@ -11,7 +11,7 @@ module Rollbar
11
11
  end
12
12
 
13
13
  def perform(*args)
14
- Rollbar.process_payload(*args)
14
+ Rollbar.process_payload_safely(*args)
15
15
  end
16
16
  end
17
17
  end
@@ -6,7 +6,7 @@ module Rollbar
6
6
  end
7
7
 
8
8
  def call(payload)
9
- ::Thread.new { Rollbar.process_payload(payload) }
9
+ ::Thread.new { Rollbar.process_payload_safely(payload) }
10
10
  end
11
11
  end
12
12
  end
@@ -15,7 +15,7 @@ module Rollbar
15
15
 
16
16
  if body['trace_chain']
17
17
  truncate_trace_chain(body)
18
- else
18
+ elsif body['trace']
19
19
  truncate_trace(body)
20
20
  end
21
21
 
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "1.3.0"
2
+ VERSION = "1.3.1"
3
3
  end
@@ -17,7 +17,7 @@ describe Rollbar::Delay::Sidekiq, :if => RUBY_VERSION != '1.8.7' do
17
17
 
18
18
  describe "#perform" do
19
19
  it "performs payload" do
20
- Rollbar.should_receive(:process_payload).with(payload)
20
+ Rollbar.should_receive(:process_payload_safely).with(payload)
21
21
  subject.perform payload
22
22
  end
23
23
  end
@@ -26,7 +26,7 @@ describe Rollbar::Delay::Sidekiq, :if => RUBY_VERSION != '1.8.7' do
26
26
  shared_examples "a Rollbar processor" do
27
27
 
28
28
  it "processes payload" do
29
- Rollbar.should_receive(:process_payload).with(payload)
29
+ Rollbar.should_receive(:process_payload_safely).with(payload)
30
30
 
31
31
  subject.call payload
32
32
  described_class.drain
@@ -17,7 +17,7 @@ describe Rollbar::Delay::SuckerPunch, :if => RUBY_VERSION != '1.8.7' do
17
17
  let(:payload) { "anything" }
18
18
 
19
19
  it "performs the task asynchronously" do
20
- Rollbar.should_receive(:process_payload)
20
+ Rollbar.should_receive(:process_payload_safely)
21
21
 
22
22
  Rollbar::Delay::SuckerPunch.call payload
23
23
  end
@@ -14,7 +14,7 @@ describe Rollbar::Delay::Resque do
14
14
  it 'process the payload' do
15
15
  loaded_hash = MultiJson.load(MultiJson.dump(payload))
16
16
 
17
- expect(Rollbar).to receive(:process_payload).with(loaded_hash)
17
+ expect(Rollbar).to receive(:process_payload_safely).with(loaded_hash)
18
18
  described_class.call(payload)
19
19
  end
20
20
  end
@@ -5,7 +5,7 @@ describe Rollbar::Delay::Thread do
5
5
  let(:payload) { { :key => 'value' } }
6
6
 
7
7
  it 'process the payload in a new thread' do
8
- expect(Rollbar).to receive(:process_payload).with(payload)
8
+ expect(Rollbar).to receive(:process_payload_safely).with(payload)
9
9
 
10
10
  th = described_class.call(payload)
11
11
  th.join
@@ -52,5 +52,19 @@ describe Rollbar::Truncation::FramesStrategy do
52
52
  expect(new_frames2.last).to be_eql(frames2.last)
53
53
  end
54
54
  end
55
+
56
+ context 'without trace or trace_chain', :fixture => :payload do
57
+ let(:payload_fixture) { 'payloads/sample.trace.json' }
58
+
59
+ before do
60
+ payload['data']['body'].delete('trace')
61
+ end
62
+
63
+ it 'returns the original payload' do
64
+ result = MultiJson.load(described_class.call(payload))
65
+
66
+ expect(result).to be_eql(payload)
67
+ end
68
+ end
55
69
  end
56
70
  end
data/spec/rollbar_spec.rb CHANGED
@@ -1547,6 +1547,33 @@ describe Rollbar do
1547
1547
  end
1548
1548
  end
1549
1549
 
1550
+ describe '.process_payload' do
1551
+ context 'if there is an exception sending the payload' do
1552
+ let(:exception) { StandardError.new('error message') }
1553
+ let(:payload) { { :foo => :bar } }
1554
+
1555
+ it 'logs the error and the payload' do
1556
+ allow(Rollbar.notifier).to receive(:send_payload).and_raise(exception)
1557
+ expect(Rollbar.notifier).to receive(:log_error)
1558
+
1559
+ expect { Rollbar.notifier.process_payload(payload) }.to raise_error(exception)
1560
+ end
1561
+ end
1562
+ end
1563
+
1564
+ describe '.process_payload_safely' do
1565
+ context 'with errors' do
1566
+ let(:exception) { StandardError.new('the error') }
1567
+
1568
+ it 'doesnt raise anything and sends internal error' do
1569
+ allow(Rollbar.notifier).to receive(:process_payload).and_raise(exception)
1570
+ expect(Rollbar.notifier).to receive(:report_internal_error).with(exception)
1571
+
1572
+ Rollbar.notifier.process_payload_safely({})
1573
+ end
1574
+ end
1575
+ end
1576
+
1550
1577
  # configure with some basic params
1551
1578
  def configure
1552
1579
  reconfigure_notifier
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.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Rollbar, Inc.
8
8
  autorequire:
9
9
  bindir: bin
10
10
  cert_chain: []
11
- date: 2014-12-11 00:00:00.000000000 Z
11
+ date: 2014-12-19 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json
@@ -341,7 +341,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
341
341
  version: '0'
342
342
  requirements: []
343
343
  rubyforge_project:
344
- rubygems_version: 2.0.3
344
+ rubygems_version: 2.0.14
345
345
  signing_key:
346
346
  specification_version: 4
347
347
  summary: Reports exceptions to Rollbar