rollbar 2.5.2 → 2.6.0

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 94bfaab6020d2299a4f491bcaf08c1fb1e7ffaa7
4
+ data.tar.gz: 37873db26e50016607aa5b03a7298da79fe112a4
5
+ SHA512:
6
+ metadata.gz: 6389ed78df71156fb8f44c22a9d2550d99e367988fede657a3ec58b83bd09781403e8f1d2571f657a7ec535bf1b2c1a12447fb9aace2f678c332d0e1d2fddeae
7
+ data.tar.gz: 601cdc2a21f5a2e4ba23a157ed378058e3440cf4e72fea2d1d1b85631cbfa9d67ae0ece44157a732256eee9846ccc7c22cf692bb79fa9e5abadf9b5f36c77a55
data/CHANGELOG.md CHANGED
@@ -1,5 +1,12 @@
1
1
  # Change Log
2
2
 
3
+ ## 2.6.0
4
+
5
+ Features
6
+
7
+ - Sidekiq threshold for retried jobs. Allows you define a minimum number of retries to start reporting errors to Rollbar. See [#336](https://github.com/rollbar/rollbar-gem/pull/336).
8
+ - User IP obfuscator. See [#331](https://github.com/rollbar/rollbar-gem/pull/331) and [#338](https://github.com/rollbar/rollbar-gem/pull/338).
9
+
3
10
  ## 2.5.2
4
11
 
5
12
  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=v2.5.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=v2.6.0)](https://travis-ci.org/rollbar/rollbar-gem/branches)
2
2
 
3
3
  <!-- RemoveNext -->
4
4
  [Rollbar](https://rollbar.com) is an error tracking service for Ruby and other languages. The Rollbar service will alert you of problems with your code and help you understand them in a ways never possible before. We love it and we hope you will too.
@@ -12,7 +12,7 @@ This is the Ruby library for Rollbar. It will instrument many kinds of Ruby appl
12
12
  Add this line to your application's Gemfile:
13
13
 
14
14
  ```ruby
15
- gem 'rollbar', '~> 2.5.2'
15
+ gem 'rollbar', '~> 2.6.0'
16
16
  ```
17
17
 
18
18
  If you are not using JRuby we suggest using [Oj](https://github.com/ohler55/oj) for JSON serialization. In order to install Oj you can add this line to your Gemfile:
@@ -347,6 +347,12 @@ And ```Rollbar.configuration.scrub_headers```:
347
347
  Rollbar.configuration.scrub_headers |= ["X-Access-Token"]
348
348
  ```
349
349
 
350
+ If you want to obfuscate the user IP reported to the Rollbar API you can configure a secret to do it and a different IP address from the original will be reported:
351
+
352
+ ```
353
+ Rollbar.configuration.user_ip_obfuscator_secret = "a-private-secret-here"
354
+ ```
355
+
350
356
  ## Including additional runtime data
351
357
 
352
358
  You can provide a callable that will be called for each exception or message report. ```custom_data_method``` should be a lambda that takes no arguments and returns a hash.
@@ -490,6 +496,12 @@ Start Sidekiq from the root directory of your Rails app and declare the name of
490
496
  $ bundle exec sidekiq -q rollbar
491
497
  ```
492
498
 
499
+ For every errored job a new report will be sent to Rollbar API, also for errored retried jobs. You can configure the retries threshold to start reporting to rollbar:
500
+
501
+ ```ruby
502
+ config.sidekiq_threshold = 3 # Start reporting from 3 retries jobs
503
+ ```
504
+
493
505
  ### Using Resque
494
506
 
495
507
  Add the following in ```config/initializers/rollbar.rb```:
@@ -15,5 +15,3 @@ gem "rubinius-developer_tools", :platform => :rbx
15
15
  gem "rails", "3.2.22"
16
16
 
17
17
  gemspec :path => "../"
18
-
19
- gem 'debugger'
@@ -35,9 +35,11 @@ module Rollbar
35
35
  attr_accessor :scrub_fields
36
36
  attr_accessor :scrub_user
37
37
  attr_accessor :scrub_password
38
+ attr_accessor :user_ip_obfuscator_secret
38
39
  attr_accessor :randomize_scrub_length
39
40
  attr_accessor :uncaught_exception_level
40
41
  attr_accessor :scrub_headers
42
+ attr_accessor :sidekiq_threshold
41
43
  attr_accessor :verify_ssl_peer
42
44
  attr_accessor :use_async
43
45
  attr_accessor :use_eventmachine
@@ -87,6 +89,7 @@ module Rollbar
87
89
  @randomize_scrub_length = true
88
90
  @uncaught_exception_level = 'error'
89
91
  @scrub_headers = ['Authorization']
92
+ @sidekiq_threshold = 0
90
93
  @safely = false
91
94
  @use_async = false
92
95
  @use_eventmachine = false
@@ -2,6 +2,7 @@ require 'rack'
2
2
  require 'tempfile'
3
3
 
4
4
  require 'rollbar/scrubbers/url'
5
+ require 'rollbar/util/ip_obfuscator'
5
6
 
6
7
  module Rollbar
7
8
  module RequestDataExtractor
@@ -116,7 +117,9 @@ module Rollbar
116
117
  end
117
118
 
118
119
  def rollbar_user_ip(env)
119
- (env['action_dispatch.remote_ip'] || env['HTTP_X_REAL_IP'] || env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR']).to_s
120
+ user_ip_string = (env['action_dispatch.remote_ip'] || env['HTTP_X_REAL_IP'] || env['HTTP_X_FORWARDED_FOR'] || env['REMOTE_ADDR']).to_s
121
+
122
+ Rollbar::Util::IPObfuscator.obfuscate_ip(user_ip_string)
120
123
  rescue
121
124
  nil
122
125
  end
@@ -5,12 +5,18 @@ module Rollbar
5
5
  PARAM_BLACKLIST = %w[backtrace error_backtrace error_message error_class]
6
6
 
7
7
  def self.handle_exception(msg_or_context, e)
8
+ return if skip_report?(msg_or_context, e)
9
+
8
10
  params = msg_or_context.reject{ |k| PARAM_BLACKLIST.include?(k) }
9
11
  scope = { :request => { :params => params } }
10
12
 
11
13
  Rollbar.scope(scope).error(e, :use_exception_level_filters => true)
12
14
  end
13
15
 
16
+ def self.skip_report?(msg_or_context, e)
17
+ msg_or_context.is_a?(Hash) && msg_or_context["retry"] && msg_or_context["retry_count"] < ::Rollbar.configuration.sidekiq_threshold
18
+ end
19
+
14
20
  def call(worker, msg, queue)
15
21
  yield
16
22
  rescue Exception => e
data/lib/rollbar/util.rb CHANGED
@@ -1,5 +1,6 @@
1
1
  require 'rollbar/util/hash'
2
2
 
3
+
3
4
  module Rollbar
4
5
  module Util
5
6
  def self.iterate_and_update(obj, block)
@@ -0,0 +1,21 @@
1
+ module Rollbar
2
+ module Util
3
+ module IPObfuscator
4
+ require 'ipaddr'
5
+ require 'digest'
6
+
7
+ def self.obfuscate_ip(ip_string)
8
+ return ip_string unless Rollbar.configuration.user_ip_obfuscator_secret
9
+
10
+ secret = Rollbar.configuration.user_ip_obfuscator_secret
11
+ ip_int32 = IPAddr.new(ip_string, Socket::AF_INET).to_i
12
+ secret_int32 = Digest::MD5.hexdigest(secret)[0..7].to_i(16)
13
+ obfuscated_ip_int32 = ip_int32 ^ secret_int32 % (2 << 31)
14
+
15
+ IPAddr.new(obfuscated_ip_int32, Socket::AF_INET).to_s
16
+ rescue
17
+ nil
18
+ end
19
+ end
20
+ end
21
+ end
@@ -1,3 +1,3 @@
1
1
  module Rollbar
2
- VERSION = "2.5.2"
2
+ VERSION = "2.6.0"
3
3
  end
@@ -8,8 +8,9 @@ describe HomeController do
8
8
  before do
9
9
  reset_configuration
10
10
  preconfigure_rails_notifier
11
+
11
12
  Rollbar.configure do |config|
12
- config.access_token = 'aaaabbbbccccddddeeeeffff00001111'
13
+ config.access_token = test_access_token
13
14
  config.logger = logger_mock
14
15
  config.request_timeout = 60
15
16
  end
@@ -143,6 +144,27 @@ describe HomeController do
143
144
  it "should use the remote_addr when neither is set" do
144
145
  controller.send(:rollbar_request_data)[:user_ip].should == '0.0.0.0'
145
146
  end
147
+
148
+ context "rollbar_user_ip obfuscator" do
149
+ before do
150
+ Rollbar.configure do |config|
151
+ config.user_ip_obfuscator_secret = 'secret'
152
+ end
153
+ end
154
+
155
+ it "should obfuscate the ip when user_ip_obfuscator_secret is set" do
156
+ real_ip = '1.1.1.1'
157
+ obfuscated_ip = '95.191.35.149'
158
+ controller.request.env["HTTP_X_REAL_IP"] = real_ip
159
+ controller.send(:rollbar_request_data)[:user_ip].should == obfuscated_ip
160
+ end
161
+
162
+ it "should clear the ip field when an invalid ip is provided" do
163
+ invalid_ip = '1.1.1.999'
164
+ controller.request.env["HTTP_X_REAL_IP"] = invalid_ip
165
+ controller.send(:rollbar_request_data)[:user_ip].should == nil
166
+ end
167
+ end
146
168
  end
147
169
 
148
170
  context "rollbar_route_params", :type => 'request' do
@@ -27,6 +27,39 @@ describe Rollbar::Sidekiq, :reconfigure_notifier => false do
27
27
 
28
28
  described_class.handle_exception(msg_or_context, exception)
29
29
  end
30
+
31
+ context 'when set a sidekiq_threshold' do
32
+ before do
33
+ Rollbar.configuration.sidekiq_threshold = 2
34
+ end
35
+
36
+ it 'does not send error to rollbar under the threshold' do
37
+ allow(Rollbar).to receive(:scope).and_return(rollbar)
38
+ expect(rollbar).to receive(:error).never
39
+
40
+ msg_or_context = {"retry" => true, "retry_count" => 1}
41
+
42
+ described_class.handle_exception(msg_or_context, exception)
43
+ end
44
+
45
+ it 'sends the error to rollbar above the threshold' do
46
+ allow(Rollbar).to receive(:scope).and_return(rollbar)
47
+ expect(rollbar).to receive(:error)
48
+
49
+ msg_or_context = {"retry" => true, "retry_count" => 2}
50
+
51
+ described_class.handle_exception(msg_or_context, exception)
52
+ end
53
+
54
+ it 'sends the error to rollbar if not retry' do
55
+ allow(Rollbar).to receive(:scope).and_return(rollbar)
56
+ expect(rollbar).to receive(:error)
57
+
58
+ msg_or_context = {"retry" => false}
59
+
60
+ described_class.handle_exception(msg_or_context, exception)
61
+ end
62
+ end
30
63
  end
31
64
 
32
65
  describe '#call' do
@@ -43,5 +76,3 @@ describe Rollbar::Sidekiq, :reconfigure_notifier => false do
43
76
  end
44
77
  end
45
78
  end unless RUBY_VERSION == '1.8.7'
46
-
47
-
metadata CHANGED
@@ -1,238 +1,209 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: rollbar
3
3
  version: !ruby/object:Gem::Version
4
- version: 2.5.2
5
- prerelease:
4
+ version: 2.6.0
6
5
  platform: ruby
7
6
  authors:
8
7
  - Rollbar, Inc.
9
8
  autorequire:
10
9
  bindir: bin
11
10
  cert_chain: []
12
- date: 2015-11-03 00:00:00.000000000 Z
11
+ date: 2015-11-11 00:00:00.000000000 Z
13
12
  dependencies:
14
13
  - !ruby/object:Gem::Dependency
15
14
  name: rails
16
15
  requirement: !ruby/object:Gem::Requirement
17
- none: false
18
16
  requirements:
19
- - - ! '>='
17
+ - - ">="
20
18
  - !ruby/object:Gem::Version
21
19
  version: 3.0.0
22
20
  type: :development
23
21
  prerelease: false
24
22
  version_requirements: !ruby/object:Gem::Requirement
25
- none: false
26
23
  requirements:
27
- - - ! '>='
24
+ - - ">="
28
25
  - !ruby/object:Gem::Version
29
26
  version: 3.0.0
30
27
  - !ruby/object:Gem::Dependency
31
28
  name: rspec-rails
32
29
  requirement: !ruby/object:Gem::Requirement
33
- none: false
34
30
  requirements:
35
- - - ! '>='
31
+ - - ">="
36
32
  - !ruby/object:Gem::Version
37
33
  version: 2.14.0
38
34
  type: :development
39
35
  prerelease: false
40
36
  version_requirements: !ruby/object:Gem::Requirement
41
- none: false
42
37
  requirements:
43
- - - ! '>='
38
+ - - ">="
44
39
  - !ruby/object:Gem::Version
45
40
  version: 2.14.0
46
41
  - !ruby/object:Gem::Dependency
47
42
  name: database_cleaner
48
43
  requirement: !ruby/object:Gem::Requirement
49
- none: false
50
44
  requirements:
51
- - - ~>
45
+ - - "~>"
52
46
  - !ruby/object:Gem::Version
53
47
  version: 1.0.0
54
48
  type: :development
55
49
  prerelease: false
56
50
  version_requirements: !ruby/object:Gem::Requirement
57
- none: false
58
51
  requirements:
59
- - - ~>
52
+ - - "~>"
60
53
  - !ruby/object:Gem::Version
61
54
  version: 1.0.0
62
55
  - !ruby/object:Gem::Dependency
63
56
  name: girl_friday
64
57
  requirement: !ruby/object:Gem::Requirement
65
- none: false
66
58
  requirements:
67
- - - ! '>='
59
+ - - ">="
68
60
  - !ruby/object:Gem::Version
69
61
  version: 0.11.1
70
62
  type: :development
71
63
  prerelease: false
72
64
  version_requirements: !ruby/object:Gem::Requirement
73
- none: false
74
65
  requirements:
75
- - - ! '>='
66
+ - - ">="
76
67
  - !ruby/object:Gem::Version
77
68
  version: 0.11.1
78
69
  - !ruby/object:Gem::Dependency
79
70
  name: sucker_punch
80
71
  requirement: !ruby/object:Gem::Requirement
81
- none: false
82
72
  requirements:
83
- - - ! '>='
73
+ - - ">="
84
74
  - !ruby/object:Gem::Version
85
75
  version: 1.0.0
86
76
  type: :development
87
77
  prerelease: false
88
78
  version_requirements: !ruby/object:Gem::Requirement
89
- none: false
90
79
  requirements:
91
- - - ! '>='
80
+ - - ">="
92
81
  - !ruby/object:Gem::Version
93
82
  version: 1.0.0
94
83
  - !ruby/object:Gem::Dependency
95
84
  name: sidekiq
96
85
  requirement: !ruby/object:Gem::Requirement
97
- none: false
98
86
  requirements:
99
- - - ! '>='
87
+ - - ">="
100
88
  - !ruby/object:Gem::Version
101
89
  version: 2.13.0
102
90
  type: :development
103
91
  prerelease: false
104
92
  version_requirements: !ruby/object:Gem::Requirement
105
- none: false
106
93
  requirements:
107
- - - ! '>='
94
+ - - ">="
108
95
  - !ruby/object:Gem::Version
109
96
  version: 2.13.0
110
97
  - !ruby/object:Gem::Dependency
111
98
  name: genspec
112
99
  requirement: !ruby/object:Gem::Requirement
113
- none: false
114
100
  requirements:
115
- - - ! '>='
101
+ - - ">="
116
102
  - !ruby/object:Gem::Version
117
103
  version: 0.2.8
118
104
  type: :development
119
105
  prerelease: false
120
106
  version_requirements: !ruby/object:Gem::Requirement
121
- none: false
122
107
  requirements:
123
- - - ! '>='
108
+ - - ">="
124
109
  - !ruby/object:Gem::Version
125
110
  version: 0.2.8
126
111
  - !ruby/object:Gem::Dependency
127
112
  name: sinatra
128
113
  requirement: !ruby/object:Gem::Requirement
129
- none: false
130
114
  requirements:
131
- - - ! '>='
115
+ - - ">="
132
116
  - !ruby/object:Gem::Version
133
117
  version: '0'
134
118
  type: :development
135
119
  prerelease: false
136
120
  version_requirements: !ruby/object:Gem::Requirement
137
- none: false
138
121
  requirements:
139
- - - ! '>='
122
+ - - ">="
140
123
  - !ruby/object:Gem::Version
141
124
  version: '0'
142
125
  - !ruby/object:Gem::Dependency
143
126
  name: resque
144
127
  requirement: !ruby/object:Gem::Requirement
145
- none: false
146
128
  requirements:
147
- - - ! '>='
129
+ - - ">="
148
130
  - !ruby/object:Gem::Version
149
131
  version: '0'
150
132
  type: :development
151
133
  prerelease: false
152
134
  version_requirements: !ruby/object:Gem::Requirement
153
- none: false
154
135
  requirements:
155
- - - ! '>='
136
+ - - ">="
156
137
  - !ruby/object:Gem::Version
157
138
  version: '0'
158
139
  - !ruby/object:Gem::Dependency
159
140
  name: delayed_job
160
141
  requirement: !ruby/object:Gem::Requirement
161
- none: false
162
142
  requirements:
163
- - - ! '>='
143
+ - - ">="
164
144
  - !ruby/object:Gem::Version
165
145
  version: '0'
166
146
  type: :development
167
147
  prerelease: false
168
148
  version_requirements: !ruby/object:Gem::Requirement
169
- none: false
170
149
  requirements:
171
- - - ! '>='
150
+ - - ">="
172
151
  - !ruby/object:Gem::Version
173
152
  version: '0'
174
153
  - !ruby/object:Gem::Dependency
175
154
  name: rake
176
155
  requirement: !ruby/object:Gem::Requirement
177
- none: false
178
156
  requirements:
179
- - - ! '>='
157
+ - - ">="
180
158
  - !ruby/object:Gem::Version
181
159
  version: 0.9.0
182
160
  type: :development
183
161
  prerelease: false
184
162
  version_requirements: !ruby/object:Gem::Requirement
185
- none: false
186
163
  requirements:
187
- - - ! '>='
164
+ - - ">="
188
165
  - !ruby/object:Gem::Version
189
166
  version: 0.9.0
190
167
  - !ruby/object:Gem::Dependency
191
168
  name: redis
192
169
  requirement: !ruby/object:Gem::Requirement
193
- none: false
194
170
  requirements:
195
- - - ! '>='
171
+ - - ">="
196
172
  - !ruby/object:Gem::Version
197
173
  version: '0'
198
174
  type: :development
199
175
  prerelease: false
200
176
  version_requirements: !ruby/object:Gem::Requirement
201
- none: false
202
177
  requirements:
203
- - - ! '>='
178
+ - - ">="
204
179
  - !ruby/object:Gem::Version
205
180
  version: '0'
206
181
  - !ruby/object:Gem::Dependency
207
182
  name: multi_json
208
183
  requirement: !ruby/object:Gem::Requirement
209
- none: false
210
184
  requirements:
211
- - - ! '>='
185
+ - - ">="
212
186
  - !ruby/object:Gem::Version
213
187
  version: '0'
214
188
  type: :runtime
215
189
  prerelease: false
216
190
  version_requirements: !ruby/object:Gem::Requirement
217
- none: false
218
191
  requirements:
219
- - - ! '>='
192
+ - - ">="
220
193
  - !ruby/object:Gem::Version
221
194
  version: '0'
222
195
  - !ruby/object:Gem::Dependency
223
196
  name: oj
224
197
  requirement: !ruby/object:Gem::Requirement
225
- none: false
226
198
  requirements:
227
- - - ~>
199
+ - - "~>"
228
200
  - !ruby/object:Gem::Version
229
201
  version: 2.12.14
230
202
  type: :development
231
203
  prerelease: false
232
204
  version_requirements: !ruby/object:Gem::Requirement
233
- none: false
234
205
  requirements:
235
- - - ~>
206
+ - - "~>"
236
207
  - !ruby/object:Gem::Version
237
208
  version: 2.12.14
238
209
  description: Easy and powerful exception tracking for Ruby
@@ -243,8 +214,8 @@ executables:
243
214
  extensions: []
244
215
  extra_rdoc_files: []
245
216
  files:
246
- - .gitignore
247
- - .travis.yml
217
+ - ".gitignore"
218
+ - ".travis.yml"
248
219
  - Appraisals
249
220
  - CHANGELOG.md
250
221
  - Gemfile
@@ -312,6 +283,7 @@ files:
312
283
  - lib/rollbar/truncation/strings_strategy.rb
313
284
  - lib/rollbar/util.rb
314
285
  - lib/rollbar/util/hash.rb
286
+ - lib/rollbar/util/ip_obfuscator.rb
315
287
  - lib/rollbar/version.rb
316
288
  - rollbar.gemspec
317
289
  - spec/cacert.pem
@@ -412,27 +384,26 @@ files:
412
384
  homepage: https://rollbar.com
413
385
  licenses:
414
386
  - MIT
387
+ metadata: {}
415
388
  post_install_message:
416
389
  rdoc_options: []
417
390
  require_paths:
418
391
  - lib
419
392
  required_ruby_version: !ruby/object:Gem::Requirement
420
- none: false
421
393
  requirements:
422
- - - ! '>='
394
+ - - ">="
423
395
  - !ruby/object:Gem::Version
424
396
  version: '0'
425
397
  required_rubygems_version: !ruby/object:Gem::Requirement
426
- none: false
427
398
  requirements:
428
- - - ! '>='
399
+ - - ">="
429
400
  - !ruby/object:Gem::Version
430
401
  version: '0'
431
402
  requirements: []
432
403
  rubyforge_project:
433
- rubygems_version: 1.8.23
404
+ rubygems_version: 2.4.5
434
405
  signing_key:
435
- specification_version: 3
406
+ specification_version: 4
436
407
  summary: Reports exceptions to Rollbar
437
408
  test_files:
438
409
  - spec/cacert.pem