rollbar 0.11.8 → 0.12.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/CHANGELOG.md +3 -0
- data/README.md +3 -3
- data/lib/generators/rollbar/templates/initializer.rb +3 -3
- data/lib/rollbar/configuration.rb +21 -11
- data/lib/rollbar/delay/sidekiq.rb +5 -3
- data/lib/rollbar/delay/sucker_punch.rb +4 -4
- data/lib/rollbar/version.rb +1 -1
- data/spec/delay/sidekiq_spec.rb +49 -28
- data/spec/delay/sucker_punch_spec.rb +25 -0
- data/spec/rollbar_spec.rb +22 -19
- metadata +3 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: d821880871796e7a3f286f28efed45d344e58f7a
|
4
|
+
data.tar.gz: 3e955416377adb50366976787a1b96f8fe0f7267
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f524945b9cddd9a18ef5a346d0416475c12d257dde63598a49514d3601e24e773e7b8705d434a9d5cc77a97b2c5b2df676f80aa0fe26264f40771d33e2d25c77
|
7
|
+
data.tar.gz: 093270b5b4852101b26196e287c92be720cdb02e1c198b29397b977c1db249115484024670b59b31501b1ed34871be756b968655a15cdfbac606aedebdae2ff4
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,8 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
**0.12.0**
|
4
|
+
- Added [#73](https://github.com/rollbar/rollbar-gem/pull/73), enhanced Sidekiq and SuckerPunch configuration. NOTE: The old `Rollbar::Configuration#use_sidekiq=` and `Rollbar::Configuration#use_sucker_punch=` methods are now depricated, see the docs for updated usage information.
|
5
|
+
|
3
6
|
**0.11.8**
|
4
7
|
- Make sure the person method exists for the controller before trying to extract person data
|
5
8
|
|
data/README.md
CHANGED
@@ -206,7 +206,7 @@ Asynchronous reporting falls back to Threading if girl_friday is not installed.
|
|
206
206
|
Add the following in ```config/initializers/rollbar.rb```:
|
207
207
|
|
208
208
|
```ruby
|
209
|
-
config.use_sucker_punch
|
209
|
+
config.use_sucker_punch
|
210
210
|
```
|
211
211
|
|
212
212
|
### Using Sidekiq
|
@@ -214,13 +214,13 @@ config.use_sucker_punch = true
|
|
214
214
|
Add the following in ```config/initializers/rollbar.rb```:
|
215
215
|
|
216
216
|
```ruby
|
217
|
-
config.use_sidekiq
|
217
|
+
config.use_sidekiq
|
218
218
|
```
|
219
219
|
|
220
220
|
You can also supply custom Sidekiq options:
|
221
221
|
|
222
222
|
```ruby
|
223
|
-
config.use_sidekiq
|
223
|
+
config.use_sidekiq { 'queue' => 'my_queue' }
|
224
224
|
```
|
225
225
|
|
226
226
|
Start the redis server:
|
@@ -41,10 +41,10 @@ Rollbar.configure do |config|
|
|
41
41
|
# }
|
42
42
|
|
43
43
|
# Enable asynchronous reporting (using sucker_punch)
|
44
|
-
# config.use_sucker_punch
|
44
|
+
# config.use_sucker_punch
|
45
45
|
|
46
46
|
# Enable delayed reporting (using Sidekiq)
|
47
|
-
# config.use_sidekiq
|
47
|
+
# config.use_sidekiq
|
48
48
|
# You can supply custom Sidekiq options:
|
49
|
-
# config.use_sidekiq
|
49
|
+
# config.use_sidekiq { 'queue' => 'my_queue' }
|
50
50
|
end
|
@@ -63,21 +63,31 @@ module Rollbar
|
|
63
63
|
@write_to_file = false
|
64
64
|
end
|
65
65
|
|
66
|
+
def use_sidekiq(options = {})
|
67
|
+
require 'rollbar/delay/sidekiq' if defined?(Sidekiq)
|
68
|
+
@use_async = true
|
69
|
+
@use_sidekiq = true
|
70
|
+
@async_handler = Rollbar::Delay::Sidekiq.new(options)
|
71
|
+
end
|
72
|
+
|
66
73
|
def use_sidekiq=(value)
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
72
|
-
|
74
|
+
deprecation_message = "#use_sidekiq=(value) has been deprecated in favor of #use_sidekiq(options = {}). Please update your rollbar configuration."
|
75
|
+
defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
|
76
|
+
|
77
|
+
value.is_a?(Hash) ? use_sidekiq(value) : use_sidekiq
|
78
|
+
end
|
79
|
+
|
80
|
+
def use_sucker_punch
|
81
|
+
require 'rollbar/delay/sucker_punch' if defined?(SuckerPunch)
|
82
|
+
@use_async = true
|
83
|
+
@async_handler = Rollbar::Delay::SuckerPunch.new
|
73
84
|
end
|
74
85
|
|
75
86
|
def use_sucker_punch=(value)
|
76
|
-
|
77
|
-
|
78
|
-
|
79
|
-
|
80
|
-
end
|
87
|
+
deprecation_message = "#use_sucker_punch=(value) has been deprecated in favor of #use_sucker_punch. Please update your rollbar configuration."
|
88
|
+
defined?(ActiveSupport) ? ActiveSupport::Deprecation.warn(deprecation_message) : puts(deprecation_message)
|
89
|
+
|
90
|
+
use_sucker_punch
|
81
91
|
end
|
82
92
|
|
83
93
|
def use_eventmachine=(value)
|
@@ -5,10 +5,12 @@ module Rollbar
|
|
5
5
|
class Sidekiq
|
6
6
|
OPTIONS = { 'queue' => 'rollbar', 'class' => self.name }.freeze
|
7
7
|
|
8
|
-
def
|
9
|
-
|
8
|
+
def initialize(*args)
|
9
|
+
@options = (opts = args.shift) ? OPTIONS.merge(opts) : OPTIONS
|
10
|
+
end
|
10
11
|
|
11
|
-
|
12
|
+
def call(payload)
|
13
|
+
::Sidekiq::Client.push @options.merge('args' => [payload])
|
12
14
|
end
|
13
15
|
|
14
16
|
include ::Sidekiq::Worker
|
@@ -3,13 +3,13 @@ require 'sucker_punch'
|
|
3
3
|
module Rollbar
|
4
4
|
module Delay
|
5
5
|
class SuckerPunch
|
6
|
-
def self.handle(payload)
|
7
|
-
@@sucker_punch_worker ||= self.new
|
8
|
-
@@sucker_punch_worker.async.perform payload
|
9
|
-
end
|
10
6
|
|
11
7
|
include ::SuckerPunch::Job
|
12
8
|
|
9
|
+
def call(payload)
|
10
|
+
async.perform payload
|
11
|
+
end
|
12
|
+
|
13
13
|
def perform(*args)
|
14
14
|
Rollbar.process_payload(*args)
|
15
15
|
end
|
data/lib/rollbar/version.rb
CHANGED
data/spec/delay/sidekiq_spec.rb
CHANGED
@@ -2,39 +2,60 @@ require 'spec_helper'
|
|
2
2
|
|
3
3
|
begin
|
4
4
|
require 'rollbar/delay/sidekiq'
|
5
|
+
require 'sidekiq/testing'
|
5
6
|
rescue LoadError
|
7
|
+
module Rollbar
|
8
|
+
module Delay
|
9
|
+
class Sidekiq
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
6
13
|
end
|
7
14
|
|
8
|
-
if
|
9
|
-
|
10
|
-
|
11
|
-
|
15
|
+
describe Rollbar::Delay::Sidekiq, :if => RUBY_VERSION != '1.8.7' do
|
16
|
+
let(:payload) { anything }
|
17
|
+
|
18
|
+
describe "#perform" do
|
19
|
+
it "performs payload" do
|
20
|
+
Rollbar.should_receive(:process_payload).with(payload)
|
21
|
+
subject.perform payload
|
12
22
|
end
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
end
|
23
|
+
end
|
24
|
+
|
25
|
+
describe "#call" do
|
26
|
+
shared_examples "a Rollbar processor" do
|
27
|
+
|
28
|
+
it "processes payload" do
|
29
|
+
Rollbar.should_receive(:process_payload).with(payload)
|
30
|
+
|
31
|
+
subject.call payload
|
32
|
+
described_class.drain
|
24
33
|
end
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
::Sidekiq::Client.should_receive(:push).with options
|
34
|
-
|
35
|
-
Rollbar::Delay::Sidekiq.handle(payload)
|
36
|
-
end
|
34
|
+
end
|
35
|
+
|
36
|
+
context "with default options" do
|
37
|
+
it "enqueues to default queue" do
|
38
|
+
options = Rollbar::Delay::Sidekiq::OPTIONS.merge('args' => payload)
|
39
|
+
::Sidekiq::Client.should_receive(:push).with options
|
40
|
+
|
41
|
+
subject.call payload
|
37
42
|
end
|
43
|
+
|
44
|
+
it_behaves_like "a Rollbar processor"
|
45
|
+
end
|
46
|
+
|
47
|
+
context "with custom options" do
|
48
|
+
let(:custom_config) { { 'queue' => 'custom_queue' } }
|
49
|
+
subject { Rollbar::Delay::Sidekiq.new custom_config }
|
50
|
+
|
51
|
+
it "enqueues to custom queue" do
|
52
|
+
options = Rollbar::Delay::Sidekiq::OPTIONS.merge(custom_config.merge('args' => payload))
|
53
|
+
::Sidekiq::Client.should_receive(:push).with options
|
54
|
+
|
55
|
+
subject.call payload
|
56
|
+
end
|
57
|
+
|
58
|
+
it_behaves_like "a Rollbar processor"
|
38
59
|
end
|
39
60
|
end
|
40
|
-
end
|
61
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
begin
|
4
|
+
require 'rollbar/delay/sucker_punch'
|
5
|
+
require 'sucker_punch/testing/inline'
|
6
|
+
rescue LoadError
|
7
|
+
module Rollbar
|
8
|
+
module Delay
|
9
|
+
class SuckerPunch
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
|
15
|
+
describe Rollbar::Delay::SuckerPunch, :if => RUBY_VERSION != '1.8.7' do
|
16
|
+
describe "#call" do
|
17
|
+
let(:payload) { "anything" }
|
18
|
+
|
19
|
+
it "performs asynchronously the task" do
|
20
|
+
Rollbar.should_receive(:process_payload)
|
21
|
+
|
22
|
+
subject.call payload
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
data/spec/rollbar_spec.rb
CHANGED
@@ -370,18 +370,18 @@ describe Rollbar do
|
|
370
370
|
end
|
371
371
|
end
|
372
372
|
|
373
|
-
if defined?(SuckerPunch)
|
373
|
+
describe "#use_sucker_punch", :if => defined?(SuckerPunch) do
|
374
374
|
it "should send the payload to sucker_punch delayer" do
|
375
375
|
logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
|
376
376
|
logger_mock.should_receive(:info).with('[Rollbar] Sending payload')
|
377
377
|
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
378
|
-
|
378
|
+
|
379
379
|
Rollbar.configure do |config|
|
380
|
-
config.use_sucker_punch
|
380
|
+
config.use_sucker_punch
|
381
381
|
end
|
382
|
-
|
382
|
+
|
383
383
|
Rollbar.report_exception(@exception)
|
384
|
-
|
384
|
+
|
385
385
|
Rollbar.configure do |config|
|
386
386
|
config.use_async = false
|
387
387
|
config.async_handler = Rollbar.method(:default_async_handler)
|
@@ -389,25 +389,28 @@ describe Rollbar do
|
|
389
389
|
end
|
390
390
|
end
|
391
391
|
|
392
|
-
|
393
|
-
|
394
|
-
|
395
|
-
|
396
|
-
|
397
|
-
end
|
392
|
+
describe "#use_sidekiq", :if => defined?(Sidekiq) do
|
393
|
+
it "should instanciate sidekiq delayer with custom values" do
|
394
|
+
Rollbar::Delay::Sidekiq.should_receive(:new).with('queue' => 'test_queue')
|
395
|
+
config = Rollbar::Configuration.new
|
396
|
+
config.use_sidekiq 'queue' => 'test_queue'
|
398
397
|
end
|
399
398
|
|
400
|
-
|
399
|
+
it "should send the payload to sidekiq delayer" do
|
400
|
+
handler = double('sidekiq_handler_mock')
|
401
|
+
handler.should_receive(:call)
|
401
402
|
|
402
|
-
|
403
|
-
|
404
|
-
|
403
|
+
Rollbar.configure do |config|
|
404
|
+
config.use_sidekiq
|
405
|
+
config.async_handler = handler
|
406
|
+
end
|
405
407
|
|
406
|
-
|
408
|
+
Rollbar.report_exception(@exception)
|
407
409
|
|
408
|
-
|
409
|
-
|
410
|
-
|
410
|
+
Rollbar.configure do |config|
|
411
|
+
config.use_async = false
|
412
|
+
config.async_handler = Rollbar.method(:default_async_handler)
|
413
|
+
end
|
411
414
|
end
|
412
415
|
end
|
413
416
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: rollbar
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.
|
4
|
+
version: 0.12.0
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Brian Rue
|
@@ -171,6 +171,7 @@ files:
|
|
171
171
|
- rollbar.gemspec
|
172
172
|
- spec/controllers/home_controller_spec.rb
|
173
173
|
- spec/delay/sidekiq_spec.rb
|
174
|
+
- spec/delay/sucker_punch_spec.rb
|
174
175
|
- spec/dummyapp/.gitignore
|
175
176
|
- spec/dummyapp/Rakefile
|
176
177
|
- spec/dummyapp/app/assets/javascripts/application.js
|
@@ -252,6 +253,7 @@ summary: Reports exceptions to Rollbar
|
|
252
253
|
test_files:
|
253
254
|
- spec/controllers/home_controller_spec.rb
|
254
255
|
- spec/delay/sidekiq_spec.rb
|
256
|
+
- spec/delay/sucker_punch_spec.rb
|
255
257
|
- spec/dummyapp/.gitignore
|
256
258
|
- spec/dummyapp/Rakefile
|
257
259
|
- spec/dummyapp/app/assets/javascripts/application.js
|