rollbar 2.2.1 → 2.3.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 +15 -0
- data/README.md +2 -2
- data/gemfiles/rails30.gemfile +13 -12
- data/lib/generators/rollbar/templates/initializer.rb +1 -1
- data/lib/rollbar.rb +33 -22
- data/lib/rollbar/delayed_job.rb +54 -8
- data/lib/rollbar/json.rb +11 -14
- data/lib/rollbar/request_data_extractor.rb +9 -1
- data/lib/rollbar/version.rb +1 -1
- data/rollbar.gemspec +1 -0
- data/spec/controllers/home_controller_spec.rb +12 -1
- data/spec/delayed/backend/test.rb +133 -0
- data/spec/delayed/serialization/test.rb +0 -0
- data/spec/dummyapp/app/controllers/home_controller.rb +10 -0
- data/spec/dummyapp/config/routes.rb +10 -6
- data/spec/rollbar/delayed_job/job_data.rb +35 -0
- data/spec/rollbar/delayed_job_spec.rb +37 -24
- data/spec/rollbar/json_spec.rb +19 -5
- data/spec/rollbar_spec.rb +23 -4
- data/spec/spec_helper.rb +1 -4
- data/spec/support/helpers.rb +5 -0
- metadata +24 -2
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 6e71e17b7e4734a7d1f0ef5b089a35786b962b4e
|
4
|
+
data.tar.gz: 6b91570fd7e15397aa2100e0e2e99339d99544b0
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 5d768005681a92731a4947f3f8afb7db45cf73f2cc51119495e731dd7cf8fdf3b58c7dc6220e234e47f3dc00acf1c1b50c4870763b7685e6e8ec362f5001cf5d
|
7
|
+
data.tar.gz: 0383bbc528d88144cf755ac2d7042fcb4165faa521d69c58f65f2a2ebb7be1db17dddd98cd5c41187e85fbc8264e20f0cc12555a32bd577725f49d3c2ade2b37
|
data/CHANGELOG.md
CHANGED
@@ -1,5 +1,20 @@
|
|
1
1
|
# Change Log
|
2
2
|
|
3
|
+
## 2.3.0
|
4
|
+
|
5
|
+
Internal changes:
|
6
|
+
|
7
|
+
- Use Oj instead of JSON gem for payload serializing. See [#300](https://github.com/rollbar/rollbar-gem/pull/300)
|
8
|
+
- Send nearest backtrace entry on failsafe messages. See [#290](https://github.com/rollbar/rollbar-gem/pull/290)
|
9
|
+
- Remove whitespace from config template. See [#295](https://github.com/rollbar/rollbar-gem/pull/295)
|
10
|
+
|
11
|
+
Bug fixes:
|
12
|
+
|
13
|
+
- Send correct hash value for delayed job 'handler' object. See [#301](https://github.com/rollbar/rollbar-gem/pull/301)
|
14
|
+
- Fix delayed_job crash reports. See [#293](https://github.com/rollbar/rollbar-gem/pull/293)
|
15
|
+
- Send session data instead of session store options. [#289](https://github.com/rollbar/rollbar-gem/pull/289)
|
16
|
+
|
17
|
+
|
3
18
|
## 2.2.1
|
4
19
|
|
5
20
|
Improvement:
|
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.
|
1
|
+
# Rollbar notifier for Ruby [![Build Status](https://api.travis-ci.org/rollbar/rollbar-gem.svg?branch=v2.3.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.
|
15
|
+
gem 'rollbar', '~> 2.3.0'
|
16
16
|
```
|
17
17
|
|
18
18
|
And then execute:
|
data/gemfiles/rails30.gemfile
CHANGED
@@ -1,16 +1,17 @@
|
|
1
1
|
# This file was generated by Appraisal
|
2
2
|
|
3
|
-
source
|
3
|
+
source 'https://rubygems.org'
|
4
4
|
|
5
|
-
gem
|
6
|
-
gem
|
7
|
-
gem
|
8
|
-
gem
|
9
|
-
gem
|
10
|
-
gem
|
11
|
-
gem
|
12
|
-
gem
|
13
|
-
gem
|
14
|
-
gem
|
5
|
+
gem 'sqlite3', :platform => [:ruby, :mswin, :mingw]
|
6
|
+
gem 'jruby-openssl', :platform => :jruby
|
7
|
+
gem 'activerecord-jdbcsqlite3-adapter', :platform => :jruby
|
8
|
+
gem 'appraisal', '= 1.0.2'
|
9
|
+
gem 'rubysl', '~> 2.0', :platform => :rbx
|
10
|
+
gem 'racc', :platform => :rbx
|
11
|
+
gem 'minitest', :platform => :rbx
|
12
|
+
gem 'rubysl-test-unit', :platform => :rbx
|
13
|
+
gem 'rubinius-developer_tools', :platform => :rbx
|
14
|
+
gem 'rails', '3.0.20'
|
15
|
+
gem 'hitimes', '< 1.2.2'
|
15
16
|
|
16
|
-
gemspec :path =>
|
17
|
+
gemspec :path => '../'
|
@@ -2,7 +2,7 @@ require 'rollbar/rails'
|
|
2
2
|
Rollbar.configure do |config|
|
3
3
|
# Without configuration, Rollbar is enabled in all environments.
|
4
4
|
# To disable in specific environments, set config.enabled=false.
|
5
|
-
|
5
|
+
|
6
6
|
<%- if (defined? EY::Config) -%>
|
7
7
|
# Here we'll disable in 'test' and 'development':
|
8
8
|
if Rails.env.test? or Rails.env.development?
|
data/lib/rollbar.rb
CHANGED
@@ -573,21 +573,11 @@ module Rollbar
|
|
573
573
|
end
|
574
574
|
|
575
575
|
def send_failsafe(message, exception)
|
576
|
-
|
577
|
-
log_error "[Rollbar] Sending failsafe response due to #{message}."
|
576
|
+
exception_reason = failsafe_reason(message, exception)
|
578
577
|
|
579
|
-
|
580
|
-
|
581
|
-
|
582
|
-
log_error "[Rollbar] #{exception.class.name}: #{exception}"
|
583
|
-
rescue
|
584
|
-
end
|
585
|
-
else
|
586
|
-
begin
|
587
|
-
body += message.to_s
|
588
|
-
rescue
|
589
|
-
end
|
590
|
-
end
|
578
|
+
log_error "[Rollbar] Sending failsafe response due to #{exception_reason}"
|
579
|
+
|
580
|
+
body = failsafe_body(exception_reason)
|
591
581
|
|
592
582
|
failsafe_data = {
|
593
583
|
:level => 'error',
|
@@ -619,6 +609,34 @@ module Rollbar
|
|
619
609
|
failsafe_payload
|
620
610
|
end
|
621
611
|
|
612
|
+
def failsafe_reason(message, exception)
|
613
|
+
body = ''
|
614
|
+
|
615
|
+
if exception
|
616
|
+
begin
|
617
|
+
backtrace = exception.backtrace || []
|
618
|
+
nearest_frame = backtrace[0]
|
619
|
+
|
620
|
+
exception_info = exception.class.name
|
621
|
+
exception_info += " in #{nearest_frame}" if nearest_frame
|
622
|
+
|
623
|
+
body += "#{exception_info}: #{message}"
|
624
|
+
rescue
|
625
|
+
end
|
626
|
+
else
|
627
|
+
begin
|
628
|
+
body += message.to_s
|
629
|
+
rescue
|
630
|
+
end
|
631
|
+
end
|
632
|
+
|
633
|
+
body
|
634
|
+
end
|
635
|
+
|
636
|
+
def failsafe_body(reason)
|
637
|
+
"Failsafe from rollbar-gem. #{reason}"
|
638
|
+
end
|
639
|
+
|
622
640
|
def schedule_payload(payload)
|
623
641
|
return if payload.nil?
|
624
642
|
|
@@ -778,14 +796,7 @@ module Rollbar
|
|
778
796
|
end
|
779
797
|
|
780
798
|
def monkey_patch_socket?
|
781
|
-
|
782
|
-
|
783
|
-
major, minor = ActiveSupport::VERSION::STRING.split('.').map(&:to_i)
|
784
|
-
|
785
|
-
return true if major == 3
|
786
|
-
return true if major == 4 && minor == 0
|
787
|
-
|
788
|
-
false
|
799
|
+
defined?(ActiveSupport::VERSION::STRING)
|
789
800
|
end
|
790
801
|
|
791
802
|
def wrap_delayed_worker
|
data/lib/rollbar/delayed_job.rb
CHANGED
@@ -1,20 +1,66 @@
|
|
1
|
+
require 'delayed_job'
|
2
|
+
|
1
3
|
module Rollbar
|
2
4
|
module Delayed
|
5
|
+
class << self
|
6
|
+
attr_accessor :wrapped
|
7
|
+
end
|
8
|
+
|
9
|
+
class JobData
|
10
|
+
attr_reader :job
|
11
|
+
|
12
|
+
def initialize(job)
|
13
|
+
@job = job
|
14
|
+
end
|
15
|
+
|
16
|
+
def to_hash
|
17
|
+
job_data = job.as_json
|
18
|
+
# Here job_data['handler'] is a YAML object comming
|
19
|
+
# from the storage backend
|
20
|
+
job_data['handler'] = job.payload_object.as_json
|
21
|
+
|
22
|
+
job_data
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|
26
|
+
self.wrapped = false
|
27
|
+
|
3
28
|
def self.wrap_worker
|
4
|
-
return if
|
5
|
-
|
29
|
+
return if wrapped
|
30
|
+
|
31
|
+
around_invoke_job(&invoke_job_callback)
|
6
32
|
|
7
|
-
|
33
|
+
self.wrapped = true
|
34
|
+
end
|
35
|
+
|
36
|
+
def self.around_invoke_job(&block)
|
37
|
+
::Delayed::Worker.lifecycle.around(:invoke_job, &block)
|
38
|
+
end
|
39
|
+
|
40
|
+
def self.invoke_job_callback
|
41
|
+
proc do |job, *args, &block|
|
8
42
|
begin
|
9
43
|
block.call(job, *args)
|
10
|
-
rescue
|
11
|
-
|
12
|
-
|
13
|
-
::Rollbar.scope(:request => data).error(e, :use_exception_level_filters => true)
|
14
|
-
end
|
44
|
+
rescue => e
|
45
|
+
report(e, job)
|
46
|
+
|
15
47
|
raise e
|
16
48
|
end
|
17
49
|
end
|
18
50
|
end
|
51
|
+
|
52
|
+
def self.report(e, job)
|
53
|
+
return unless job.attempts <= ::Rollbar.configuration.dj_threshold
|
54
|
+
|
55
|
+
data = build_job_data(job)
|
56
|
+
|
57
|
+
::Rollbar.scope(:request => data).error(e, :use_exception_level_filters => true)
|
58
|
+
end
|
59
|
+
|
60
|
+
def self.build_job_data(job)
|
61
|
+
return nil unless ::Rollbar.configuration.report_dj_data
|
62
|
+
|
63
|
+
JobData.new(job).to_hash
|
64
|
+
end
|
19
65
|
end
|
20
66
|
end
|
data/lib/rollbar/json.rb
CHANGED
@@ -6,23 +6,20 @@ module Rollbar
|
|
6
6
|
attr_accessor :dump_method
|
7
7
|
attr_accessor :load_method
|
8
8
|
|
9
|
-
def
|
10
|
-
require '
|
9
|
+
def load_oj
|
10
|
+
require 'oj'
|
11
11
|
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
end
|
12
|
+
options = { :mode=> :compat,
|
13
|
+
:use_to_json => false,
|
14
|
+
:symbol_keys => false,
|
15
|
+
:circular => false
|
16
|
+
}
|
18
17
|
|
19
|
-
self.dump_method = proc { |obj|
|
20
|
-
self.load_method
|
21
|
-
self.backend_name
|
18
|
+
self.dump_method = proc { |obj| Oj.dump(obj, options) }
|
19
|
+
self.load_method = proc { |obj| Oj.load(obj, options) }
|
20
|
+
self.backend_name = :oj
|
22
21
|
|
23
22
|
true
|
24
|
-
rescue StandardError, ScriptError => err
|
25
|
-
Rollbar.log_debug('%p while loading JSON library: %s' % [err, err.message])
|
26
23
|
end
|
27
24
|
|
28
25
|
def dump(object)
|
@@ -34,7 +31,7 @@ module Rollbar
|
|
34
31
|
end
|
35
32
|
|
36
33
|
def setup
|
37
|
-
|
34
|
+
load_oj
|
38
35
|
end
|
39
36
|
end
|
40
37
|
end
|
@@ -25,7 +25,7 @@ module Rollbar
|
|
25
25
|
post_params = rollbar_filtered_params(sensitive_params, rollbar_post_params(rack_req))
|
26
26
|
raw_body_params = rollbar_filtered_params(sensitive_params, mergeable_raw_body_params(rack_req))
|
27
27
|
cookies = rollbar_filtered_params(sensitive_params, rollbar_request_cookies(rack_req))
|
28
|
-
session = rollbar_filtered_params(sensitive_params,
|
28
|
+
session = rollbar_filtered_params(sensitive_params, rollbar_request_session(rack_req))
|
29
29
|
route_params = rollbar_filtered_params(sensitive_params, rollbar_route_params(env))
|
30
30
|
|
31
31
|
params = request_params.merge(get_params).merge(post_params).merge(raw_body_params)
|
@@ -150,6 +150,14 @@ module Rollbar
|
|
150
150
|
end
|
151
151
|
end
|
152
152
|
|
153
|
+
def rollbar_request_session(rack_req)
|
154
|
+
session = rack_req.session
|
155
|
+
|
156
|
+
session.to_hash
|
157
|
+
rescue
|
158
|
+
{}
|
159
|
+
end
|
160
|
+
|
153
161
|
def rollbar_request_cookies(rack_req)
|
154
162
|
rack_req.cookies
|
155
163
|
rescue
|
data/lib/rollbar/version.rb
CHANGED
data/rollbar.gemspec
CHANGED
@@ -368,7 +368,7 @@ describe HomeController do
|
|
368
368
|
end
|
369
369
|
end
|
370
370
|
|
371
|
-
context 'with multiple uploads' do
|
371
|
+
context 'with multiple uploads', :type => :request do
|
372
372
|
it "saves attachment data for all uploads" do
|
373
373
|
expect { post '/file_upload', :upload => [file1, file2] }.to raise_exception
|
374
374
|
sent_params = Rollbar.last_report[:request][:params]['upload']
|
@@ -379,6 +379,17 @@ describe HomeController do
|
|
379
379
|
end
|
380
380
|
end
|
381
381
|
|
382
|
+
context 'with session data', :type => :request do
|
383
|
+
before { get '/set_session_data' }
|
384
|
+
it 'reports the session data' do
|
385
|
+
expect { get '/use_session_data' }.to raise_exception
|
386
|
+
|
387
|
+
session_data = Rollbar.last_report[:request][:session]
|
388
|
+
|
389
|
+
expect(session_data['some_value']).to be_eql('this-is-a-cool-value')
|
390
|
+
end
|
391
|
+
end
|
392
|
+
|
382
393
|
after(:each) do
|
383
394
|
Rollbar.configure do |config|
|
384
395
|
config.logger = ::Rails.logger
|
@@ -0,0 +1,133 @@
|
|
1
|
+
require 'ostruct'
|
2
|
+
require 'delayed/backend/base'
|
3
|
+
|
4
|
+
# This code is taken from delayed_job/spec/delayed/backend/test.rb.
|
5
|
+
#
|
6
|
+
# It just works as a in memory job backend. Job#save is modified to create
|
7
|
+
# a new Delayed::Worker and call #work_off(1) so the job is processed inline.
|
8
|
+
|
9
|
+
module Delayed
|
10
|
+
module Backend
|
11
|
+
module Test
|
12
|
+
def self.run
|
13
|
+
worker.work_off(1)
|
14
|
+
end
|
15
|
+
|
16
|
+
def self.worker
|
17
|
+
@worker ||= ::Delayed::Worker.new
|
18
|
+
end
|
19
|
+
|
20
|
+
class Job
|
21
|
+
attr_accessor :id
|
22
|
+
attr_accessor :priority
|
23
|
+
attr_accessor :attempts
|
24
|
+
attr_accessor :handler
|
25
|
+
attr_accessor :last_error
|
26
|
+
attr_accessor :run_at
|
27
|
+
attr_accessor :locked_at
|
28
|
+
attr_accessor :locked_by
|
29
|
+
attr_accessor :failed_at
|
30
|
+
attr_accessor :queue
|
31
|
+
|
32
|
+
include Delayed::Backend::Base
|
33
|
+
|
34
|
+
cattr_accessor :id
|
35
|
+
self.id = 0
|
36
|
+
|
37
|
+
def initialize(hash = {})
|
38
|
+
self.attempts = 0
|
39
|
+
self.priority = 0
|
40
|
+
self.id = (self.class.id += 1)
|
41
|
+
hash.each { |k, v| send(:"#{k}=", v) }
|
42
|
+
end
|
43
|
+
|
44
|
+
def self.all
|
45
|
+
@jobs ||= []
|
46
|
+
end
|
47
|
+
|
48
|
+
def self.count
|
49
|
+
all.size
|
50
|
+
end
|
51
|
+
|
52
|
+
def self.delete_all
|
53
|
+
all.clear
|
54
|
+
end
|
55
|
+
|
56
|
+
def self.create(attrs = {})
|
57
|
+
new(attrs).tap do |o|
|
58
|
+
o.save
|
59
|
+
end
|
60
|
+
end
|
61
|
+
|
62
|
+
def self.create!(*args)
|
63
|
+
create(*args)
|
64
|
+
end
|
65
|
+
|
66
|
+
def self.clear_locks!(worker_name)
|
67
|
+
all.select { |j| j.locked_by == worker_name }.each do |j|
|
68
|
+
j.locked_by = nil
|
69
|
+
j.locked_at = nil
|
70
|
+
end
|
71
|
+
end
|
72
|
+
|
73
|
+
# Find a few candidate jobs to run (in case some immediately get locked by others).
|
74
|
+
def self.find_available(worker_name, limit = 5, max_run_time = Worker.max_run_time) # rubocop:disable CyclomaticComplexity, PerceivedComplexity
|
75
|
+
jobs = all.select do |j|
|
76
|
+
j.run_at <= db_time_now &&
|
77
|
+
(j.locked_at.nil? || j.locked_at < db_time_now - max_run_time || j.locked_by == worker_name) &&
|
78
|
+
!j.failed?
|
79
|
+
end
|
80
|
+
jobs.select! { |j| j.priority <= Worker.max_priority } if Worker.max_priority
|
81
|
+
jobs.select! { |j| j.priority >= Worker.min_priority } if Worker.min_priority
|
82
|
+
jobs.select! { |j| Worker.queues.include?(j.queue) } if Worker.queues.any?
|
83
|
+
jobs.sort_by! { |j| [j.priority, j.run_at] }[0..limit - 1]
|
84
|
+
end
|
85
|
+
|
86
|
+
# Lock this job for this worker.
|
87
|
+
# Returns true if we have the lock, false otherwise.
|
88
|
+
def lock_exclusively!(_max_run_time, worker)
|
89
|
+
now = self.class.db_time_now
|
90
|
+
if locked_by != worker
|
91
|
+
# We don't own this job so we will update the locked_by name and the locked_at
|
92
|
+
self.locked_at = now
|
93
|
+
self.locked_by = worker
|
94
|
+
end
|
95
|
+
|
96
|
+
true
|
97
|
+
end
|
98
|
+
|
99
|
+
def self.db_time_now
|
100
|
+
Time.current
|
101
|
+
end
|
102
|
+
|
103
|
+
def update_attributes(attrs = {})
|
104
|
+
attrs.each { |k, v| send(:"#{k}=", v) }
|
105
|
+
save
|
106
|
+
end
|
107
|
+
|
108
|
+
def destroy
|
109
|
+
self.class.all.delete(self)
|
110
|
+
end
|
111
|
+
|
112
|
+
def save
|
113
|
+
self.run_at ||= Time.current
|
114
|
+
|
115
|
+
self.class.all << self unless self.class.all.include?(self)
|
116
|
+
|
117
|
+
::Delayed::Backend::Test.run
|
118
|
+
|
119
|
+
true
|
120
|
+
end
|
121
|
+
|
122
|
+
def save!
|
123
|
+
save
|
124
|
+
end
|
125
|
+
|
126
|
+
def reload
|
127
|
+
reset
|
128
|
+
self
|
129
|
+
end
|
130
|
+
end
|
131
|
+
end
|
132
|
+
end
|
133
|
+
end
|
File without changes
|
@@ -32,6 +32,16 @@ class HomeController < ApplicationController
|
|
32
32
|
this = will_crash
|
33
33
|
end
|
34
34
|
|
35
|
+
def set_session_data
|
36
|
+
session[:some_value] = 'this-is-a-cool-value'
|
37
|
+
|
38
|
+
render :json => {}
|
39
|
+
end
|
40
|
+
|
41
|
+
def use_session_data
|
42
|
+
oh = this_is_crashing!
|
43
|
+
end
|
44
|
+
|
35
45
|
def current_user
|
36
46
|
@current_user ||= User.find_by_id(cookies[:session_id])
|
37
47
|
end
|
@@ -1,12 +1,16 @@
|
|
1
1
|
Dummy::Application.routes.draw do
|
2
|
-
root :to =>
|
2
|
+
root :to => 'home#index'
|
3
3
|
resources :users do
|
4
4
|
member { post :start_session }
|
5
5
|
end
|
6
6
|
|
7
|
-
get
|
8
|
-
put
|
9
|
-
match
|
10
|
-
|
11
|
-
|
7
|
+
get '/cause_exception' => 'home#cause_exception'
|
8
|
+
put '/deprecated_report_exception' => 'home#deprecated_report_exception'
|
9
|
+
match '/report_exception' => 'home#report_exception',
|
10
|
+
:via => [:get, :post, :put]
|
11
|
+
get '/current_user' => 'home#current_user'
|
12
|
+
post '/file_upload' => 'home#file_upload'
|
13
|
+
|
14
|
+
get '/set_session_data' => 'home#set_session_data'
|
15
|
+
get '/use_session_data' => 'home#use_session_data'
|
12
16
|
end
|
@@ -0,0 +1,35 @@
|
|
1
|
+
require 'spec_helper'
|
2
|
+
|
3
|
+
require 'rollbar/delayed_job'
|
4
|
+
require 'delayed/backend/test'
|
5
|
+
|
6
|
+
describe Rollbar::Delayed::JobData do
|
7
|
+
describe '#to_hash' do
|
8
|
+
let(:handler) { { 'foo' => 'bar' } }
|
9
|
+
|
10
|
+
let(:attrs) do
|
11
|
+
{
|
12
|
+
'id' => 1,
|
13
|
+
'priority' => 0,
|
14
|
+
'attempts' => 1,
|
15
|
+
'handler' => handler.to_yaml
|
16
|
+
}
|
17
|
+
end
|
18
|
+
|
19
|
+
let(:job) do
|
20
|
+
::Delayed::Backend::Test::Job.new(attrs)
|
21
|
+
end
|
22
|
+
|
23
|
+
subject { described_class.new(job) }
|
24
|
+
|
25
|
+
it 'returns the correct job data' do
|
26
|
+
expected_result = attrs.dup
|
27
|
+
expected_result.delete('id')
|
28
|
+
expected_result['handler'] = handler
|
29
|
+
|
30
|
+
result = subject.to_hash
|
31
|
+
|
32
|
+
expect(result).to be_eql(expected_result)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
@@ -6,41 +6,54 @@ describe Rollbar::Delayed, :reconfigure_notifier => true do
|
|
6
6
|
class FailingJob
|
7
7
|
class TestException < Exception; end
|
8
8
|
|
9
|
-
def
|
10
|
-
|
9
|
+
def do_job_please!(a, b)
|
10
|
+
this = will_crash_again!
|
11
11
|
end
|
12
12
|
end
|
13
13
|
|
14
|
-
|
15
|
-
|
16
|
-
|
14
|
+
before do
|
15
|
+
Rollbar::Delayed.wrap_worker
|
16
|
+
Delayed::Worker.backend = :test
|
17
17
|
|
18
|
-
|
18
|
+
Delayed::Backend::Test::Job.delete_all
|
19
|
+
end
|
19
20
|
|
20
|
-
|
21
|
-
|
22
|
-
@attempts = 0
|
23
|
-
end
|
24
|
-
end
|
21
|
+
let(:expected_args) do
|
22
|
+
[kind_of(NoMethodError), { :use_exception_level_filters => true }]
|
25
23
|
end
|
26
24
|
|
27
|
-
|
25
|
+
context 'with delayed method without arguments failing' do
|
26
|
+
it 'sends the exception' do
|
27
|
+
expect(Rollbar).to receive(:scope).with(kind_of(Hash)).and_call_original
|
28
|
+
expect_any_instance_of(Rollbar::Notifier).to receive(:error).with(*expected_args)
|
28
29
|
|
29
|
-
|
30
|
-
|
31
|
-
Delayed::Worker.delay_jobs = false
|
32
|
-
Delayed::Worker.backend = DummyBackend::Job
|
30
|
+
FailingJob.new.delay.do_job_please!(:foo, :bar)
|
31
|
+
end
|
33
32
|
end
|
34
33
|
|
35
|
-
let(:expected_args) do
|
36
|
-
[kind_of(FailingJob::TestException), { :use_exception_level_filters => true}]
|
37
|
-
end
|
38
34
|
|
39
|
-
|
40
|
-
|
35
|
+
describe '.build_job_data' do
|
36
|
+
let(:job) { double(:payload_object => {}) }
|
37
|
+
|
38
|
+
context 'if report_dj_data is disabled' do
|
39
|
+
before do
|
40
|
+
allow(Rollbar.configuration).to receive(:report_dj_data).and_return(false)
|
41
|
+
end
|
42
|
+
|
43
|
+
it 'returns nil' do
|
44
|
+
expect(described_class.build_job_data(job)).to be_nil
|
45
|
+
end
|
46
|
+
end
|
47
|
+
|
48
|
+
context 'with report_dj_data enabled' do
|
49
|
+
before do
|
50
|
+
allow(Rollbar.configuration).to receive(:report_dj_data).and_return(true)
|
51
|
+
end
|
41
52
|
|
42
|
-
|
43
|
-
|
44
|
-
|
53
|
+
it 'returns a hash' do
|
54
|
+
result = described_class.build_job_data(job)
|
55
|
+
expect(result).to be_kind_of(Hash)
|
56
|
+
end
|
57
|
+
end
|
45
58
|
end
|
46
59
|
end
|
data/spec/rollbar/json_spec.rb
CHANGED
@@ -7,23 +7,37 @@ describe Rollbar::JSON do
|
|
7
7
|
Rollbar::JSON.setup
|
8
8
|
end
|
9
9
|
|
10
|
+
let(:payload) do
|
11
|
+
{ :foo => :bar }
|
12
|
+
end
|
13
|
+
|
14
|
+
let(:options) do
|
15
|
+
{
|
16
|
+
:mode => :compat,
|
17
|
+
:use_to_json => false,
|
18
|
+
:symbol_keys => false,
|
19
|
+
:circular => false
|
20
|
+
}
|
21
|
+
end
|
22
|
+
|
10
23
|
describe '.dump' do
|
11
24
|
it 'has JSON as backend' do
|
12
|
-
expect(Rollbar::JSON.backend_name).to be_eql(:
|
25
|
+
expect(Rollbar::JSON.backend_name).to be_eql(:oj)
|
13
26
|
end
|
14
27
|
|
28
|
+
|
15
29
|
it 'calls JSON.generate' do
|
16
|
-
expect(::
|
30
|
+
expect(::Oj).to receive(:dump).once.with(payload, options)
|
17
31
|
|
18
|
-
Rollbar::JSON.dump(
|
32
|
+
Rollbar::JSON.dump(payload)
|
19
33
|
end
|
20
34
|
end
|
21
35
|
|
22
36
|
describe '.load' do
|
23
37
|
it 'calls MultiJson.load' do
|
24
|
-
expect(::
|
38
|
+
expect(::Oj).to receive(:load).once.with(payload, options)
|
25
39
|
|
26
|
-
Rollbar::JSON.load(
|
40
|
+
Rollbar::JSON.load(payload)
|
27
41
|
end
|
28
42
|
end
|
29
43
|
end
|
data/spec/rollbar_spec.rb
CHANGED
@@ -1564,14 +1564,14 @@ describe Rollbar do
|
|
1564
1564
|
context "send_failsafe" do
|
1565
1565
|
let(:exception) { StandardError.new }
|
1566
1566
|
|
1567
|
-
it "
|
1567
|
+
it "doesn't crash when given a message and exception" do
|
1568
1568
|
sent_payload = notifier.send(:send_failsafe, "test failsafe", exception)
|
1569
1569
|
|
1570
|
-
expected_message = 'Failsafe from rollbar-gem
|
1570
|
+
expected_message = 'Failsafe from rollbar-gem. StandardError: test failsafe'
|
1571
1571
|
expect(sent_payload['data'][:body][:message][:body]).to be_eql(expected_message)
|
1572
1572
|
end
|
1573
1573
|
|
1574
|
-
it "
|
1574
|
+
it "doesn't crash when given all nils" do
|
1575
1575
|
notifier.send(:send_failsafe, nil, nil)
|
1576
1576
|
end
|
1577
1577
|
|
@@ -1579,10 +1579,29 @@ describe Rollbar do
|
|
1579
1579
|
it 'just sends the given message' do
|
1580
1580
|
sent_payload = notifier.send(:send_failsafe, "test failsafe", nil)
|
1581
1581
|
|
1582
|
-
expected_message = 'Failsafe from rollbar-gem
|
1582
|
+
expected_message = 'Failsafe from rollbar-gem. test failsafe'
|
1583
1583
|
expect(sent_payload['data'][:body][:message][:body]).to be_eql(expected_message)
|
1584
1584
|
end
|
1585
1585
|
end
|
1586
|
+
|
1587
|
+
context 'if the exception has a backtrace' do
|
1588
|
+
let(:backtrace) { ['func3', 'func2', 'func1'] }
|
1589
|
+
let(:failsafe_reason) { 'StandardError in func3: test failsafe' }
|
1590
|
+
let(:expected_body) { "Failsafe from rollbar-gem. #{failsafe_reason}" }
|
1591
|
+
let(:expected_log_message) do
|
1592
|
+
"[Rollbar] Sending failsafe response due to #{failsafe_reason}"
|
1593
|
+
end
|
1594
|
+
|
1595
|
+
before { exception.set_backtrace(backtrace) }
|
1596
|
+
|
1597
|
+
it 'adds the nearest frame to the message' do
|
1598
|
+
expect(notifier).to receive(:log_error).with(expected_log_message)
|
1599
|
+
|
1600
|
+
sent_payload = notifier.send(:send_failsafe, "test failsafe", exception)
|
1601
|
+
|
1602
|
+
expect(sent_payload['data'][:body][:message][:body]).to be_eql(expected_body)
|
1603
|
+
end
|
1604
|
+
end
|
1586
1605
|
end
|
1587
1606
|
|
1588
1607
|
context 'when reporting internal error with nil context' do
|
data/spec/spec_helper.rb
CHANGED
@@ -20,6 +20,7 @@ Rake::Task['dummy:db:setup'].invoke
|
|
20
20
|
Dir["#{File.dirname(__FILE__)}/support/**/*.rb"].each { |f| require f }
|
21
21
|
|
22
22
|
RSpec.configure do |config|
|
23
|
+
config.extend(Helpers)
|
23
24
|
config.include(NotifierHelpers)
|
24
25
|
config.include(FixtureHelpers)
|
25
26
|
config.include(EncodingHelpers)
|
@@ -52,7 +53,3 @@ RSpec.configure do |config|
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
|
55
|
-
def local?
|
56
|
-
ENV['LOCAL'] == '1'
|
57
|
-
end
|
58
|
-
|
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: 2.
|
4
|
+
version: 2.3.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-09-
|
11
|
+
date: 2015-09-17 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rails
|
@@ -178,6 +178,20 @@ dependencies:
|
|
178
178
|
- - ">="
|
179
179
|
- !ruby/object:Gem::Version
|
180
180
|
version: '0'
|
181
|
+
- !ruby/object:Gem::Dependency
|
182
|
+
name: oj
|
183
|
+
requirement: !ruby/object:Gem::Requirement
|
184
|
+
requirements:
|
185
|
+
- - "~>"
|
186
|
+
- !ruby/object:Gem::Version
|
187
|
+
version: 2.12.14
|
188
|
+
type: :runtime
|
189
|
+
prerelease: false
|
190
|
+
version_requirements: !ruby/object:Gem::Requirement
|
191
|
+
requirements:
|
192
|
+
- - "~>"
|
193
|
+
- !ruby/object:Gem::Version
|
194
|
+
version: 2.12.14
|
181
195
|
description: Easy and powerful exception tracking for Ruby
|
182
196
|
email:
|
183
197
|
- support@rollbar.com
|
@@ -256,6 +270,8 @@ files:
|
|
256
270
|
- spec/controllers/home_controller_spec.rb
|
257
271
|
- spec/delay/sidekiq_spec.rb
|
258
272
|
- spec/delay/sucker_punch_spec.rb
|
273
|
+
- spec/delayed/backend/test.rb
|
274
|
+
- spec/delayed/serialization/test.rb
|
259
275
|
- spec/dummyapp/.gitignore
|
260
276
|
- spec/dummyapp/Rakefile
|
261
277
|
- spec/dummyapp/app/assets/javascripts/application.js
|
@@ -318,6 +334,7 @@ files:
|
|
318
334
|
- spec/rollbar/delay/girl_friday_spec.rb
|
319
335
|
- spec/rollbar/delay/resque_spec.rb
|
320
336
|
- spec/rollbar/delay/thread_spec.rb
|
337
|
+
- spec/rollbar/delayed_job/job_data.rb
|
321
338
|
- spec/rollbar/delayed_job_spec.rb
|
322
339
|
- spec/rollbar/encoding/encoder_spec.rb
|
323
340
|
- spec/rollbar/json_spec.rb
|
@@ -338,6 +355,7 @@ files:
|
|
338
355
|
- spec/support/encoding_helpers.rb
|
339
356
|
- spec/support/fixture_helpers.rb
|
340
357
|
- spec/support/get_ip_raising.rb
|
358
|
+
- spec/support/helpers.rb
|
341
359
|
- spec/support/notifier_helpers.rb
|
342
360
|
- spec/support/shared_contexts.rb
|
343
361
|
homepage: https://rollbar.com
|
@@ -368,6 +386,8 @@ test_files:
|
|
368
386
|
- spec/controllers/home_controller_spec.rb
|
369
387
|
- spec/delay/sidekiq_spec.rb
|
370
388
|
- spec/delay/sucker_punch_spec.rb
|
389
|
+
- spec/delayed/backend/test.rb
|
390
|
+
- spec/delayed/serialization/test.rb
|
371
391
|
- spec/dummyapp/.gitignore
|
372
392
|
- spec/dummyapp/Rakefile
|
373
393
|
- spec/dummyapp/app/assets/javascripts/application.js
|
@@ -430,6 +450,7 @@ test_files:
|
|
430
450
|
- spec/rollbar/delay/girl_friday_spec.rb
|
431
451
|
- spec/rollbar/delay/resque_spec.rb
|
432
452
|
- spec/rollbar/delay/thread_spec.rb
|
453
|
+
- spec/rollbar/delayed_job/job_data.rb
|
433
454
|
- spec/rollbar/delayed_job_spec.rb
|
434
455
|
- spec/rollbar/encoding/encoder_spec.rb
|
435
456
|
- spec/rollbar/json_spec.rb
|
@@ -450,5 +471,6 @@ test_files:
|
|
450
471
|
- spec/support/encoding_helpers.rb
|
451
472
|
- spec/support/fixture_helpers.rb
|
452
473
|
- spec/support/get_ip_raising.rb
|
474
|
+
- spec/support/helpers.rb
|
453
475
|
- spec/support/notifier_helpers.rb
|
454
476
|
- spec/support/shared_contexts.rb
|