rollbar 2.8.3 → 3.6.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +5 -5
- data/.codeclimate.yml +18 -0
- data/.github/pull_request_template.md +34 -0
- data/.github/workflows/ci.yml +67 -0
- data/.gitignore +3 -1
- data/.rubocop.yml +206 -7
- data/Appraisals +10 -10
- data/CHANGELOG.md +257 -3
- data/Gemfile +74 -13
- data/README.md +38 -833
- data/Rakefile +0 -0
- data/THANKS.md +1 -0
- data/data/rollbar.snippet.js +1 -1
- data/docs/configuration.md +64 -3
- data/docs/plugins.md +46 -0
- data/gemfiles/rails50.gemfile +56 -0
- data/gemfiles/rails51.gemfile +57 -0
- data/gemfiles/rails52.gemfile +56 -0
- data/gemfiles/rails60.gemfile +52 -0
- data/gemfiles/rails61.gemfile +52 -0
- data/gemfiles/rails70.gemfile +52 -0
- data/gemfiles/rails71.gemfile +52 -0
- data/lib/generators/rollbar/rollbar_generator.rb +24 -20
- data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +19 -5
- data/lib/rails/rollbar_runner.rb +26 -22
- data/lib/rollbar/capistrano.rb +78 -38
- data/lib/rollbar/capistrano3.rb +62 -1
- data/lib/rollbar/capistrano_tasks.rb +166 -0
- data/lib/rollbar/configuration.rb +291 -71
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/delayed_job.rb +23 -0
- data/lib/rollbar/delay/girl_friday.rb +4 -9
- data/lib/rollbar/delay/resque.rb +3 -6
- data/lib/rollbar/delay/shoryuken.rb +36 -0
- data/lib/rollbar/delay/sidekiq.rb +6 -8
- data/lib/rollbar/delay/sucker_punch.rb +17 -22
- data/lib/rollbar/delay/thread.rb +74 -3
- data/lib/rollbar/deploy.rb +91 -0
- data/lib/rollbar/encoding/encoder.rb +22 -11
- data/lib/rollbar/encoding.rb +2 -7
- data/lib/rollbar/exception_reporter.rb +36 -12
- data/lib/rollbar/item/backtrace.rb +118 -0
- data/lib/rollbar/item/frame.rb +121 -0
- data/lib/rollbar/item/locals.rb +103 -0
- data/lib/rollbar/item.rb +314 -0
- data/lib/rollbar/js.rb +0 -28
- data/lib/rollbar/json.rb +7 -55
- data/lib/rollbar/language_support.rb +7 -19
- data/lib/rollbar/lazy_store.rb +8 -12
- data/lib/rollbar/logger.rb +71 -0
- data/lib/rollbar/logger_proxy.rb +18 -1
- data/lib/rollbar/middleware/js/json_value.rb +36 -0
- data/lib/rollbar/middleware/js.rb +297 -0
- data/lib/rollbar/middleware/rack/builder.rb +4 -4
- data/lib/rollbar/middleware/rack/test_session.rb +4 -4
- data/lib/rollbar/middleware/rack.rb +52 -0
- data/lib/rollbar/middleware/rails/rollbar.rb +19 -7
- data/lib/rollbar/middleware/rails/show_exceptions.rb +21 -9
- data/lib/rollbar/middleware/sinatra.rb +2 -40
- data/lib/rollbar/notifier/trace_with_bindings.rb +75 -0
- data/lib/rollbar/notifier.rb +913 -0
- data/lib/rollbar/plugin.rb +126 -0
- data/lib/rollbar/plugins/active_job.rb +54 -0
- data/lib/rollbar/plugins/basic_socket.rb +31 -0
- data/lib/rollbar/plugins/delayed_job/job_data.rb +50 -0
- data/lib/rollbar/plugins/delayed_job/plugin.rb +88 -0
- data/lib/rollbar/plugins/delayed_job.rb +12 -0
- data/lib/rollbar/plugins/error_context.rb +11 -0
- data/lib/rollbar/plugins/goalie.rb +65 -0
- data/lib/rollbar/plugins/rack.rb +18 -0
- data/lib/rollbar/plugins/rails/controller_methods.rb +56 -0
- data/lib/rollbar/plugins/rails/error_subscriber.rb +12 -0
- data/lib/rollbar/plugins/rails/railtie30.rb +18 -0
- data/lib/rollbar/plugins/rails/railtie32.rb +18 -0
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +37 -0
- data/lib/rollbar/plugins/rails.rb +89 -0
- data/lib/rollbar/plugins/rake.rb +73 -0
- data/lib/rollbar/plugins/resque/failure.rb +39 -0
- data/lib/rollbar/plugins/resque.rb +11 -0
- data/lib/rollbar/plugins/sidekiq/plugin.rb +77 -0
- data/lib/rollbar/plugins/sidekiq.rb +37 -0
- data/lib/rollbar/plugins/thread.rb +14 -0
- data/lib/rollbar/plugins/validations.rb +45 -0
- data/lib/rollbar/plugins.rb +47 -0
- data/lib/rollbar/rails.rb +0 -1
- data/lib/rollbar/rake_tasks.rb +4 -66
- data/lib/rollbar/request_data_extractor.rb +157 -117
- data/lib/rollbar/rollbar_test.rb +38 -0
- data/lib/rollbar/scrubbers/params.rb +133 -0
- data/lib/rollbar/scrubbers/url.rb +90 -35
- data/lib/rollbar/scrubbers.rb +13 -0
- data/lib/rollbar/truncation/frames_strategy.rb +2 -1
- data/lib/rollbar/truncation/min_body_strategy.rb +3 -4
- data/lib/rollbar/truncation/mixin.rb +1 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +126 -0
- data/lib/rollbar/truncation/remove_extra_strategy.rb +37 -0
- data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
- data/lib/rollbar/truncation/strings_strategy.rb +6 -5
- data/lib/rollbar/truncation.rb +10 -4
- data/lib/rollbar/util/hash.rb +37 -6
- data/lib/rollbar/util/ip_anonymizer.rb +33 -0
- data/lib/rollbar/util/ip_obfuscator.rb +1 -1
- data/lib/rollbar/util.rb +101 -55
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +91 -879
- data/lib/tasks/benchmark.rake +104 -0
- data/lib/tasks/tasks.rake +3 -3
- data/rollbar.gemspec +21 -32
- data/spec/support/rollbar_api.rb +67 -0
- metadata +78 -439
- data/.travis.yml +0 -155
- data/gemfiles/rails30.gemfile +0 -20
- data/gemfiles/rails31.gemfile +0 -16
- data/gemfiles/rails32.gemfile +0 -17
- data/gemfiles/rails40.gemfile +0 -17
- data/gemfiles/rails41.gemfile +0 -15
- data/gemfiles/rails42.gemfile +0 -15
- data/lib/rollbar/active_job.rb +0 -11
- data/lib/rollbar/active_record_extension.rb +0 -14
- data/lib/rollbar/core_ext/basic_socket.rb +0 -7
- data/lib/rollbar/core_ext/thread.rb +0 -9
- data/lib/rollbar/delayed_job.rb +0 -78
- data/lib/rollbar/encoding/legacy_encoder.rb +0 -20
- data/lib/rollbar/goalie.rb +0 -33
- data/lib/rollbar/js/frameworks/rails.rb +0 -29
- data/lib/rollbar/js/frameworks.rb +0 -6
- data/lib/rollbar/js/middleware.rb +0 -129
- data/lib/rollbar/js/version.rb +0 -5
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -15
- data/lib/rollbar/rack.rb +0 -9
- data/lib/rollbar/rails/controller_methods.rb +0 -40
- data/lib/rollbar/railtie.rb +0 -46
- data/lib/rollbar/rake.rb +0 -38
- data/lib/rollbar/sidekiq.rb +0 -40
- data/lib/rollbar/tasks/rollbar.cap +0 -45
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -455
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -139
- data/spec/delayed/serialization/test.rb +0 -0
- data/spec/dummyapp/.gitignore +0 -73
- data/spec/dummyapp/Rakefile +0 -7
- data/spec/dummyapp/app/assets/javascripts/application.js +0 -3
- data/spec/dummyapp/app/assets/stylesheets/application.css.scss +0 -37
- data/spec/dummyapp/app/controllers/application_controller.rb +0 -3
- data/spec/dummyapp/app/controllers/home_controller.rb +0 -60
- data/spec/dummyapp/app/controllers/users_controller.rb +0 -17
- data/spec/dummyapp/app/helpers/.gitkeep +0 -0
- data/spec/dummyapp/app/mailers/.gitkeep +0 -0
- data/spec/dummyapp/app/models/.gitkeep +0 -0
- data/spec/dummyapp/app/models/user.rb +0 -7
- data/spec/dummyapp/app/views/devise/registrations/edit.html.erb +0 -27
- data/spec/dummyapp/app/views/devise/registrations/new.html.erb +0 -20
- data/spec/dummyapp/app/views/devise/shared/_links.html.erb +0 -25
- data/spec/dummyapp/app/views/home/cause_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/home/index.html.erb +0 -4
- data/spec/dummyapp/app/views/home/report_exception.html.erb +0 -1
- data/spec/dummyapp/app/views/js/test.html.erb +0 -1
- data/spec/dummyapp/app/views/layouts/_messages.html.erb +0 -5
- data/spec/dummyapp/app/views/layouts/_navigation.html.erb +0 -21
- data/spec/dummyapp/app/views/layouts/application.html.erb +0 -25
- data/spec/dummyapp/app/views/layouts/simple.html.erb +0 -18
- data/spec/dummyapp/app/views/users/index.html.erb +0 -8
- data/spec/dummyapp/app/views/users/show.html.erb +0 -3
- data/spec/dummyapp/config/application.rb +0 -59
- data/spec/dummyapp/config/boot.rb +0 -10
- data/spec/dummyapp/config/database.yml +0 -25
- data/spec/dummyapp/config/environment.rb +0 -5
- data/spec/dummyapp/config/environments/development.rb +0 -37
- data/spec/dummyapp/config/environments/production.rb +0 -67
- data/spec/dummyapp/config/environments/test.rb +0 -37
- data/spec/dummyapp/config/initializers/backtrace_silencers.rb +0 -7
- data/spec/dummyapp/config/initializers/inflections.rb +0 -15
- data/spec/dummyapp/config/initializers/mime_types.rb +0 -5
- data/spec/dummyapp/config/initializers/rollbar.rb +0 -23
- data/spec/dummyapp/config/initializers/secret_token.rb +0 -7
- data/spec/dummyapp/config/initializers/session_store.rb +0 -8
- data/spec/dummyapp/config/initializers/wrap_parameters.rb +0 -16
- data/spec/dummyapp/config/locales/devise.en.yml +0 -58
- data/spec/dummyapp/config/locales/en.yml +0 -5
- data/spec/dummyapp/config/routes.rb +0 -17
- data/spec/dummyapp/config.ru +0 -4
- data/spec/dummyapp/db/migrate/20121121184652_devise_create_users.rb +0 -46
- data/spec/dummyapp/db/migrate/20121121184654_add_name_to_users.rb +0 -5
- data/spec/dummyapp/db/schema.rb +0 -35
- data/spec/dummyapp/db/seeds.rb +0 -12
- data/spec/dummyapp/lib/assets/.gitkeep +0 -0
- data/spec/dummyapp/public/404.html +0 -26
- data/spec/dummyapp/public/422.html +0 -26
- data/spec/dummyapp/public/500.html +0 -25
- data/spec/dummyapp/public/favicon.ico +0 -0
- data/spec/dummyapp/script/rails +0 -6
- data/spec/fixtures/file1 +0 -1
- data/spec/fixtures/file2 +0 -1
- data/spec/fixtures/payloads/message.json +0 -25
- data/spec/fixtures/payloads/sample.trace.json +0 -275
- data/spec/fixtures/payloads/sample.trace_chain.json +0 -530
- data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -24
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/active_job_spec.rb +0 -33
- data/spec/rollbar/configuration_spec.rb +0 -24
- data/spec/rollbar/delay/girl_friday_spec.rb +0 -41
- data/spec/rollbar/delay/resque_spec.rb +0 -37
- data/spec/rollbar/delay/thread_spec.rb +0 -27
- data/spec/rollbar/delayed_job/job_data.rb +0 -35
- data/spec/rollbar/delayed_job_spec.rb +0 -90
- data/spec/rollbar/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/js/frameworks/rails_spec.rb +0 -19
- data/spec/rollbar/js/middleware_spec.rb +0 -162
- data/spec/rollbar/json/oj_spec.rb +0 -18
- data/spec/rollbar/json_spec.rb +0 -110
- data/spec/rollbar/lazy_store_spec.rb +0 -99
- data/spec/rollbar/logger_proxy_spec.rb +0 -34
- data/spec/rollbar/middleware/rack/builder_spec.rb +0 -151
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/rake_spec.rb +0 -34
- data/spec/rollbar/request_data_extractor_spec.rb +0 -82
- data/spec/rollbar/scrubbers/url_spec.rb +0 -111
- data/spec/rollbar/sidekiq_spec.rb +0 -90
- data/spec/rollbar/truncation/frames_strategy_spec.rb +0 -70
- data/spec/rollbar/truncation/min_body_strategy_spec.rb +0 -57
- data/spec/rollbar/truncation/strings_strategy_spec.rb +0 -89
- data/spec/rollbar/truncation_spec.rb +0 -27
- data/spec/rollbar/util/hash_spec.rb +0 -22
- data/spec/rollbar/util_spec.rb +0 -19
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -2067
- data/spec/spec_helper.rb +0 -49
- data/spec/support/cause_exception.rb +0 -1
- data/spec/support/encoding_helpers.rb +0 -8
- data/spec/support/encodings/iso_8859_9 +0 -1
- data/spec/support/fixture_helpers.rb +0 -10
- data/spec/support/get_ip_raising.rb +0 -7
- data/spec/support/helpers.rb +0 -5
- data/spec/support/notifier_helpers.rb +0 -36
- data/spec/support/shared_contexts.rb +0 -12
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
describe Rollbar::LoggerProxy do
|
4
|
-
let(:logger) { double(:logger) }
|
5
|
-
let(:message) { 'the-message' }
|
6
|
-
|
7
|
-
subject { described_class.new(logger) }
|
8
|
-
|
9
|
-
shared_examples 'delegate to logger' do
|
10
|
-
it 'logs with correct level' do
|
11
|
-
expect(logger).to receive(level).with(message)
|
12
|
-
|
13
|
-
subject.send(level, message)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
%w(info error warn debug).each do |level|
|
18
|
-
describe "#{level}" do
|
19
|
-
it_should_behave_like 'delegate to logger' do
|
20
|
-
let(:level) { level }
|
21
|
-
end
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
describe '#call' do
|
26
|
-
context 'if the logger fails' do
|
27
|
-
it 'doesnt raise' do
|
28
|
-
allow(logger).to receive(:info).and_raise(StandardError.new)
|
29
|
-
|
30
|
-
expect { subject.log('info', message) }.not_to raise_error
|
31
|
-
end
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,151 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack'
|
3
|
-
require 'rack/builder'
|
4
|
-
require 'rack/mock'
|
5
|
-
require 'rollbar/middleware/rack/builder'
|
6
|
-
|
7
|
-
|
8
|
-
describe Rollbar::Middleware::Rack::Builder, :reconfigure_notifier => true do
|
9
|
-
class RackMockError < Exception; end
|
10
|
-
|
11
|
-
let(:action) do
|
12
|
-
proc { fail(RackMockError, 'the-error') }
|
13
|
-
end
|
14
|
-
|
15
|
-
let(:app) do
|
16
|
-
action_proc = action
|
17
|
-
|
18
|
-
Rack::Builder.new { run action_proc }
|
19
|
-
end
|
20
|
-
|
21
|
-
let(:request) do
|
22
|
-
Rack::MockRequest.new(app)
|
23
|
-
end
|
24
|
-
|
25
|
-
let(:exception) { kind_of(RackMockError) }
|
26
|
-
let(:uncaught_level) { Rollbar.configuration.uncaught_exception_level }
|
27
|
-
|
28
|
-
it 'reports the error to Rollbar' do
|
29
|
-
expect(Rollbar).to receive(:log).with(uncaught_level, exception, :use_exception_level_filters => true)
|
30
|
-
expect { request.get('/will_crash') }.to raise_error(exception)
|
31
|
-
end
|
32
|
-
|
33
|
-
context 'with GET parameters' do
|
34
|
-
let(:params) do
|
35
|
-
{ 'key' => 'value' }
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'sends them to Rollbar' do
|
39
|
-
expect do
|
40
|
-
request.get('/will_crash', :params => params)
|
41
|
-
end.to raise_error(exception)
|
42
|
-
|
43
|
-
expect(Rollbar.last_report[:request][:params]).to be_eql(params)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with POST parameters' do
|
48
|
-
let(:params) do
|
49
|
-
{ 'key' => 'value' }
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'sends them to Rollbar' do
|
53
|
-
expect do
|
54
|
-
request.post('/will_crash', :input => params.to_json, 'CONTENT_TYPE' => 'application/json')
|
55
|
-
end.to raise_error(exception)
|
56
|
-
|
57
|
-
expect(Rollbar.last_report[:request][:params]).to be_eql(params)
|
58
|
-
end
|
59
|
-
end
|
60
|
-
|
61
|
-
context 'with array POST parameters' do
|
62
|
-
let(:params) do
|
63
|
-
[{ :key => 'value'}, 'string', 10]
|
64
|
-
end
|
65
|
-
|
66
|
-
it 'sends a body.multi key in params' do
|
67
|
-
expect do
|
68
|
-
request.post('/will_crash', :input => params.to_json, 'CONTENT_TYPE' => 'application/json')
|
69
|
-
end.to raise_error(exception)
|
70
|
-
|
71
|
-
reported_params = Rollbar.last_report[:request][:params]
|
72
|
-
expect(reported_params['body.multi']).to be_eql([{'key' => 'value'}, 'string', 10])
|
73
|
-
end
|
74
|
-
end
|
75
|
-
|
76
|
-
context 'with not array or hash POST parameters' do
|
77
|
-
let(:params) { 1000 }
|
78
|
-
|
79
|
-
it 'sends a body.multi key in params' do
|
80
|
-
expect do
|
81
|
-
request.post('/will_crash', :input => params.to_json, 'CONTENT_TYPE' => 'application/json')
|
82
|
-
end.to raise_error(exception)
|
83
|
-
|
84
|
-
reported_params = Rollbar.last_report[:request][:params]
|
85
|
-
expect(reported_params['body.value']).to be_eql(1000)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
|
89
|
-
context 'with multiple HTTP_X_FORWARDED_PROTO values' do
|
90
|
-
let(:headers) do
|
91
|
-
{ 'HTTP_X_FORWARDED_PROTO' => 'https,http' }
|
92
|
-
end
|
93
|
-
|
94
|
-
it 'uses the first scheme to generate the url' do
|
95
|
-
expect do
|
96
|
-
request.post('/will_crash', headers)
|
97
|
-
end.to raise_error(exception)
|
98
|
-
|
99
|
-
last_report = Rollbar.last_report
|
100
|
-
expect(last_report[:request][:url]).to match(/https:/)
|
101
|
-
end
|
102
|
-
end
|
103
|
-
|
104
|
-
context 'without HTTP_X_FORWARDED_PROTO' do
|
105
|
-
it 'uses the the url_scheme set by Rack' do
|
106
|
-
expect do
|
107
|
-
request.post('/will_crash')
|
108
|
-
end.to raise_error(exception)
|
109
|
-
|
110
|
-
last_report = Rollbar.last_report
|
111
|
-
expect(last_report[:request][:url]).to match(/http:/)
|
112
|
-
end
|
113
|
-
end
|
114
|
-
|
115
|
-
context 'with single HTTP_X_FORWARDED_PROTO value' do
|
116
|
-
let(:headers) do
|
117
|
-
{ 'HTTP_X_FORWARDED_PROTO' => 'https' }
|
118
|
-
end
|
119
|
-
|
120
|
-
it 'uses the scheme received in X-Forwarded-Proto header' do
|
121
|
-
expect do
|
122
|
-
request.post('/will_crash', headers)
|
123
|
-
end.to raise_error(exception)
|
124
|
-
|
125
|
-
last_report = Rollbar.last_report
|
126
|
-
expect(last_report[:request][:url]).to match(/https:/)
|
127
|
-
end
|
128
|
-
end
|
129
|
-
|
130
|
-
context 'with person data' do
|
131
|
-
let(:person_data) do
|
132
|
-
{ 'email' => 'person@example.com' }
|
133
|
-
end
|
134
|
-
|
135
|
-
it 'includes person data from env' do
|
136
|
-
expect do
|
137
|
-
request.get('/will_crash', 'rollbar.person_data' => person_data)
|
138
|
-
end.to raise_error(exception)
|
139
|
-
|
140
|
-
expect(Rollbar.last_report[:person]).to be_eql(person_data)
|
141
|
-
end
|
142
|
-
|
143
|
-
it 'includes empty person data when not in env' do
|
144
|
-
expect do
|
145
|
-
request.get('/will_crash')
|
146
|
-
end.to raise_error(exception)
|
147
|
-
|
148
|
-
expect(Rollbar.last_report[:person]).to be_eql({})
|
149
|
-
end
|
150
|
-
end
|
151
|
-
end
|
@@ -1,197 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/middleware/sinatra'
|
3
|
-
require 'sinatra/base'
|
4
|
-
require 'rack/test'
|
5
|
-
|
6
|
-
class SinatraDummy < Sinatra::Base
|
7
|
-
class DummyError < StandardError; end
|
8
|
-
|
9
|
-
use Rollbar::Middleware::Sinatra
|
10
|
-
|
11
|
-
get '/foo' do
|
12
|
-
raise DummyError.new
|
13
|
-
end
|
14
|
-
|
15
|
-
get '/bar' do
|
16
|
-
'this will not crash'
|
17
|
-
end
|
18
|
-
|
19
|
-
post '/crash_post' do
|
20
|
-
raise DummyError.new
|
21
|
-
end
|
22
|
-
end
|
23
|
-
|
24
|
-
describe Rollbar::Middleware::Sinatra, :reconfigure_notifier => true do
|
25
|
-
include Rack::Test::Methods
|
26
|
-
|
27
|
-
def app
|
28
|
-
SinatraDummy
|
29
|
-
end
|
30
|
-
|
31
|
-
let(:logger_mock) { double('logger').as_null_object }
|
32
|
-
|
33
|
-
before do
|
34
|
-
Rollbar.configure do |config|
|
35
|
-
config.logger = logger_mock
|
36
|
-
config.framework = 'Sinatra'
|
37
|
-
end
|
38
|
-
end
|
39
|
-
|
40
|
-
let(:uncaught_level) do
|
41
|
-
Rollbar.configuration.uncaught_exception_level
|
42
|
-
end
|
43
|
-
|
44
|
-
let(:expected_report_args) do
|
45
|
-
[uncaught_level, exception, { :use_exception_level_filters => true }]
|
46
|
-
end
|
47
|
-
|
48
|
-
describe '#call' do
|
49
|
-
context 'for a crashing endpoint' do
|
50
|
-
# this is the default for test mode in Sinatra
|
51
|
-
context 'with raise_errors? == true' do
|
52
|
-
let(:exception) { kind_of(SinatraDummy::DummyError) }
|
53
|
-
|
54
|
-
before do
|
55
|
-
allow(app.settings).to receive(:raise_errors?).and_return(true)
|
56
|
-
end
|
57
|
-
|
58
|
-
it 'reports the error to Rollbar API and raises error' do
|
59
|
-
expect(Rollbar).to receive(:log).with(*expected_report_args)
|
60
|
-
|
61
|
-
expect do
|
62
|
-
get '/foo'
|
63
|
-
end.to raise_error(SinatraDummy::DummyError)
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
context 'with raise_errors? == false' do
|
68
|
-
let(:exception) { kind_of(SinatraDummy::DummyError) }
|
69
|
-
|
70
|
-
before do
|
71
|
-
allow(app.settings).to receive(:raise_errors?).and_return(false)
|
72
|
-
end
|
73
|
-
|
74
|
-
it 'reports the error to Rollbar, but nothing is raised' do
|
75
|
-
expect(Rollbar).to receive(:log).with(*expected_report_args)
|
76
|
-
get '/foo'
|
77
|
-
end
|
78
|
-
end
|
79
|
-
end
|
80
|
-
|
81
|
-
context 'for a NOT crashing endpoint' do
|
82
|
-
it 'doesnt report any error to Rollbar API' do
|
83
|
-
expect(Rollbar).not_to receive(:log)
|
84
|
-
get '/bar'
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
context 'if the middleware itself fails' do
|
89
|
-
let(:exception) { Exception.new }
|
90
|
-
|
91
|
-
before do
|
92
|
-
allow_any_instance_of(described_class).to receive(:framework_error).and_raise(exception)
|
93
|
-
allow(app.settings).to receive(:raise_errors?).and_return(false)
|
94
|
-
end
|
95
|
-
|
96
|
-
it 'reports the report error' do
|
97
|
-
expect(Rollbar).to receive(:log).with(*expected_report_args)
|
98
|
-
|
99
|
-
expect do
|
100
|
-
get '/foo'
|
101
|
-
end.to raise_error(exception)
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
context 'with GET parameters' do
|
106
|
-
let(:exception) { kind_of(SinatraDummy::DummyError) }
|
107
|
-
let(:params) do
|
108
|
-
{
|
109
|
-
'key' => 'value'
|
110
|
-
}
|
111
|
-
end
|
112
|
-
|
113
|
-
it 'appear in the sent payload' do
|
114
|
-
expect do
|
115
|
-
get '/foo', params
|
116
|
-
end.to raise_error(exception)
|
117
|
-
|
118
|
-
expect(Rollbar.last_report[:request][:params]).to be_eql(params)
|
119
|
-
end
|
120
|
-
end
|
121
|
-
|
122
|
-
context 'with POST parameters' do
|
123
|
-
let(:exception) { kind_of(SinatraDummy::DummyError) }
|
124
|
-
let(:params) do
|
125
|
-
{
|
126
|
-
'key' => 'value'
|
127
|
-
}
|
128
|
-
end
|
129
|
-
|
130
|
-
it 'appear in the sent payload' do
|
131
|
-
expect do
|
132
|
-
post '/crash_post', params
|
133
|
-
end.to raise_error(exception)
|
134
|
-
|
135
|
-
expect(Rollbar.last_report[:request][:params]).to be_eql(params)
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
context 'with JSON POST parameters' do
|
140
|
-
let(:exception) { kind_of(SinatraDummy::DummyError) }
|
141
|
-
let(:params) do
|
142
|
-
{
|
143
|
-
'key' => 'value'
|
144
|
-
}
|
145
|
-
end
|
146
|
-
|
147
|
-
it 'appears in the sent payload when application/json is the content type' do
|
148
|
-
expect do
|
149
|
-
post '/crash_post', params.to_json, { 'CONTENT_TYPE' => 'application/json' }
|
150
|
-
end.to raise_error(exception)
|
151
|
-
|
152
|
-
expect(Rollbar.last_report[:request][:params]).to be_eql(params)
|
153
|
-
end
|
154
|
-
|
155
|
-
it 'appears in the sent payload when the accepts header contains json' do
|
156
|
-
expect do
|
157
|
-
post '/crash_post', params, { 'ACCEPT' => 'application/vnd.github.v3+json' }
|
158
|
-
end.to raise_error(exception)
|
159
|
-
|
160
|
-
expect(Rollbar.last_report[:request][:params]).to be_eql(params)
|
161
|
-
end
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'resets the notifier in every request' do
|
165
|
-
get '/bar'
|
166
|
-
id1 = Rollbar.notifier.object_id
|
167
|
-
|
168
|
-
get '/bar'
|
169
|
-
id2 = Rollbar.notifier.object_id
|
170
|
-
|
171
|
-
expect(id1).not_to be_eql(id2)
|
172
|
-
end
|
173
|
-
|
174
|
-
context 'with person data' do
|
175
|
-
let(:exception) { kind_of(SinatraDummy::DummyError) }
|
176
|
-
let(:person_data) do
|
177
|
-
{ 'email' => 'person@example.com' }
|
178
|
-
end
|
179
|
-
|
180
|
-
it 'includes person data from env' do
|
181
|
-
expect do
|
182
|
-
get '/foo', {}, 'rollbar.person_data' => person_data
|
183
|
-
end.to raise_error(exception)
|
184
|
-
|
185
|
-
expect(Rollbar.last_report[:person]).to be_eql(person_data)
|
186
|
-
end
|
187
|
-
|
188
|
-
it 'includes empty person data when not in env' do
|
189
|
-
expect do
|
190
|
-
get '/foo'
|
191
|
-
end.to raise_error(exception)
|
192
|
-
|
193
|
-
expect(Rollbar.last_report[:person]).to be_eql({})
|
194
|
-
end
|
195
|
-
end
|
196
|
-
end
|
197
|
-
end
|
data/spec/rollbar/rake_spec.rb
DELETED
@@ -1,34 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/rake'
|
3
|
-
|
4
|
-
describe Rollbar::Rake do
|
5
|
-
let(:application) { Rake::Application.new }
|
6
|
-
let(:exception) { Exception.new }
|
7
|
-
|
8
|
-
context 'with supported rake version' do
|
9
|
-
before do
|
10
|
-
allow(Rollbar::Rake).to receive(:rake_version).and_return('0.9.0')
|
11
|
-
end
|
12
|
-
|
13
|
-
it 'reports error to Rollbar' do
|
14
|
-
expect(Rollbar::Rake).not_to receive(:skip_patch)
|
15
|
-
expect(Rollbar).to receive(:error).with(exception, :use_exception_level_filters => true)
|
16
|
-
expect(application).to receive(:orig_display_error_message).with(exception)
|
17
|
-
|
18
|
-
Rollbar::Rake.patch! # Really here Rake is already patched
|
19
|
-
application.display_error_message(exception)
|
20
|
-
end
|
21
|
-
end
|
22
|
-
|
23
|
-
context 'with unsupported rake version' do
|
24
|
-
before do
|
25
|
-
allow(Rollbar::Rake).to receive(:rake_version).and_return('0.8.7')
|
26
|
-
end
|
27
|
-
|
28
|
-
it 'reports error to Rollbar' do
|
29
|
-
expect(Rollbar::Rake).to receive(:skip_patch)
|
30
|
-
|
31
|
-
Rollbar::Rake.patch!
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
@@ -1,82 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rack/mock'
|
3
|
-
|
4
|
-
require 'rollbar/request_data_extractor'
|
5
|
-
|
6
|
-
class ExtractorDummy
|
7
|
-
include Rollbar::RequestDataExtractor
|
8
|
-
end
|
9
|
-
|
10
|
-
describe Rollbar::RequestDataExtractor do
|
11
|
-
subject { ExtractorDummy.new }
|
12
|
-
|
13
|
-
let(:env) do
|
14
|
-
Rack::MockRequest.env_for('/', 'HTTP_HOST' => 'localhost:81', 'HTTP_X_FORWARDED_HOST' => 'example.org:9292')
|
15
|
-
end
|
16
|
-
|
17
|
-
describe '#extract_request_data_from_rack' do
|
18
|
-
let(:scrubber) { double }
|
19
|
-
|
20
|
-
it 'returns a Hash object' do
|
21
|
-
scrubber_config = {
|
22
|
-
:scrub_fields => kind_of(Array),
|
23
|
-
:scrub_user => Rollbar.configuration.scrub_user,
|
24
|
-
:scrub_password => Rollbar.configuration.scrub_password,
|
25
|
-
:randomize_scrub_length => Rollbar.configuration.randomize_scrub_length
|
26
|
-
}
|
27
|
-
expect(Rollbar::Scrubbers::URL).to receive(:new).with(scrubber_config).and_return(scrubber)
|
28
|
-
expect(scrubber).to receive(:call).with(kind_of(String))
|
29
|
-
|
30
|
-
result = subject.extract_request_data_from_rack(env)
|
31
|
-
|
32
|
-
expect(result).to be_kind_of(Hash)
|
33
|
-
end
|
34
|
-
|
35
|
-
context 'with invalid utf8 sequence in key', :if => RUBY_VERSION != '1.8.7' do
|
36
|
-
let(:data) do
|
37
|
-
File.read(File.expand_path('../../support/encodings/iso_8859_9', __FILE__)).force_encoding(Encoding::ISO_8859_9)
|
38
|
-
end
|
39
|
-
let(:env) do
|
40
|
-
env = Rack::MockRequest.env_for('/',
|
41
|
-
'HTTP_HOST' => 'localhost:81',
|
42
|
-
'HTTP_X_FORWARDED_HOST' => 'example.org:9292',
|
43
|
-
'CONTENT_TYPE' => 'application/json')
|
44
|
-
|
45
|
-
env['rack.session'] = { data => 'foo' }
|
46
|
-
env
|
47
|
-
end
|
48
|
-
|
49
|
-
it 'doesnt crash' do
|
50
|
-
result = subject.extract_request_data_from_rack(env)
|
51
|
-
|
52
|
-
expect(result).to be_kind_of(Hash)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
end
|
56
|
-
|
57
|
-
describe '#rollbar_scrubbed_value' do
|
58
|
-
context 'with random scrub length' do
|
59
|
-
before do
|
60
|
-
allow(Rollbar.configuration).to receive(:randomize_scrub_length).and_return(true)
|
61
|
-
end
|
62
|
-
|
63
|
-
let(:value) { 'herecomesaverylongvalue' }
|
64
|
-
|
65
|
-
it 'randomizes the scrubbed string' do
|
66
|
-
expect(subject.rollbar_scrubbed(value)).to match(/\*{3,8}/)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
|
70
|
-
context 'with no-random scrub length' do
|
71
|
-
before do
|
72
|
-
allow(Rollbar.configuration).to receive(:randomize_scrub_length).and_return(false)
|
73
|
-
end
|
74
|
-
|
75
|
-
let(:value) { 'herecomesaverylongvalue' }
|
76
|
-
|
77
|
-
it 'randomizes the scrubbed string' do
|
78
|
-
expect(subject.rollbar_scrubbed(value)).to match(/\*{#{value.length}}/)
|
79
|
-
end
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
@@ -1,111 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/language_support'
|
3
|
-
require 'rollbar/scrubbers/url'
|
4
|
-
|
5
|
-
describe Rollbar::Scrubbers::URL do
|
6
|
-
let(:options) do
|
7
|
-
{ :scrub_fields => [:password, :secret],
|
8
|
-
:scrub_user => false,
|
9
|
-
:scrub_password => false,
|
10
|
-
:randomize_scrub_length => true
|
11
|
-
}
|
12
|
-
end
|
13
|
-
|
14
|
-
subject { described_class.new(options) }
|
15
|
-
|
16
|
-
describe '#call' do
|
17
|
-
context 'cannot scrub URLs' do
|
18
|
-
next if Rollbar::LanguageSupport.can_scrub_url?
|
19
|
-
|
20
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
21
|
-
|
22
|
-
it 'returns the URL without any change' do
|
23
|
-
expect(subject.call(url)).to be_eql(url)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
|
27
|
-
context 'with ruby different from 1.8' do
|
28
|
-
next unless Rollbar::LanguageSupport.can_scrub_url?
|
29
|
-
|
30
|
-
context 'without data to be scrubbed' do
|
31
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
32
|
-
|
33
|
-
it 'returns the URL without any change' do
|
34
|
-
expect(subject.call(url)).to be_eql(url)
|
35
|
-
end
|
36
|
-
|
37
|
-
context 'with arrays in params' do
|
38
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path?foo[]=1&foo[]=2' }
|
39
|
-
|
40
|
-
it 'returns the URL without any change' do
|
41
|
-
expect(subject.call(url)).to be_eql(url)
|
42
|
-
end
|
43
|
-
end
|
44
|
-
end
|
45
|
-
|
46
|
-
context 'scrubbing user and password' do
|
47
|
-
let(:options) do
|
48
|
-
{
|
49
|
-
:scrub_fields => [],
|
50
|
-
:scrub_password => true,
|
51
|
-
:scrub_user => true
|
52
|
-
}
|
53
|
-
end
|
54
|
-
|
55
|
-
let(:url) { 'http://user:password@foo.com/some-interesting-path#fragment' }
|
56
|
-
|
57
|
-
it 'returns the URL without any change' do
|
58
|
-
expected_url = /http:\/\/\*{3,8}:\*{3,8}@foo.com\/some-interesting\-path#fragment/
|
59
|
-
|
60
|
-
expect(subject.call(url)).to match(expected_url)
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
context 'with params to be filtered' do
|
65
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password=mypassword&secret=somevalue#fragment' }
|
66
|
-
|
67
|
-
it 'returns the URL with some params filtered' do
|
68
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password=\*{3,8}&secret=\*{3,8}#fragment/
|
69
|
-
|
70
|
-
expect(subject.call(url)).to match(expected_url)
|
71
|
-
end
|
72
|
-
|
73
|
-
context 'having array params' do
|
74
|
-
let(:url) { 'http://foo.com/some-interesting-path?foo=bar&password[]=mypassword&password[]=otherpassword&secret=somevalue#fragment' }
|
75
|
-
|
76
|
-
it 'returns the URL with some params filtered' do
|
77
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password\[\]=\*{3,8}&password\[\]=\*{3,8}&secret=\*{3,8}#fragment/
|
78
|
-
|
79
|
-
expect(subject.call(url)).to match(expected_url)
|
80
|
-
end
|
81
|
-
end
|
82
|
-
end
|
83
|
-
|
84
|
-
context 'with no-random scrub length' do
|
85
|
-
let(:options) do
|
86
|
-
{ :scrub_fields => [:password, :secret],
|
87
|
-
:scrub_user => false,
|
88
|
-
:scrub_password => false,
|
89
|
-
:randomize_scrub_length => false
|
90
|
-
}
|
91
|
-
end
|
92
|
-
let(:password) { 'longpasswordishere' }
|
93
|
-
let(:url) { "http://foo.com/some-interesting-path?foo=bar&password=#{password}#fragment" }
|
94
|
-
|
95
|
-
it 'scrubs with same length than the scrubbed param' do
|
96
|
-
expected_url = /http:\/\/foo.com\/some-interesting-path\?foo=bar&password=\*{#{password.length}}#fragment/
|
97
|
-
|
98
|
-
expect(subject.call(url)).to match(expected_url)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
context 'with malformed URL or not able to be parsed' do
|
103
|
-
let(:url) { '\this\is\not\a\valid\url' }
|
104
|
-
|
105
|
-
it 'return the same url' do
|
106
|
-
expect(subject.call(url)).to be_eql(url)
|
107
|
-
end
|
108
|
-
end
|
109
|
-
end
|
110
|
-
end
|
111
|
-
end
|
@@ -1,90 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
unless RUBY_VERSION == '1.8.7'
|
4
|
-
require 'sidekiq'
|
5
|
-
require 'rollbar/sidekiq'
|
6
|
-
end
|
7
|
-
|
8
|
-
describe Rollbar::Sidekiq, :reconfigure_notifier => false do
|
9
|
-
describe '.handle_exception' do
|
10
|
-
let(:msg_or_context) { ['hello', 'error_backtrace', 'backtrace', 'goodbye'] }
|
11
|
-
let(:exception) { StandardError.new('oh noes') }
|
12
|
-
let(:rollbar) { double }
|
13
|
-
let(:expected_args) { { :request => { :params => ['hello', 'goodbye'] } } }
|
14
|
-
|
15
|
-
subject { described_class }
|
16
|
-
|
17
|
-
it 'constructs scope from filtered params' do
|
18
|
-
allow(rollbar).to receive(:error)
|
19
|
-
expect(Rollbar).to receive(:scope).with(expected_args) {rollbar}
|
20
|
-
|
21
|
-
described_class.handle_exception(msg_or_context, exception)
|
22
|
-
end
|
23
|
-
|
24
|
-
it 'sends the passed-in error to rollbar' do
|
25
|
-
allow(Rollbar).to receive(:scope).and_return(rollbar)
|
26
|
-
expect(rollbar).to receive(:error).with(exception, :use_exception_level_filters => true)
|
27
|
-
|
28
|
-
described_class.handle_exception(msg_or_context, exception)
|
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
|
-
|
63
|
-
it 'does not blow up and sends the error to rollbar if retry is true but there is no retry count' do
|
64
|
-
allow(Rollbar).to receive(:scope).and_return(rollbar)
|
65
|
-
expect(rollbar).to receive(:error)
|
66
|
-
|
67
|
-
msg_or_context = {"retry" => true}
|
68
|
-
|
69
|
-
expect {
|
70
|
-
described_class.handle_exception(msg_or_context, exception)
|
71
|
-
}.to_not raise_error
|
72
|
-
end
|
73
|
-
|
74
|
-
end
|
75
|
-
end
|
76
|
-
|
77
|
-
describe '#call' do
|
78
|
-
let(:msg) { ['hello'] }
|
79
|
-
let(:exception) { StandardError.new('oh noes') }
|
80
|
-
let(:middleware_block) { proc { raise exception } }
|
81
|
-
|
82
|
-
subject { Rollbar::Sidekiq.new }
|
83
|
-
|
84
|
-
it 'sends the error to Rollbar::Sidekiq.handle_exception' do
|
85
|
-
expect(Rollbar::Sidekiq).to receive(:handle_exception).with(msg, exception)
|
86
|
-
|
87
|
-
expect { subject.call(nil, msg, nil, &middleware_block) }.to raise_error(exception)
|
88
|
-
end
|
89
|
-
end
|
90
|
-
end unless RUBY_VERSION == '1.8.7'
|