rollbar 1.4.2 → 1.4.3

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: c71304582c4e3e90c305212907f516cce923104a
4
- data.tar.gz: 233e2f5605cefcdce34ae82021d176c349c5fbb0
3
+ metadata.gz: 5014d11d0ce47ae5f2e50751236a81404148c787
4
+ data.tar.gz: 12aa1c0e3509ebdb622083e4d90ca20b731414d5
5
5
  SHA512:
6
- metadata.gz: ea71e508f060e52cc6e80320035fd9f97ad269ba3a7635b1dce6554910ed18f3be0cab12ecb373f2d1f6b9213d28b87d7f85bd470926e26b3b44328adb246d3d
7
- data.tar.gz: d7399f7773162732ddba0f66f5080818005308d03ab8e4d3e110b966b54d595439f2ccaa5cc16a85b997cd22939d9ec1de2777862e4d9dc675a4004b26d285f4
6
+ metadata.gz: 83428ce3fb1b1a7287a81e1f22a862b5d3c2d429e4f133c7c7e005927724f184b4123e4446e0d2a7777e23ac7856d0b769e4e9d7ffb1cf05ee29c930b25eadbc
7
+ data.tar.gz: de80c650cde9ba6e3909d3b45a4b4fb6346a2b49cec49298449e2cb7201bfcf0d32b44c2dd73a3afdea35295abbead953b86015fcf03082f08fc71c6a4c8a86b
data/CHANGELOG.md CHANGED
@@ -1,5 +1,17 @@
1
1
  # Change Log
2
2
 
3
+ ## 1.4.3
4
+
5
+ New features:
6
+
7
+ - The current thread's scope can now be modified using `Rollbar.scope!`. This can be used to provide context data which will be included if the current request/job/etc. later throws an exception. See [#212](https://github.com/rollbar/rollbar-gem/pull/212)
8
+
9
+ Bug fixes:
10
+
11
+ - Remove duplicate `#configure` definition. See [#207](https://github.com/rollbar/rollbar-gem/pull/207)
12
+ - In the capistrano task, don't override set variables. See [#210](https://github.com/rollbar/rollbar-gem/pull/210)
13
+ - Style fix in sidekiq handler. See [#209](https://github.com/rollbar/rollbar-gem/pull/209)
14
+
3
15
  ## 1.4.2
4
16
 
5
17
  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.4.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.3)](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.4.2'
12
+ gem 'rollbar', '~> 1.4.3'
13
13
 
14
14
  And then execute:
15
15
 
@@ -184,7 +184,7 @@ notifier = notifier.scope({
184
184
  notifier.info('Jobs processed')
185
185
  ```
186
186
 
187
- If you don't want to work with a new `Notifier` instance `#scoped` will do it for you:
187
+ If you don't want to work with a new `Notifier` instance `.scoped` will do it for you:
188
188
 
189
189
  ```ruby
190
190
  while job
@@ -208,6 +208,24 @@ while job
208
208
  end
209
209
  ```
210
210
 
211
+ To modify the current scope (rather than creating a new one), use `Rollbar.scope!`. You can use this to add additional context data from inside a web request, background job, etc.
212
+
213
+ ```ruby
214
+ class NotificationJob
215
+ include Sidekiq::Worker
216
+
217
+ def perform(user_id)
218
+ Rollbar.scope!(:person => { :id => :user_id })
219
+
220
+ # If this next line causes an exception, the reported exception (which will
221
+ # be reported by Rollbar's standard Sidekiq instrumentation) will also
222
+ # include the above person information.
223
+ Notification.send_to_user(user_id)
224
+ end
225
+ end
226
+ ```
227
+
228
+
211
229
  ## Person tracking
212
230
 
213
231
  Rollbar will send information about the current user (called a "person" in Rollbar parlance) along with each error report, when available. This works by calling the ```current_user``` controller method. The return value should be an object with an ```id``` method and, optionally, ```username``` and ```email``` methods.
data/THANKS.md CHANGED
@@ -7,6 +7,7 @@ Huge thanks to the following contributors (by github username). For the most up-
7
7
  - [antico5](https://github.com/antico5)
8
8
  - [arr-ee](https://github.com/arr-ee)
9
9
  - [awmichel](https://github.com/awmichel)
10
+ - [blaet](https://github.com/blaet)
10
11
  - [bradx3](https://github.com/bradx3)
11
12
  - [chrisb](https://github.com/chrisb)
12
13
  - [derekrockwell](https://github.com/derekrockwell)
@@ -28,6 +29,7 @@ Huge thanks to the following contributors (by github username). For the most up-
28
29
  - [JoshuaOSHickman](https://github.com/JoshuaOSHickman)
29
30
  - [juggler](https://github.com/juggler)
30
31
  - [kavu](https://github.com/kavu)
32
+ - [kdonovan](https://github.com/kdonovan)
31
33
  - [kroky](https://github.com/kroky)
32
34
  - [lanej](https://github.com/lanej)
33
35
  - [lesliev-figured](https://github.com/lesliev-figured)
data/lib/rollbar.rb CHANGED
@@ -71,8 +71,9 @@ module Rollbar
71
71
  self.class.new(self, options)
72
72
  end
73
73
 
74
- def configure
75
- yield(configuration)
74
+ def scope!(options = {})
75
+ Rollbar::Util.deep_merge(@configuration.payload_options, options)
76
+ self
76
77
  end
77
78
 
78
79
  # Turns off reporting for the given block.
@@ -757,6 +758,10 @@ module Rollbar
757
758
  self.notifier = old_notifier
758
759
  end
759
760
 
761
+ def scope!(options = {})
762
+ notifier.scope!(options)
763
+ end
764
+
760
765
  # Backwards compatibility methods
761
766
 
762
767
  def report_exception(exception, request_data = nil, person_data = nil, level = 'error')
@@ -1,20 +1,18 @@
1
1
  # encoding: utf-8
2
2
 
3
- PARAM_BLACKLIST = ['backtrace', 'error_backtrace', 'error_message', 'error_class']
3
+ PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class]
4
4
 
5
5
  if Sidekiq::VERSION < '3'
6
6
  module Rollbar
7
7
  class Sidekiq
8
8
  def call(worker, msg, queue)
9
- begin
10
- yield
11
- rescue Exception => e
12
- params = msg.reject{ |k| PARAM_BLACKLIST.include?(k) }
13
- scope = { :request => { :params => params } }
9
+ yield
10
+ rescue Exception => e
11
+ params = msg.reject{ |k| PARAM_BLACKLIST.include?(k) }
12
+ scope = { :request => { :params => params } }
14
13
 
15
- Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
16
- raise
17
- end
14
+ Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
15
+ raise
18
16
  end
19
17
  end
20
18
  end
@@ -34,9 +34,9 @@ end
34
34
 
35
35
  namespace :load do
36
36
  task :defaults do
37
- set :rollbar_user, Proc.new { ENV['USER'] || ENV['USERNAME'] }
38
- set :rollbar_env, Proc.new { fetch :rails_env, 'production' }
39
- set :rollbar_token, Proc.new { abort "Please specify the Rollbar access token, set :rollbar_token, 'your token'" }
40
- set :rollbar_role, Proc.new { :app }
37
+ set :rollbar_user, fetch(:rollbar_user, Proc.new { ENV['USER'] || ENV['USERNAME'] } )
38
+ set :rollbar_env, fetch(:rollbar_env, Proc.new { fetch :rails_env, 'production' } )
39
+ set :rollbar_token, fetch(:rollbar_token, Proc.new { abort "Please specify the Rollbar access token, set :rollbar_token, 'your token'" } )
40
+ set :rollbar_role, fetch(:rollbar_role, Proc.new { :app } )
41
41
  end
42
42
  end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "1.4.2"
2
+ VERSION = "1.4.3"
3
3
  end
data/spec/rollbar_spec.rb CHANGED
@@ -1581,6 +1581,21 @@ describe Rollbar do
1581
1581
  end
1582
1582
  end
1583
1583
 
1584
+ describe '.scope!' do
1585
+ let(:new_scope) do
1586
+ { :person => { :id => 1 } }
1587
+ end
1588
+
1589
+ before { reconfigure_notifier }
1590
+
1591
+ it 'adds the new scope to the payload options' do
1592
+ configuration = Rollbar.notifier.configuration
1593
+ Rollbar.scope!(new_scope)
1594
+
1595
+ expect(configuration.payload_options).to be_eql(new_scope)
1596
+ end
1597
+ end
1598
+
1584
1599
  describe '.reset_notifier' do
1585
1600
  it 'resets the notifier' do
1586
1601
  notifier1_id = Rollbar.notifier.object_id
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.4.2
4
+ version: 1.4.3
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-26 00:00:00.000000000 Z
11
+ date: 2015-02-04 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: multi_json