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,70 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/truncation/frames_strategy'
|
3
|
-
|
4
|
-
describe Rollbar::Truncation::FramesStrategy do
|
5
|
-
def expand_frames(frames)
|
6
|
-
frames * (1 + 300 / frames.count)
|
7
|
-
end
|
8
|
-
|
9
|
-
describe '.call', :fixture => :payload do
|
10
|
-
context 'with trace key' do
|
11
|
-
let(:payload_fixture) { 'payloads/sample.trace.json' }
|
12
|
-
let(:frames) { payload['data']['body']['trace']['frames'].clone }
|
13
|
-
|
14
|
-
before do
|
15
|
-
payload['data']['body']['trace']['frames'] = expand_frames(frames)
|
16
|
-
end
|
17
|
-
|
18
|
-
it 'returns a new payload with 300 frames' do
|
19
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
20
|
-
|
21
|
-
new_frames = result['data']['body']['trace']['frames']
|
22
|
-
|
23
|
-
expect(new_frames.count).to be_eql(300)
|
24
|
-
expect(new_frames.first).to be_eql(frames.first)
|
25
|
-
expect(new_frames.last).to be_eql(frames.last)
|
26
|
-
end
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with trace_chain key' do
|
30
|
-
let(:payload_fixture) { 'payloads/sample.trace_chain.json' }
|
31
|
-
|
32
|
-
let(:frames1) { payload['data']['body']['trace_chain'][0]['frames'].clone }
|
33
|
-
let(:frames2) { payload['data']['body']['trace_chain'][1]['frames'].clone }
|
34
|
-
|
35
|
-
before do
|
36
|
-
payload['data']['body']['trace_chain'][0]['frames'] = expand_frames(frames1)
|
37
|
-
payload['data']['body']['trace_chain'][1]['frames'] = expand_frames(frames2)
|
38
|
-
end
|
39
|
-
|
40
|
-
it 'returns a new payload with 300 frames for each chain item' do
|
41
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
42
|
-
|
43
|
-
new_frames1 = result['data']['body']['trace_chain'][0]['frames']
|
44
|
-
new_frames2 = result['data']['body']['trace_chain'][1]['frames']
|
45
|
-
|
46
|
-
expect(new_frames1.count).to be_eql(300)
|
47
|
-
expect(new_frames1.first).to be_eql(frames1.first)
|
48
|
-
expect(new_frames1.last).to be_eql(frames1.last)
|
49
|
-
|
50
|
-
expect(new_frames2.count).to be_eql(300)
|
51
|
-
expect(new_frames2.first).to be_eql(frames2.first)
|
52
|
-
expect(new_frames2.last).to be_eql(frames2.last)
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
|
-
context 'without trace or trace_chain', :fixture => :payload do
|
57
|
-
let(:payload_fixture) { 'payloads/sample.trace.json' }
|
58
|
-
|
59
|
-
before do
|
60
|
-
payload['data']['body'].delete('trace')
|
61
|
-
end
|
62
|
-
|
63
|
-
it 'returns the original payload' do
|
64
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
65
|
-
|
66
|
-
expect(result).to be_eql(payload)
|
67
|
-
end
|
68
|
-
end
|
69
|
-
end
|
70
|
-
end
|
@@ -1,57 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/truncation/frames_strategy'
|
3
|
-
|
4
|
-
describe Rollbar::Truncation::MinBodyStrategy do
|
5
|
-
describe '.call', :fixture => :payload do
|
6
|
-
let(:message) { 'a' * 1_000 }
|
7
|
-
|
8
|
-
context 'with trace key ' do
|
9
|
-
let(:payload_fixture) { 'payloads/sample.trace.json' }
|
10
|
-
let!(:frames) { payload['data']['body']['trace']['frames'].clone }
|
11
|
-
|
12
|
-
before do
|
13
|
-
payload['data']['body']['trace']['exception']['message'] = message
|
14
|
-
end
|
15
|
-
|
16
|
-
it 'truncates the exception message and frames array' do
|
17
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
18
|
-
|
19
|
-
trace = result['data']['body']['trace']
|
20
|
-
expect(trace['frames'].count).to eq 2
|
21
|
-
expect(trace['exception']['message']).to be_eql('a' * 255)
|
22
|
-
end
|
23
|
-
end
|
24
|
-
|
25
|
-
context 'with trace_chain key ' do
|
26
|
-
let(:payload_fixture) { 'payloads/sample.trace_chain.json' }
|
27
|
-
let!(:frames1) { payload['data']['body']['trace_chain'][0]['frames'].clone }
|
28
|
-
let!(:frames2) { payload['data']['body']['trace_chain'][1]['frames'].clone }
|
29
|
-
|
30
|
-
before do
|
31
|
-
payload['data']['body']['trace_chain'][0]['exception']['message'] = message
|
32
|
-
payload['data']['body']['trace_chain'][1]['exception']['message'] = message
|
33
|
-
end
|
34
|
-
|
35
|
-
it 'truncates the exception message and frames array' do
|
36
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
37
|
-
|
38
|
-
traces = result['data']['body']['trace_chain']
|
39
|
-
expect(traces[0]['frames'].count).to eq 2
|
40
|
-
expect(traces[0]['exception']['message']).to be_eql('a' * 255)
|
41
|
-
|
42
|
-
expect(traces[1]['frames'].count).to eq 2
|
43
|
-
expect(traces[1]['exception']['message']).to be_eql('a' * 255)
|
44
|
-
end
|
45
|
-
end
|
46
|
-
|
47
|
-
context 'with a message payload' do
|
48
|
-
let(:payload_fixture) { 'payloads/sample.trace_chain.json' }
|
49
|
-
|
50
|
-
it "doesn't truncate anything and returns same payload" do
|
51
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
52
|
-
|
53
|
-
expect(result).to be_eql(payload)
|
54
|
-
end
|
55
|
-
end
|
56
|
-
end
|
57
|
-
end
|
@@ -1,89 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'spec_helper'
|
4
|
-
require 'rollbar/truncation/frames_strategy'
|
5
|
-
|
6
|
-
describe Rollbar::Truncation::StringsStrategy do
|
7
|
-
describe '.call' do
|
8
|
-
let(:long_message) { 'a' * 2000 }
|
9
|
-
let(:payload) do
|
10
|
-
{
|
11
|
-
'truncated' => long_message,
|
12
|
-
'not_truncated' => '123456',
|
13
|
-
'hash' => {
|
14
|
-
'inner_truncated' => long_message,
|
15
|
-
'inner_not_truncated' => '567',
|
16
|
-
'array' => ['12345678', '12', { 'inner_inner' => long_message }]
|
17
|
-
}
|
18
|
-
}
|
19
|
-
end
|
20
|
-
|
21
|
-
it 'should truncate all nested strings in the payload' do
|
22
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
23
|
-
|
24
|
-
expect(result['truncated'].size).to be_eql(1024)
|
25
|
-
expect(result['hash']['inner_truncated'].size).to be_eql(1024)
|
26
|
-
expect(result['hash']['array'][2]['inner_inner'].size).to be_eql(1024)
|
27
|
-
end
|
28
|
-
|
29
|
-
context 'with utf8 strings' do
|
30
|
-
let(:long_message) { 'Ŝǻмρļẻ śţяịņģ' + 'a' * 2000 }
|
31
|
-
let(:payload) do
|
32
|
-
{
|
33
|
-
'truncated' => long_message,
|
34
|
-
'not_truncated' => '123456',
|
35
|
-
}
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'should truncate utf8 strings properly' do
|
39
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
40
|
-
expect(result['truncated']).to match(/^Ŝǻмρļẻ śţяịņģa*\.{3}/)
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
|
-
context 'when first threshold is not enough' do
|
45
|
-
let(:payload) do
|
46
|
-
129.times.to_enum.reduce({}) do |hash, i|
|
47
|
-
hash[i.to_s] = 'a' * 1024
|
48
|
-
hash
|
49
|
-
end
|
50
|
-
end
|
51
|
-
|
52
|
-
it 'truncates to 512 size strings' do
|
53
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
54
|
-
|
55
|
-
expect(result['0'].size).to be_eql(512)
|
56
|
-
end
|
57
|
-
end
|
58
|
-
|
59
|
-
context 'when second threshold is still not enough' do
|
60
|
-
let(:payload) do
|
61
|
-
257.times.to_enum.reduce({}) do |hash, i|
|
62
|
-
hash[i.to_s] = 'a' * 1024
|
63
|
-
hash
|
64
|
-
end
|
65
|
-
end
|
66
|
-
|
67
|
-
it 'truncates to 256 size strings, the third threshold' do
|
68
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
69
|
-
|
70
|
-
expect(result['0'].size).to be_eql(256)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
|
74
|
-
context 'when third threshold is still not enough' do
|
75
|
-
let(:payload) do
|
76
|
-
1024.times.to_enum.reduce({}) do |hash, i|
|
77
|
-
hash[i.to_s] = 'a' * 1024
|
78
|
-
hash
|
79
|
-
end
|
80
|
-
end
|
81
|
-
|
82
|
-
it 'just return the value for third threshold' do
|
83
|
-
result = Rollbar::JSON.load(described_class.call(payload))
|
84
|
-
|
85
|
-
expect(result['0'].size).to be_eql(256)
|
86
|
-
end
|
87
|
-
end
|
88
|
-
end
|
89
|
-
end
|
@@ -1,27 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/truncation'
|
3
|
-
|
4
|
-
describe Rollbar::Truncation do
|
5
|
-
describe '.truncate' do
|
6
|
-
let(:payload) { {} }
|
7
|
-
|
8
|
-
context 'if truncation is not needed' do
|
9
|
-
it 'only calls RawStrategy is truncation is not needed' do
|
10
|
-
allow(described_class).to receive(:truncate?).and_return(false)
|
11
|
-
expect(Rollbar::Truncation::RawStrategy).to receive(:call).with(payload)
|
12
|
-
|
13
|
-
Rollbar::Truncation.truncate(payload)
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
context 'if truncation is needed' do
|
18
|
-
it 'calls the next strategy, FramesStrategy' do
|
19
|
-
allow(described_class).to receive(:truncate?).and_return(true, false)
|
20
|
-
expect(Rollbar::Truncation::RawStrategy).to receive(:call).with(payload)
|
21
|
-
expect(Rollbar::Truncation::FramesStrategy).to receive(:call).with(payload)
|
22
|
-
|
23
|
-
Rollbar::Truncation.truncate(payload)
|
24
|
-
end
|
25
|
-
end
|
26
|
-
end
|
27
|
-
end
|
@@ -1,22 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
require 'rollbar/util/hash'
|
3
|
-
|
4
|
-
describe Rollbar::Util::Hash do
|
5
|
-
let(:value) do
|
6
|
-
{
|
7
|
-
:foo => 'bar',
|
8
|
-
:bar => {
|
9
|
-
:foo => 'bar',
|
10
|
-
:bar => [{:foo => 'bar'}]
|
11
|
-
},
|
12
|
-
}
|
13
|
-
end
|
14
|
-
|
15
|
-
it 'converts the symbol keys to string' do
|
16
|
-
new_hash = described_class.deep_stringify_keys(value)
|
17
|
-
|
18
|
-
expect(new_hash['foo']).to be_eql('bar')
|
19
|
-
expect(new_hash['bar']['foo']).to be_eql('bar')
|
20
|
-
expect(new_hash['bar']['bar'][0]['foo']).to be_eql('bar')
|
21
|
-
end
|
22
|
-
end
|
data/spec/rollbar/util_spec.rb
DELETED
@@ -1,19 +0,0 @@
|
|
1
|
-
require 'spec_helper'
|
2
|
-
|
3
|
-
require 'rollbar/util'
|
4
|
-
|
5
|
-
describe Rollbar::Util do
|
6
|
-
describe '.deep_merge' do
|
7
|
-
context 'with nil arguments' do
|
8
|
-
let(:data) do
|
9
|
-
{ :foo => :bar }
|
10
|
-
end
|
11
|
-
|
12
|
-
it 'doesnt fail and returns same hash' do
|
13
|
-
result = Rollbar::Util.deep_merge(nil, data)
|
14
|
-
|
15
|
-
expect(result).to be_eql(data)
|
16
|
-
end
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
data/spec/rollbar_bc_spec.rb
DELETED
@@ -1,380 +0,0 @@
|
|
1
|
-
# encoding: UTF-8
|
2
|
-
|
3
|
-
require 'logger'
|
4
|
-
require 'spec_helper'
|
5
|
-
|
6
|
-
describe Rollbar do
|
7
|
-
let(:notifier) { Rollbar.notifier }
|
8
|
-
|
9
|
-
context 'bc_report_message' do
|
10
|
-
before do
|
11
|
-
configure
|
12
|
-
Rollbar.configure do |config|
|
13
|
-
config.logger = logger_mock
|
14
|
-
end
|
15
|
-
end
|
16
|
-
|
17
|
-
let(:logger_mock) { double('Rails.logger').as_null_object }
|
18
|
-
let(:user) do
|
19
|
-
User.create(:email => 'email@example.com',
|
20
|
-
:encrypted_password => '',
|
21
|
-
:created_at => Time.now,
|
22
|
-
:updated_at => Time.now)
|
23
|
-
end
|
24
|
-
|
25
|
-
it 'should report simple messages' do
|
26
|
-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
|
27
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
28
|
-
|
29
|
-
Rollbar.report_message('Test message')
|
30
|
-
end
|
31
|
-
|
32
|
-
it 'should not report anything when disabled' do
|
33
|
-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
|
34
|
-
|
35
|
-
Rollbar.configure do |config|
|
36
|
-
config.enabled = false
|
37
|
-
end
|
38
|
-
|
39
|
-
Rollbar.report_message('Test message that should be ignored')
|
40
|
-
end
|
41
|
-
|
42
|
-
it 'should report messages with extra data' do
|
43
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
44
|
-
Rollbar.report_message('Test message with extra data', 'debug', :foo => 'bar',
|
45
|
-
:hash => { :a => 123, :b => 'xyz' })
|
46
|
-
end
|
47
|
-
|
48
|
-
it 'should not crash with circular extra_data' do
|
49
|
-
a = { :foo => 'bar' }
|
50
|
-
b = { :a => a }
|
51
|
-
c = { :b => b }
|
52
|
-
a[:c] = c
|
53
|
-
|
54
|
-
logger_mock.should_receive(:error).with(/\[Rollbar\] Reporting internal error encountered while sending data to Rollbar./)
|
55
|
-
|
56
|
-
Rollbar.report_message('Test message with circular extra data', 'debug', a)
|
57
|
-
end
|
58
|
-
|
59
|
-
it 'should be able to report form validation errors when they are present' do
|
60
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
61
|
-
user.errors.add(:example, 'error')
|
62
|
-
user.report_validation_errors_to_rollbar
|
63
|
-
end
|
64
|
-
|
65
|
-
it 'should not report form validation errors when they are not present' do
|
66
|
-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
|
67
|
-
user.errors.clear
|
68
|
-
user.report_validation_errors_to_rollbar
|
69
|
-
end
|
70
|
-
end
|
71
|
-
|
72
|
-
context 'bc_report_message_with_request' do
|
73
|
-
before(:each) do
|
74
|
-
configure
|
75
|
-
Rollbar.configure do |config|
|
76
|
-
config.logger = logger_mock
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
after(:each) do
|
81
|
-
Rollbar.unconfigure
|
82
|
-
configure
|
83
|
-
end
|
84
|
-
|
85
|
-
let(:logger_mock) { double('Rails.logger').as_null_object }
|
86
|
-
let(:user) { User.create(:email => 'email@example.com', :encrypted_password => '', :created_at => Time.now, :updated_at => Time.now) }
|
87
|
-
|
88
|
-
it 'should report simple messages' do
|
89
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
90
|
-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
|
91
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
92
|
-
Rollbar.report_message_with_request('Test message')
|
93
|
-
|
94
|
-
Rollbar.last_report[:request].should be_nil
|
95
|
-
Rollbar.last_report[:person].should be_nil
|
96
|
-
end
|
97
|
-
|
98
|
-
it 'should report messages with request, person data and extra data' do
|
99
|
-
Rollbar.last_report = nil
|
100
|
-
|
101
|
-
logger_mock.should_receive(:info).with('[Rollbar] Scheduling payload')
|
102
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
103
|
-
|
104
|
-
request_data = {
|
105
|
-
:params => {:foo => 'bar'}
|
106
|
-
}
|
107
|
-
|
108
|
-
person_data = {
|
109
|
-
:id => 123,
|
110
|
-
:username => 'username'
|
111
|
-
}
|
112
|
-
|
113
|
-
extra_data = {
|
114
|
-
:extra_foo => 'extra_bar'
|
115
|
-
}
|
116
|
-
|
117
|
-
Rollbar.report_message_with_request('Test message', 'info', request_data, person_data, extra_data)
|
118
|
-
|
119
|
-
Rollbar.last_report[:request].should == request_data
|
120
|
-
Rollbar.last_report[:person].should == person_data
|
121
|
-
Rollbar.last_report[:body][:message][:extra][:extra_foo].should == 'extra_bar'
|
122
|
-
end
|
123
|
-
end
|
124
|
-
|
125
|
-
context 'bc_report_exception' do
|
126
|
-
before(:each) do
|
127
|
-
configure
|
128
|
-
Rollbar.configure do |config|
|
129
|
-
config.logger = logger_mock
|
130
|
-
end
|
131
|
-
|
132
|
-
begin
|
133
|
-
foo = bar
|
134
|
-
rescue => e
|
135
|
-
@exception = e
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
after(:each) do
|
140
|
-
Rollbar.unconfigure
|
141
|
-
configure
|
142
|
-
end
|
143
|
-
|
144
|
-
let(:logger_mock) { double('Rails.logger').as_null_object }
|
145
|
-
|
146
|
-
it 'should report exceptions without person or request data' do
|
147
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
148
|
-
Rollbar.report_exception(@exception)
|
149
|
-
end
|
150
|
-
|
151
|
-
it 'should not report anything when disabled' do
|
152
|
-
logger_mock.should_not_receive(:info).with('[Rollbar] Success')
|
153
|
-
Rollbar.configure do |config|
|
154
|
-
config.enabled = false
|
155
|
-
end
|
156
|
-
|
157
|
-
Rollbar.report_exception(@exception)
|
158
|
-
end
|
159
|
-
|
160
|
-
it 'should be enabled when freshly configured' do
|
161
|
-
Rollbar.configuration.enabled.should == true
|
162
|
-
end
|
163
|
-
|
164
|
-
it 'should not be enabled when not configured' do
|
165
|
-
Rollbar.unconfigure
|
166
|
-
|
167
|
-
Rollbar.configuration.enabled.should be_nil
|
168
|
-
Rollbar.report_exception(@exception).should == 'disabled'
|
169
|
-
end
|
170
|
-
|
171
|
-
it 'should stay disabled if configure is called again' do
|
172
|
-
Rollbar.unconfigure
|
173
|
-
|
174
|
-
# configure once, setting enabled to false.
|
175
|
-
Rollbar.configure do |config|
|
176
|
-
config.enabled = false
|
177
|
-
end
|
178
|
-
|
179
|
-
# now configure again (perhaps to change some other values)
|
180
|
-
Rollbar.configure do |config| end
|
181
|
-
|
182
|
-
Rollbar.configuration.enabled.should == false
|
183
|
-
Rollbar.report_exception(@exception).should == 'disabled'
|
184
|
-
end
|
185
|
-
|
186
|
-
it 'should report exceptions with request and person data' do
|
187
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
188
|
-
request_data = {
|
189
|
-
:params => { :foo => 'bar' },
|
190
|
-
:url => 'http://localhost/',
|
191
|
-
:user_ip => '127.0.0.1',
|
192
|
-
:headers => {},
|
193
|
-
:GET => { 'baz' => 'boz' },
|
194
|
-
:session => { :user_id => 123 },
|
195
|
-
:method => 'GET',
|
196
|
-
}
|
197
|
-
person_data = {
|
198
|
-
:id => 1,
|
199
|
-
:username => 'test',
|
200
|
-
:email => 'test@example.com'
|
201
|
-
}
|
202
|
-
Rollbar.report_exception(@exception, request_data, person_data)
|
203
|
-
end
|
204
|
-
|
205
|
-
# Skip jruby 1.9+ (https://github.com/jruby/jruby/issues/2373)
|
206
|
-
if defined?(RUBY_ENGINE) && RUBY_ENGINE == 'jruby' && (not RUBY_VERSION =~ /^1\.9/)
|
207
|
-
it 'should work with an IO object as rack.errors' do
|
208
|
-
logger_mock.should_receive(:info).with('[Rollbar] Success')
|
209
|
-
|
210
|
-
request_data = {
|
211
|
-
:params => { :foo => 'bar' },
|
212
|
-
:url => 'http://localhost/',
|
213
|
-
:user_ip => '127.0.0.1',
|
214
|
-
:headers => {},
|
215
|
-
:GET => { 'baz' => 'boz' },
|
216
|
-
:session => { :user_id => 123 },
|
217
|
-
:method => 'GET',
|
218
|
-
:env => { :'rack.errors' => IO.new(2, File::WRONLY) },
|
219
|
-
}
|
220
|
-
|
221
|
-
person_data = {
|
222
|
-
:id => 1,
|
223
|
-
:username => 'test',
|
224
|
-
:email => 'test@example.com'
|
225
|
-
}
|
226
|
-
|
227
|
-
Rollbar.report_exception(@exception, request_data, person_data)
|
228
|
-
end
|
229
|
-
end
|
230
|
-
|
231
|
-
it 'should ignore ignored exception classes' do
|
232
|
-
Rollbar.configure do |config|
|
233
|
-
config.exception_level_filters = { 'NameError' => 'ignore' }
|
234
|
-
end
|
235
|
-
|
236
|
-
logger_mock.should_not_receive(:info)
|
237
|
-
logger_mock.should_not_receive(:error)
|
238
|
-
|
239
|
-
Rollbar.report_exception(@exception)
|
240
|
-
end
|
241
|
-
|
242
|
-
it 'should ignore ignored persons' do
|
243
|
-
Rollbar.configure do |config|
|
244
|
-
config.ignored_person_ids += [1]
|
245
|
-
end
|
246
|
-
|
247
|
-
logger_mock.should_not_receive(:info)
|
248
|
-
logger_mock.should_not_receive(:error)
|
249
|
-
|
250
|
-
person_data = {
|
251
|
-
:id => 1,
|
252
|
-
:username => 'test',
|
253
|
-
:email => 'test@example.com'
|
254
|
-
}
|
255
|
-
Rollbar.report_exception(@exception, {}, person_data)
|
256
|
-
end
|
257
|
-
|
258
|
-
it 'should not ignore non-ignored persons' do
|
259
|
-
Rollbar.configure do |config|
|
260
|
-
config.ignored_person_ids += [1]
|
261
|
-
end
|
262
|
-
|
263
|
-
Rollbar.last_report = nil
|
264
|
-
|
265
|
-
person_data = {
|
266
|
-
:id => 1,
|
267
|
-
:username => 'test',
|
268
|
-
:email => 'test@example.com'
|
269
|
-
}
|
270
|
-
Rollbar.report_exception(@exception, {}, person_data)
|
271
|
-
Rollbar.last_report.should be_nil
|
272
|
-
|
273
|
-
person_data = {
|
274
|
-
:id => 2,
|
275
|
-
:username => 'test2',
|
276
|
-
:email => 'test2@example.com'
|
277
|
-
}
|
278
|
-
Rollbar.report_exception(@exception, {}, person_data)
|
279
|
-
Rollbar.last_report.should_not be_nil
|
280
|
-
end
|
281
|
-
|
282
|
-
it 'should allow callables to set exception filtered level with :use_exception_level_filters option' do
|
283
|
-
callable_mock = double
|
284
|
-
Rollbar.configure do |config|
|
285
|
-
config.exception_level_filters = { 'NameError' => callable_mock }
|
286
|
-
end
|
287
|
-
|
288
|
-
callable_mock.should_receive(:call).with(@exception).at_least(:once).and_return('info')
|
289
|
-
logger_mock.should_receive(:info)
|
290
|
-
logger_mock.should_not_receive(:error)
|
291
|
-
|
292
|
-
Rollbar.report_exception(@exception)
|
293
|
-
end
|
294
|
-
|
295
|
-
it 'should not report exceptions when silenced' do
|
296
|
-
notifier.should_not_receive :schedule_payload
|
297
|
-
|
298
|
-
begin
|
299
|
-
test_var = 1
|
300
|
-
Rollbar.silenced do
|
301
|
-
test_var = 2
|
302
|
-
raise
|
303
|
-
end
|
304
|
-
rescue => e
|
305
|
-
Rollbar.report_exception(e)
|
306
|
-
end
|
307
|
-
|
308
|
-
test_var.should == 2
|
309
|
-
end
|
310
|
-
|
311
|
-
it 'should report exception objects with no backtrace' do
|
312
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
313
|
-
|
314
|
-
payload = nil
|
315
|
-
|
316
|
-
notifier.stub(:schedule_payload) do |*args|
|
317
|
-
payload = args[0]
|
318
|
-
end
|
319
|
-
|
320
|
-
Rollbar.report_exception(StandardError.new('oops'))
|
321
|
-
|
322
|
-
payload['data'][:body][:trace][:frames].should == []
|
323
|
-
payload['data'][:body][:trace][:exception][:class].should == 'StandardError'
|
324
|
-
payload['data'][:body][:trace][:exception][:message].should == 'oops'
|
325
|
-
end
|
326
|
-
|
327
|
-
it 'should return the exception data with a uuid, on platforms with SecureRandom' do
|
328
|
-
if defined?(SecureRandom) and SecureRandom.respond_to?(:uuid)
|
329
|
-
notifier.stub(:schedule_payload) do |*args| end
|
330
|
-
|
331
|
-
exception_data = Rollbar.report_exception(StandardError.new('oops'))
|
332
|
-
exception_data[:uuid].should_not be_nil
|
333
|
-
end
|
334
|
-
end
|
335
|
-
|
336
|
-
it 'should report exception objects with nonstandard backtraces' do
|
337
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
338
|
-
|
339
|
-
payload = nil
|
340
|
-
|
341
|
-
notifier.stub(:schedule_payload) do |*args|
|
342
|
-
payload = args[0]
|
343
|
-
end
|
344
|
-
|
345
|
-
class CustomException < StandardError
|
346
|
-
def backtrace
|
347
|
-
['custom backtrace line']
|
348
|
-
end
|
349
|
-
end
|
350
|
-
|
351
|
-
exception = CustomException.new('oops')
|
352
|
-
|
353
|
-
Rollbar.report_exception(exception)
|
354
|
-
|
355
|
-
payload['data'][:body][:trace][:frames][0][:method].should == 'custom backtrace line'
|
356
|
-
end
|
357
|
-
|
358
|
-
it 'should report exceptions with a custom level' do
|
359
|
-
allow(Rollbar).to receive(:notifier).and_return(notifier)
|
360
|
-
payload = nil
|
361
|
-
|
362
|
-
notifier.stub(:schedule_payload) do |*args|
|
363
|
-
payload = args[0]
|
364
|
-
end
|
365
|
-
|
366
|
-
Rollbar.report_exception(@exception)
|
367
|
-
|
368
|
-
payload['data'][:level].should == 'error'
|
369
|
-
|
370
|
-
Rollbar.report_exception(@exception, nil, nil, 'debug')
|
371
|
-
|
372
|
-
payload['data'][:level].should == 'debug'
|
373
|
-
end
|
374
|
-
end
|
375
|
-
|
376
|
-
# configure with some basic params
|
377
|
-
def configure
|
378
|
-
reconfigure_notifier
|
379
|
-
end
|
380
|
-
end
|