rollbar 2.16.2 → 2.22.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +5 -5
- data/.rubocop.yml +47 -0
- data/.travis.yml +182 -94
- data/Appraisals +10 -10
- data/Gemfile +45 -13
- data/README.md +20 -3
- data/Rakefile +0 -0
- data/data/rollbar.snippet.js +1 -1
- data/docs/configuration.md +15 -0
- data/gemfiles/rails30.gemfile +21 -14
- data/gemfiles/rails31.gemfile +21 -12
- data/gemfiles/rails32.gemfile +18 -8
- data/gemfiles/rails40.gemfile +18 -6
- data/gemfiles/rails41.gemfile +17 -6
- data/gemfiles/rails42.gemfile +24 -14
- data/gemfiles/rails50.gemfile +20 -11
- data/gemfiles/rails51.gemfile +20 -10
- data/gemfiles/rails52.gemfile +65 -0
- data/gemfiles/rails60.gemfile +67 -0
- data/lib/generators/rollbar/rollbar_generator.rb +1 -1
- data/lib/rails/rollbar_runner.rb +17 -2
- data/lib/rollbar.rb +2 -3
- data/lib/rollbar/capistrano.rb +71 -39
- data/lib/rollbar/capistrano3.rb +56 -1
- data/lib/rollbar/capistrano_tasks.rb +130 -0
- data/lib/rollbar/configuration.rb +95 -7
- data/lib/rollbar/delay/active_job.rb +17 -0
- data/lib/rollbar/delay/girl_friday.rb +2 -2
- data/lib/rollbar/delay/resque.rb +4 -6
- data/lib/rollbar/delay/shoryuken.rb +15 -9
- data/lib/rollbar/delay/sidekiq.rb +6 -8
- data/lib/rollbar/delay/sucker_punch.rb +17 -19
- data/lib/rollbar/delay/thread.rb +3 -3
- data/lib/rollbar/deploy.rb +90 -0
- data/lib/rollbar/encoding/encoder.rb +9 -9
- data/lib/rollbar/exception_reporter.rb +19 -5
- data/lib/rollbar/item.rb +62 -20
- data/lib/rollbar/item/backtrace.rb +4 -4
- data/lib/rollbar/item/frame.rb +7 -1
- data/lib/rollbar/item/locals.rb +56 -0
- data/lib/rollbar/json.rb +5 -51
- data/lib/rollbar/language_support.rb +4 -20
- data/lib/rollbar/lazy_store.rb +5 -5
- data/lib/rollbar/logger.rb +1 -0
- data/lib/rollbar/logger_proxy.rb +15 -2
- data/lib/rollbar/middleware/js.rb +110 -10
- data/lib/rollbar/middleware/js/json_value.rb +26 -0
- data/lib/rollbar/middleware/rack.rb +4 -1
- data/lib/rollbar/middleware/rails/rollbar.rb +10 -1
- data/lib/rollbar/notifier.rb +118 -49
- data/lib/rollbar/notifier/trace_with_bindings.rb +65 -0
- data/lib/rollbar/plugin.rb +54 -6
- data/lib/rollbar/plugins.rb +7 -1
- data/lib/rollbar/plugins/active_job.rb +5 -1
- data/lib/rollbar/plugins/basic_socket.rb +21 -6
- data/lib/rollbar/plugins/delayed_job/job_data.rb +3 -3
- data/lib/rollbar/plugins/delayed_job/plugin.rb +3 -3
- data/lib/rollbar/plugins/goalie.rb +11 -3
- data/lib/rollbar/plugins/rails/controller_methods.rb +17 -4
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +7 -3
- data/lib/rollbar/plugins/rake.rb +2 -2
- data/lib/rollbar/plugins/sidekiq/plugin.rb +10 -6
- data/lib/rollbar/rake_tasks.rb +3 -86
- data/lib/rollbar/request_data_extractor.rb +35 -21
- data/lib/rollbar/rollbar_test.rb +147 -0
- data/lib/rollbar/scrubbers.rb +7 -3
- data/lib/rollbar/scrubbers/params.rb +38 -20
- data/lib/rollbar/scrubbers/url.rb +27 -13
- data/lib/rollbar/truncation.rb +9 -2
- data/lib/rollbar/truncation/min_body_strategy.rb +2 -3
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +123 -0
- data/lib/rollbar/truncation/remove_extra_strategy.rb +35 -0
- data/lib/rollbar/truncation/remove_request_strategy.rb +21 -0
- data/lib/rollbar/truncation/strings_strategy.rb +3 -4
- data/lib/rollbar/util.rb +75 -45
- data/lib/rollbar/util/hash.rb +30 -6
- data/lib/rollbar/util/ip_anonymizer.rb +8 -7
- data/lib/rollbar/util/ip_obfuscator.rb +1 -1
- data/lib/rollbar/version.rb +1 -1
- data/lib/tasks/benchmark.rake +103 -0
- data/rollbar.gemspec +14 -8
- metadata +25 -277
- data/gemfiles/ruby_1_8_and_1_9_2.gemfile +0 -49
- data/lib/rollbar/json/default.rb +0 -11
- data/lib/rollbar/json/oj.rb +0 -16
- data/lib/rollbar/tasks/rollbar.cap +0 -47
- data/spec/cacert.pem +0 -3988
- data/spec/controllers/home_controller_spec.rb +0 -480
- data/spec/delay/sidekiq_spec.rb +0 -61
- data/spec/delay/sucker_punch_spec.rb +0 -25
- data/spec/delayed/backend/test.rb +0 -140
- 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/book.rb +0 -5
- data/spec/dummyapp/app/models/post.rb +0 -9
- data/spec/dummyapp/app/models/user.rb +0 -9
- 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.ru +0 -4
- 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 -26
- 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/secrets.yml +0 -2
- 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/migrate/20161219184410_create_books.rb +0 -10
- data/spec/dummyapp/db/migrate/20161219185529_add_username_to_users.rb +0 -5
- data/spec/dummyapp/db/schema.rb +0 -41
- 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/fixtures/plugins/dummy1.rb +0 -5
- data/spec/fixtures/plugins/dummy2.rb +0 -5
- data/spec/generators/rollbar/rollbar_generator_rails30_spec.rb +0 -31
- data/spec/generators/rollbar/rollbar_generator_spec.rb +0 -51
- data/spec/requests/home_spec.rb +0 -49
- data/spec/rollbar/configuration_spec.rb +0 -46
- data/spec/rollbar/delay/delayed_job_spec.rb +0 -22
- 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/encoding/encoder_spec.rb +0 -63
- data/spec/rollbar/item/backtrace_spec.rb +0 -26
- data/spec/rollbar/item/frame_spec.rb +0 -267
- data/spec/rollbar/item_spec.rb +0 -736
- 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 -50
- data/spec/rollbar/logger_spec.rb +0 -124
- data/spec/rollbar/middleware/js_spec.rb +0 -421
- data/spec/rollbar/middleware/sinatra_spec.rb +0 -197
- data/spec/rollbar/notifier_spec.rb +0 -56
- data/spec/rollbar/plugin_spec.rb +0 -209
- data/spec/rollbar/plugins/active_job_spec.rb +0 -38
- data/spec/rollbar/plugins/delayed_job/job_data_spec.rb +0 -48
- data/spec/rollbar/plugins/delayed_job_spec.rb +0 -129
- data/spec/rollbar/plugins/rack_spec.rb +0 -152
- data/spec/rollbar/plugins/rails_js_spec.rb +0 -19
- data/spec/rollbar/plugins/rake_spec.rb +0 -34
- data/spec/rollbar/plugins/resque/failure_spec.rb +0 -36
- data/spec/rollbar/plugins/sidekiq_spec.rb +0 -171
- data/spec/rollbar/plugins/validations_spec.rb +0 -56
- data/spec/rollbar/plugins_spec.rb +0 -68
- data/spec/rollbar/request_data_extractor_spec.rb +0 -270
- data/spec/rollbar/scrubbers/params_spec.rb +0 -314
- data/spec/rollbar/scrubbers/url_spec.rb +0 -136
- data/spec/rollbar/scrubbers_spec.rb +0 -31
- data/spec/rollbar/sidekig/clear_scope_spec.rb +0 -19
- 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/ip_anonymizer_spec.rb +0 -30
- data/spec/rollbar/util_spec.rb +0 -80
- data/spec/rollbar_bc_spec.rb +0 -380
- data/spec/rollbar_spec.rb +0 -1667
- data/spec/spec_helper.rb +0 -84
- 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/matchers.rb +0 -23
- data/spec/support/notifier_helpers.rb +0 -57
- data/spec/support/rollbar_api.rb +0 -57
- data/spec/support/shared_contexts.rb +0 -12
@@ -10,19 +10,17 @@ module Rollbar
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(payload)
|
13
|
-
::Sidekiq::Client.push
|
13
|
+
raise StandardError, 'Unable to push the job to Sidekiq' if ::Sidekiq::Client.push(@options.merge('args' => [payload])).nil?
|
14
14
|
end
|
15
15
|
|
16
16
|
include ::Sidekiq::Worker
|
17
17
|
|
18
18
|
def perform(*args)
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
raise
|
25
|
-
end
|
19
|
+
Rollbar.process_from_async_handler(*args)
|
20
|
+
rescue StandardError
|
21
|
+
# Raise the exception so Sidekiq can track the errored job
|
22
|
+
# and retry it
|
23
|
+
raise
|
26
24
|
end
|
27
25
|
end
|
28
26
|
end
|
@@ -16,11 +16,11 @@ module Rollbar
|
|
16
16
|
def self.setup
|
17
17
|
major_version = ::SuckerPunch::VERSION.split.first.to_i
|
18
18
|
|
19
|
-
if major_version > 1
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
19
|
+
self.perform_proc = if major_version > 1
|
20
|
+
proc { |payload| perform_async(payload) }
|
21
|
+
else
|
22
|
+
proc { |payload| new.async.perform(payload) }
|
23
|
+
end
|
24
24
|
|
25
25
|
self.ready = true
|
26
26
|
end
|
@@ -32,20 +32,18 @@ module Rollbar
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def perform(*args)
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
raise
|
48
|
-
end
|
35
|
+
Rollbar.process_from_async_handler(*args)
|
36
|
+
rescue StandardError
|
37
|
+
# SuckerPunch can configure an exception handler with:
|
38
|
+
#
|
39
|
+
# SuckerPunch.exception_handler { # do something here }
|
40
|
+
#
|
41
|
+
# This is just passed to Celluloid.exception_handler which will
|
42
|
+
# push the reiceved block to an array of handlers, by default empty, [].
|
43
|
+
#
|
44
|
+
# We reraise the exception here casue it's safe and users could have defined
|
45
|
+
# their own exception handler for SuckerPunch
|
46
|
+
raise
|
49
47
|
end
|
50
48
|
end
|
51
49
|
end
|
data/lib/rollbar/delay/thread.rb
CHANGED
@@ -1,11 +1,10 @@
|
|
1
|
-
require 'thread'
|
2
1
|
require 'timeout'
|
3
2
|
|
4
3
|
module Rollbar
|
5
4
|
module Delay
|
6
5
|
class Thread
|
7
6
|
EXIT_SIGNAL = :exit
|
8
|
-
EXIT_TIMEOUT =
|
7
|
+
EXIT_TIMEOUT = 6
|
9
8
|
|
10
9
|
Error = Class.new(StandardError)
|
11
10
|
TimeoutError = Class.new(Error)
|
@@ -29,6 +28,7 @@ module Rollbar
|
|
29
28
|
|
30
29
|
def spawn_threads_reaper
|
31
30
|
return if @spawned
|
31
|
+
|
32
32
|
@spawned = true
|
33
33
|
|
34
34
|
@reaper ||= build_reaper_thread
|
@@ -65,7 +65,7 @@ module Rollbar
|
|
65
65
|
::Thread.new do
|
66
66
|
begin
|
67
67
|
Rollbar.process_from_async_handler(payload)
|
68
|
-
rescue
|
68
|
+
rescue StandardError
|
69
69
|
# Here we swallow the exception:
|
70
70
|
# 1. The original report wasn't sent.
|
71
71
|
# 2. An internal error was sent and logged
|
@@ -0,0 +1,90 @@
|
|
1
|
+
module Rollbar
|
2
|
+
# Deploy Tracking API wrapper module
|
3
|
+
module Deploy
|
4
|
+
ENDPOINT = 'https://api.rollbar.com/api/1/deploy/'.freeze
|
5
|
+
|
6
|
+
def self.report(opts, access_token, environment, revision)
|
7
|
+
return {} unless access_token && !access_token.empty?
|
8
|
+
|
9
|
+
opts[:status] ||= :started
|
10
|
+
|
11
|
+
uri = ::URI.parse(::Rollbar::Deploy::ENDPOINT)
|
12
|
+
|
13
|
+
request_data = {
|
14
|
+
:access_token => access_token,
|
15
|
+
:environment => environment,
|
16
|
+
:revision => revision
|
17
|
+
}.merge(opts)
|
18
|
+
request_data.delete(:proxy)
|
19
|
+
request_data.delete(:dry_run)
|
20
|
+
|
21
|
+
request = ::Net::HTTP::Post.new(uri.request_uri)
|
22
|
+
request.body = ::JSON.dump(request_data)
|
23
|
+
|
24
|
+
send_request(opts, uri, request)
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.update(opts, access_token, deploy_id, status)
|
28
|
+
return {} unless access_token && !access_token.empty?
|
29
|
+
|
30
|
+
uri = ::URI.parse(
|
31
|
+
::Rollbar::Deploy::ENDPOINT +
|
32
|
+
deploy_id.to_s +
|
33
|
+
'?access_token=' + access_token
|
34
|
+
)
|
35
|
+
|
36
|
+
request = ::Net::HTTP::Patch.new(uri.request_uri)
|
37
|
+
request.body = ::JSON.dump(:status => status.to_s, :comment => opts[:comment])
|
38
|
+
|
39
|
+
send_request(opts, uri, request)
|
40
|
+
end
|
41
|
+
|
42
|
+
class << self
|
43
|
+
private
|
44
|
+
|
45
|
+
def send_request(opts, uri, request)
|
46
|
+
::Net::HTTP.start(uri.host, uri.port, opts[:proxy], :use_ssl => true) do |http|
|
47
|
+
build_result(
|
48
|
+
uri,
|
49
|
+
request,
|
50
|
+
opts[:dry_run] ? nil : http.request(request),
|
51
|
+
opts[:dry_run]
|
52
|
+
)
|
53
|
+
end
|
54
|
+
end
|
55
|
+
|
56
|
+
def build_result(uri, request, response = nil, dry_run = false)
|
57
|
+
result = {}
|
58
|
+
result.merge!(request_result(uri, request))
|
59
|
+
result.merge!(response_result(response)) unless response.nil?
|
60
|
+
result[:success] = success?(result, dry_run)
|
61
|
+
result
|
62
|
+
end
|
63
|
+
|
64
|
+
def success?(result, dry_run = false)
|
65
|
+
return true if dry_run
|
66
|
+
|
67
|
+
result[:response] &&
|
68
|
+
result[:response].is_a?(::Net::HTTPSuccess) &&
|
69
|
+
result[:response].code == '200' &&
|
70
|
+
(result.key?('err') ? result['err'].to_i.zero? : true)
|
71
|
+
end
|
72
|
+
|
73
|
+
def request_result(uri, request)
|
74
|
+
{
|
75
|
+
:request_info => uri.inspect + ': ' + request.body,
|
76
|
+
:request => request
|
77
|
+
}
|
78
|
+
end
|
79
|
+
|
80
|
+
def response_result(response)
|
81
|
+
{
|
82
|
+
:response => response,
|
83
|
+
:response_info => response.code + '; ' +
|
84
|
+
response.message + '; ' +
|
85
|
+
response.body.delete("\n")
|
86
|
+
}.merge(::JSON.parse(response.body, :symbolize_names => true))
|
87
|
+
end
|
88
|
+
end
|
89
|
+
end
|
90
|
+
end
|
@@ -1,9 +1,9 @@
|
|
1
1
|
module Rollbar
|
2
2
|
module Encoding
|
3
3
|
class Encoder
|
4
|
-
ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT, ::Encoding::US_ASCII]
|
5
|
-
ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT, ::Encoding::ISO_8859_1]
|
6
|
-
ENCODING_OPTIONS = { :invalid => :replace, :undef => :replace, :replace => '' }
|
4
|
+
ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT, ::Encoding::US_ASCII].freeze
|
5
|
+
ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT, ::Encoding::ISO_8859_1].freeze
|
6
|
+
ENCODING_OPTIONS = { :invalid => :replace, :undef => :replace, :replace => '' }.freeze
|
7
7
|
UTF8 = 'UTF-8'.freeze
|
8
8
|
BINARY = 'binary'.freeze
|
9
9
|
|
@@ -18,11 +18,11 @@ module Rollbar
|
|
18
18
|
encoding = value.encoding
|
19
19
|
|
20
20
|
# This will be most of cases so avoid force anything for them
|
21
|
-
if encoding == ::Encoding::UTF_8 && value.valid_encoding?
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
21
|
+
encoded_value = if encoding == ::Encoding::UTF_8 && value.valid_encoding?
|
22
|
+
value
|
23
|
+
else
|
24
|
+
force_encoding(value).encode(*encoding_args(value))
|
25
|
+
end
|
26
26
|
|
27
27
|
object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
|
28
28
|
end
|
@@ -45,7 +45,7 @@ module Rollbar
|
|
45
45
|
# Seems #codepoints is faster than #valid_encoding?
|
46
46
|
value.force_encoding(encoding).encode(::Encoding::UTF_8).codepoints
|
47
47
|
true
|
48
|
-
rescue
|
48
|
+
rescue StandardError
|
49
49
|
false
|
50
50
|
end
|
51
51
|
end
|
@@ -1,10 +1,11 @@
|
|
1
1
|
module Rollbar
|
2
|
-
module ExceptionReporter
|
2
|
+
module ExceptionReporter # :nodoc:
|
3
3
|
def report_exception_to_rollbar(env, exception)
|
4
|
-
|
5
|
-
|
4
|
+
return unless capture_uncaught?
|
5
|
+
|
6
|
+
log_exception_message(exception)
|
6
7
|
|
7
|
-
exception_data =
|
8
|
+
exception_data = exception_data(exception)
|
8
9
|
|
9
10
|
if exception_data.is_a?(Hash)
|
10
11
|
env['rollbar.exception_uuid'] = exception_data[:uuid]
|
@@ -14,8 +15,21 @@ module Rollbar
|
|
14
15
|
elsif exception_data == 'ignored'
|
15
16
|
Rollbar.log_debug '[Rollbar] Exception not reported because it was ignored'
|
16
17
|
end
|
17
|
-
rescue => e
|
18
|
+
rescue StandardError => e
|
18
19
|
Rollbar.log_warning "[Rollbar] Exception while reporting exception to Rollbar: #{e.message}"
|
19
20
|
end
|
21
|
+
|
22
|
+
def capture_uncaught?
|
23
|
+
Rollbar.configuration.capture_uncaught != false
|
24
|
+
end
|
25
|
+
|
26
|
+
def log_exception_message(exception)
|
27
|
+
exception_message = exception.respond_to?(:message) ? exception.message : 'No Exception Message'
|
28
|
+
Rollbar.log_debug "[Rollbar] Reporting exception: #{exception_message}"
|
29
|
+
end
|
30
|
+
|
31
|
+
def exception_data(exception)
|
32
|
+
Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception, :use_exception_level_filters => true)
|
33
|
+
end
|
20
34
|
end
|
21
35
|
end
|
data/lib/rollbar/item.rb
CHANGED
@@ -12,6 +12,7 @@ require 'rollbar/util'
|
|
12
12
|
require 'rollbar/encoding'
|
13
13
|
require 'rollbar/truncation'
|
14
14
|
require 'rollbar/json'
|
15
|
+
require 'rollbar/scrubbers/params'
|
15
16
|
|
16
17
|
module Rollbar
|
17
18
|
# This class represents the payload to be sent to the API.
|
@@ -26,12 +27,12 @@ module Rollbar
|
|
26
27
|
attr_reader :message
|
27
28
|
attr_reader :exception
|
28
29
|
attr_reader :extra
|
29
|
-
|
30
|
+
|
30
31
|
attr_reader :configuration
|
31
32
|
attr_reader :scope
|
32
33
|
attr_reader :logger
|
33
34
|
attr_reader :notifier
|
34
|
-
|
35
|
+
|
35
36
|
attr_reader :context
|
36
37
|
|
37
38
|
def_delegators :payload, :[]
|
@@ -83,7 +84,8 @@ module Rollbar
|
|
83
84
|
:server => server_data,
|
84
85
|
:notifier => {
|
85
86
|
:name => 'rollbar-gem',
|
86
|
-
:version => VERSION
|
87
|
+
:version => VERSION,
|
88
|
+
:configured_options => configured_options
|
87
89
|
},
|
88
90
|
:body => build_body
|
89
91
|
}
|
@@ -101,29 +103,58 @@ module Rollbar
|
|
101
103
|
data
|
102
104
|
end
|
103
105
|
|
106
|
+
def configured_options
|
107
|
+
if Gem.loaded_specs['activesupport'] && Gem.loaded_specs['activesupport'].version < Gem::Version.new('4.1')
|
108
|
+
# There are too many types that crash ActiveSupport JSON serialization, and not worth
|
109
|
+
# the risk just to send this diagnostic object. In versions < 4.1, ActiveSupport hooks
|
110
|
+
# Ruby's JSON.generate so deeply there's no workaround.
|
111
|
+
'not serialized in ActiveSupport < 4.1'
|
112
|
+
elsif configuration.use_async
|
113
|
+
# Currently serialization is performed by each handler, and this invariably
|
114
|
+
# means it is actually performed by ActiveSupport.
|
115
|
+
#
|
116
|
+
# TODO: Since serialization must be done prior to scheduling the job,
|
117
|
+
# it should at least be done by rollbar-gem itself. Much work has been done
|
118
|
+
# to avoid the bugs in ActiveSupport JSON. The async handlers are currently
|
119
|
+
# still subject to all those knnown issues.
|
120
|
+
'not serialized for async/delayed handlers'
|
121
|
+
else
|
122
|
+
scrub(configuration.configured_options.configured)
|
123
|
+
end
|
124
|
+
end
|
125
|
+
|
104
126
|
def dump
|
105
127
|
# Ensure all keys are strings since we can receive the payload inline or
|
106
128
|
# from an async handler job, which can be serialized.
|
107
129
|
stringified_payload = Util::Hash.deep_stringify_keys(payload)
|
108
|
-
|
130
|
+
attempts = []
|
131
|
+
result = Truncation.truncate(stringified_payload, attempts)
|
109
132
|
|
110
133
|
return result unless Truncation.truncate?(result)
|
111
134
|
|
112
|
-
handle_too_large_payload(stringified_payload, result)
|
135
|
+
handle_too_large_payload(stringified_payload, result, attempts)
|
113
136
|
|
114
137
|
nil
|
115
138
|
end
|
116
139
|
|
117
|
-
def handle_too_large_payload(stringified_payload, final_payload)
|
118
|
-
original_size = Rollbar::JSON.dump(stringified_payload).bytesize
|
119
|
-
final_size = final_payload.bytesize
|
140
|
+
def handle_too_large_payload(stringified_payload, final_payload, attempts)
|
120
141
|
uuid = stringified_payload['data']['uuid']
|
121
142
|
host = stringified_payload['data'].fetch('server', {})['host']
|
122
143
|
|
123
|
-
notifier.send_failsafe(
|
144
|
+
notifier.send_failsafe(
|
145
|
+
too_large_payload_string(attempts),
|
146
|
+
nil,
|
147
|
+
uuid,
|
148
|
+
host
|
149
|
+
)
|
124
150
|
logger.error("[Rollbar] Payload too large to be sent for UUID #{uuid}: #{Rollbar::JSON.dump(payload)}")
|
125
151
|
end
|
126
152
|
|
153
|
+
def too_large_payload_string(attempts)
|
154
|
+
'Could not send payload due to it being too large after truncating attempts. ' \
|
155
|
+
"Original size: #{attempts.first} Attempts: #{attempts.join(', ')} Final size: #{attempts.last}"
|
156
|
+
end
|
157
|
+
|
127
158
|
def ignored?
|
128
159
|
data = payload['data']
|
129
160
|
|
@@ -156,26 +187,37 @@ module Rollbar
|
|
156
187
|
end
|
157
188
|
|
158
189
|
def build_extra
|
159
|
-
if custom_data_method?
|
160
|
-
Util.deep_merge(custom_data, extra || {})
|
190
|
+
if custom_data_method? && !Rollbar::Util.method_in_stack(:custom_data, __FILE__)
|
191
|
+
Util.deep_merge(scrub(custom_data), scrub(extra) || {})
|
161
192
|
else
|
162
|
-
extra
|
193
|
+
scrub(extra)
|
163
194
|
end
|
164
195
|
end
|
165
196
|
|
197
|
+
def scrub(data)
|
198
|
+
return data unless data.is_a? Hash
|
199
|
+
|
200
|
+
options = {
|
201
|
+
:params => data,
|
202
|
+
:config => Rollbar.configuration.scrub_fields,
|
203
|
+
:whitelist => Rollbar.configuration.scrub_whitelist
|
204
|
+
}
|
205
|
+
Rollbar::Scrubbers::Params.call(options)
|
206
|
+
end
|
207
|
+
|
166
208
|
def custom_data_method?
|
167
209
|
!!configuration.custom_data_method
|
168
210
|
end
|
169
211
|
|
170
212
|
def custom_data
|
171
|
-
if configuration.custom_data_method.arity == 3
|
172
|
-
|
173
|
-
|
174
|
-
|
175
|
-
|
176
|
-
|
213
|
+
data = if configuration.custom_data_method.arity == 3
|
214
|
+
configuration.custom_data_method.call(message, exception, context)
|
215
|
+
else
|
216
|
+
configuration.custom_data_method.call
|
217
|
+
end
|
218
|
+
|
177
219
|
Rollbar::Util.deep_copy(data)
|
178
|
-
rescue => e
|
220
|
+
rescue StandardError => e
|
179
221
|
return {} if configuration.safely?
|
180
222
|
|
181
223
|
report_custom_data_error(e)
|
@@ -220,7 +262,7 @@ module Rollbar
|
|
220
262
|
handlers.each do |handler|
|
221
263
|
begin
|
222
264
|
handler.call(transform_options)
|
223
|
-
rescue => e
|
265
|
+
rescue StandardError => e
|
224
266
|
logger.error("[Rollbar] Error calling the `transform` hook: #{e}")
|
225
267
|
|
226
268
|
break
|
@@ -32,7 +32,7 @@ module Rollbar
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
|
35
|
+
alias build to_h
|
36
36
|
|
37
37
|
def get_file_lines(filename)
|
38
38
|
files[filename] ||= read_file(filename)
|
@@ -44,7 +44,7 @@ module Rollbar
|
|
44
44
|
return unless File.exist?(filename)
|
45
45
|
|
46
46
|
File.read(filename).split("\n")
|
47
|
-
rescue
|
47
|
+
rescue StandardError
|
48
48
|
nil
|
49
49
|
end
|
50
50
|
|
@@ -74,10 +74,10 @@ module Rollbar
|
|
74
74
|
end
|
75
75
|
|
76
76
|
def map_frames(current_exception)
|
77
|
-
exception_backtrace(current_exception).
|
77
|
+
exception_backtrace(current_exception).map do |frame|
|
78
78
|
Rollbar::Item::Frame.new(self, frame,
|
79
79
|
:configuration => configuration).to_h
|
80
|
-
end
|
80
|
+
end.reverse
|
81
81
|
end
|
82
82
|
|
83
83
|
# Returns the backtrace to be sent to our API. There are 3 options:
|