rollbar 3.2.0 → 3.3.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +81 -34
- data/Gemfile +8 -8
- data/gemfiles/rails30.gemfile +10 -12
- data/gemfiles/rails31.gemfile +10 -12
- data/gemfiles/rails32.gemfile +3 -5
- data/gemfiles/rails40.gemfile +2 -4
- data/gemfiles/rails41.gemfile +2 -5
- data/gemfiles/rails42.gemfile +4 -9
- data/gemfiles/rails50.gemfile +7 -9
- data/gemfiles/rails51.gemfile +6 -8
- data/gemfiles/rails52.gemfile +5 -5
- data/gemfiles/rails60.gemfile +3 -4
- data/gemfiles/rails61.gemfile +3 -3
- data/lib/generators/rollbar/rollbar_generator.rb +18 -14
- data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
- data/lib/rails/rollbar_runner.rb +12 -5
- data/lib/rollbar/capistrano.rb +16 -8
- data/lib/rollbar/capistrano3.rb +8 -2
- data/lib/rollbar/capistrano_tasks.rb +16 -7
- data/lib/rollbar/configuration.rb +113 -91
- data/lib/rollbar/delay/shoryuken.rb +4 -3
- data/lib/rollbar/delay/sidekiq.rb +3 -1
- data/lib/rollbar/delay/sucker_punch.rb +1 -2
- data/lib/rollbar/delay/thread.rb +3 -2
- data/lib/rollbar/deploy.rb +6 -7
- data/lib/rollbar/encoding/encoder.rb +7 -3
- data/lib/rollbar/exception_reporter.rb +17 -8
- data/lib/rollbar/item/backtrace.rb +10 -8
- data/lib/rollbar/item/frame.rb +6 -5
- data/lib/rollbar/item/locals.rb +3 -1
- data/lib/rollbar/item.rb +47 -38
- data/lib/rollbar/json.rb +1 -1
- data/lib/rollbar/lazy_store.rb +1 -3
- data/lib/rollbar/logger.rb +2 -0
- data/lib/rollbar/logger_proxy.rb +3 -1
- data/lib/rollbar/middleware/js.rb +32 -20
- data/lib/rollbar/middleware/rack/builder.rb +3 -3
- data/lib/rollbar/middleware/rack/test_session.rb +3 -3
- data/lib/rollbar/middleware/rack.rb +4 -4
- data/lib/rollbar/middleware/rails/rollbar.rb +9 -6
- data/lib/rollbar/middleware/rails/show_exceptions.rb +8 -4
- data/lib/rollbar/notifier/trace_with_bindings.rb +4 -2
- data/lib/rollbar/notifier.rb +179 -133
- data/lib/rollbar/plugin.rb +8 -8
- data/lib/rollbar/plugins/active_job.rb +11 -2
- data/lib/rollbar/plugins/delayed_job/plugin.rb +10 -3
- data/lib/rollbar/plugins/goalie.rb +27 -16
- data/lib/rollbar/plugins/rails/controller_methods.rb +18 -14
- data/lib/rollbar/plugins/rails/railtie30.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie32.rb +2 -1
- data/lib/rollbar/plugins/rails/railtie_mixin.rb +2 -2
- data/lib/rollbar/plugins/rails.rb +5 -2
- data/lib/rollbar/plugins/rake.rb +2 -1
- data/lib/rollbar/plugins/sidekiq/plugin.rb +5 -5
- data/lib/rollbar/plugins/thread.rb +1 -1
- data/lib/rollbar/plugins/validations.rb +3 -1
- data/lib/rollbar/rake_tasks.rb +0 -1
- data/lib/rollbar/request_data_extractor.rb +38 -17
- data/lib/rollbar/rollbar_test.rb +3 -1
- data/lib/rollbar/scrubbers/params.rb +13 -7
- data/lib/rollbar/scrubbers/url.rb +37 -17
- data/lib/rollbar/scrubbers.rb +1 -1
- data/lib/rollbar/truncation/remove_any_key_strategy.rb +4 -1
- data/lib/rollbar/truncation/remove_extra_strategy.rb +3 -1
- data/lib/rollbar/util/hash.rb +14 -7
- data/lib/rollbar/util/ip_anonymizer.rb +1 -1
- data/lib/rollbar/util.rb +19 -13
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +12 -7
- data/lib/tasks/benchmark.rake +2 -1
- data/rollbar.gemspec +3 -1
- metadata +3 -3
@@ -7,16 +7,23 @@ module Rollbar
|
|
7
7
|
|
8
8
|
exception_data = exception_data(exception)
|
9
9
|
|
10
|
-
|
10
|
+
case exception_data
|
11
|
+
when Hash
|
11
12
|
env['rollbar.exception_uuid'] = exception_data[:uuid]
|
12
|
-
Rollbar.log_debug
|
13
|
-
|
14
|
-
|
15
|
-
|
13
|
+
Rollbar.log_debug(
|
14
|
+
"[Rollbar] Exception uuid saved in env: #{exception_data[:uuid]}"
|
15
|
+
)
|
16
|
+
when 'disabled'
|
17
|
+
Rollbar.log_debug(
|
18
|
+
'[Rollbar] Exception not reported because Rollbar is disabled'
|
19
|
+
)
|
20
|
+
when 'ignored'
|
16
21
|
Rollbar.log_debug '[Rollbar] Exception not reported because it was ignored'
|
17
22
|
end
|
18
23
|
rescue StandardError => e
|
19
|
-
Rollbar.log_warning
|
24
|
+
Rollbar.log_warning(
|
25
|
+
"[Rollbar] Exception while reporting exception to Rollbar: #{e.message}"
|
26
|
+
)
|
20
27
|
end
|
21
28
|
|
22
29
|
def capture_uncaught?
|
@@ -24,12 +31,14 @@ module Rollbar
|
|
24
31
|
end
|
25
32
|
|
26
33
|
def log_exception_message(exception)
|
27
|
-
exception_message = exception.respond_to?(:message)
|
34
|
+
exception_message = exception.message if exception.respond_to?(:message)
|
35
|
+
exception_message ||= 'No Exception Message'
|
28
36
|
Rollbar.log_debug "[Rollbar] Reporting exception: #{exception_message}"
|
29
37
|
end
|
30
38
|
|
31
39
|
def exception_data(exception)
|
32
|
-
Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception,
|
40
|
+
Rollbar.log(Rollbar.configuration.uncaught_exception_level, exception,
|
41
|
+
:use_exception_level_filters => true)
|
33
42
|
end
|
34
43
|
end
|
35
44
|
end
|
@@ -3,11 +3,7 @@ require 'rollbar/item/frame'
|
|
3
3
|
module Rollbar
|
4
4
|
class Item
|
5
5
|
class Backtrace
|
6
|
-
attr_reader :exception
|
7
|
-
attr_reader :message
|
8
|
-
attr_reader :extra
|
9
|
-
attr_reader :configuration
|
10
|
-
attr_reader :files
|
6
|
+
attr_reader :exception, :message, :extra, :configuration, :files
|
11
7
|
|
12
8
|
private :files
|
13
9
|
|
@@ -54,7 +50,10 @@ module Rollbar
|
|
54
50
|
|
55
51
|
current_exception = exception
|
56
52
|
|
57
|
-
while current_exception.respond_to?(:cause) &&
|
53
|
+
while current_exception.respond_to?(:cause) &&
|
54
|
+
(cause = current_exception.cause) &&
|
55
|
+
cause.is_a?(Exception) &&
|
56
|
+
!visited.include?(cause)
|
58
57
|
traces << trace_data(cause)
|
59
58
|
visited << cause
|
60
59
|
current_exception = cause
|
@@ -100,7 +99,9 @@ module Rollbar
|
|
100
99
|
# are those from the user's Rollbar.error line until this method. We want
|
101
100
|
# to remove those lines.
|
102
101
|
def exception_backtrace(current_exception)
|
103
|
-
|
102
|
+
if current_exception.backtrace.respond_to?(:map)
|
103
|
+
return current_exception.backtrace
|
104
|
+
end
|
104
105
|
return [] unless configuration.populate_empty_backtraces
|
105
106
|
|
106
107
|
caller_backtrace = caller
|
@@ -109,7 +110,8 @@ module Rollbar
|
|
109
110
|
end
|
110
111
|
|
111
112
|
def rollbar_lib_gem_dir
|
112
|
-
Gem::Specification.find_by_name('rollbar').gem_dir
|
113
|
+
gem_dir = Gem::Specification.find_by_name('rollbar').gem_dir
|
114
|
+
"#{gem_dir}/lib"
|
113
115
|
end
|
114
116
|
end
|
115
117
|
end
|
data/lib/rollbar/item/frame.rb
CHANGED
@@ -6,9 +6,7 @@ module Rollbar
|
|
6
6
|
class Item
|
7
7
|
# Representation of the trace data per frame in the payload
|
8
8
|
class Frame
|
9
|
-
attr_reader :backtrace
|
10
|
-
attr_reader :frame
|
11
|
-
attr_reader :configuration
|
9
|
+
attr_reader :backtrace, :frame, :configuration
|
12
10
|
|
13
11
|
MAX_CONTEXT_LENGTH = 4
|
14
12
|
|
@@ -104,7 +102,8 @@ module Rollbar
|
|
104
102
|
|
105
103
|
def post_data(file_lines, lineno)
|
106
104
|
from_line = lineno
|
107
|
-
number_of_lines = [from_line + MAX_CONTEXT_LENGTH,
|
105
|
+
number_of_lines = [from_line + MAX_CONTEXT_LENGTH,
|
106
|
+
file_lines.size].min - from_line
|
108
107
|
|
109
108
|
file_lines[from_line, number_of_lines]
|
110
109
|
end
|
@@ -113,7 +112,9 @@ module Rollbar
|
|
113
112
|
to_line = lineno - 2
|
114
113
|
from_line = [to_line - MAX_CONTEXT_LENGTH + 1, 0].max
|
115
114
|
|
116
|
-
file_lines[from_line, (to_line - from_line + 1)].select
|
115
|
+
file_lines[from_line, (to_line - from_line + 1)].select do |line|
|
116
|
+
line && !line.empty?
|
117
|
+
end
|
117
118
|
end
|
118
119
|
end
|
119
120
|
end
|
data/lib/rollbar/item/locals.rb
CHANGED
@@ -58,7 +58,9 @@ module Rollbar
|
|
58
58
|
# truncation strategy for large payloads.
|
59
59
|
#
|
60
60
|
def prepare_value(value)
|
61
|
-
|
61
|
+
unless value.is_a?(Hash) || value.is_a?(Array)
|
62
|
+
return simple_value?(value) ? value : value.inspect
|
63
|
+
end
|
62
64
|
|
63
65
|
cloned_value = ::Rollbar::Util.deep_copy(value)
|
64
66
|
::Rollbar::Util.iterate_and_update_with_block(cloned_value) do |v|
|
data/lib/rollbar/item.rb
CHANGED
@@ -23,17 +23,8 @@ module Rollbar
|
|
23
23
|
|
24
24
|
attr_writer :payload
|
25
25
|
|
26
|
-
attr_reader :level
|
27
|
-
|
28
|
-
attr_reader :exception
|
29
|
-
attr_reader :extra
|
30
|
-
|
31
|
-
attr_reader :configuration
|
32
|
-
attr_reader :scope
|
33
|
-
attr_reader :logger
|
34
|
-
attr_reader :notifier
|
35
|
-
|
36
|
-
attr_reader :context
|
26
|
+
attr_reader :level, :message, :exception, :extra, :configuration, :scope, :logger,
|
27
|
+
:notifier, :context
|
37
28
|
|
38
29
|
def_delegators :payload, :[]
|
39
30
|
|
@@ -64,7 +55,7 @@ module Rollbar
|
|
64
55
|
|
65
56
|
def build
|
66
57
|
data = build_data
|
67
|
-
self.payload = add_access_token_to_payload({'data' => data})
|
58
|
+
self.payload = add_access_token_to_payload({ 'data' => data })
|
68
59
|
|
69
60
|
enforce_valid_utf8
|
70
61
|
transform
|
@@ -72,7 +63,22 @@ module Rollbar
|
|
72
63
|
end
|
73
64
|
|
74
65
|
def build_data
|
75
|
-
data =
|
66
|
+
data = initial_data
|
67
|
+
|
68
|
+
build_optional_data(data)
|
69
|
+
|
70
|
+
Util.deep_merge(data, configuration.payload_options)
|
71
|
+
Util.deep_merge(data, scope)
|
72
|
+
|
73
|
+
# Our API doesn't allow null context values, so just delete
|
74
|
+
# the key if value is nil.
|
75
|
+
data.delete(:context) unless data[:context]
|
76
|
+
|
77
|
+
data
|
78
|
+
end
|
79
|
+
|
80
|
+
def initial_data
|
81
|
+
{
|
76
82
|
:timestamp => Time.now.to_i,
|
77
83
|
:environment => build_environment,
|
78
84
|
:level => level,
|
@@ -86,25 +92,27 @@ module Rollbar
|
|
86
92
|
},
|
87
93
|
:body => build_body
|
88
94
|
}
|
89
|
-
|
90
|
-
data[:code_version] = configuration.code_version if configuration.code_version
|
91
|
-
data[:uuid] = SecureRandom.uuid if defined?(SecureRandom) && SecureRandom.respond_to?(:uuid)
|
95
|
+
end
|
92
96
|
|
93
|
-
|
94
|
-
|
97
|
+
def build_optional_data(data)
|
98
|
+
if configuration.project_gem_paths.any?
|
99
|
+
data[:project_package_paths] = configuration.project_gem_paths
|
100
|
+
end
|
95
101
|
|
96
|
-
|
97
|
-
# the key if value is nil.
|
98
|
-
data.delete(:context) unless data[:context]
|
102
|
+
data[:code_version] = configuration.code_version if configuration.code_version
|
99
103
|
|
100
|
-
|
104
|
+
return unless defined?(SecureRandom) && SecureRandom.respond_to?(:uuid)
|
105
|
+
|
106
|
+
data[:uuid] = SecureRandom.uuid
|
101
107
|
end
|
102
108
|
|
103
109
|
def configured_options
|
104
|
-
if Gem.loaded_specs['activesupport'] &&
|
105
|
-
|
106
|
-
#
|
107
|
-
#
|
110
|
+
if Gem.loaded_specs['activesupport'] &&
|
111
|
+
Gem.loaded_specs['activesupport'].version < Gem::Version.new('4.1')
|
112
|
+
# There are too many types that crash ActiveSupport JSON serialization,
|
113
|
+
# and not worth the risk just to send this diagnostic object.
|
114
|
+
# In versions < 4.1, ActiveSupport hooks Ruby's JSON.generate so deeply
|
115
|
+
# that there's no workaround.
|
108
116
|
'not serialized in ActiveSupport < 4.1'
|
109
117
|
elsif configuration.use_async && !configuration.async_json_payload
|
110
118
|
# The setting allows serialization to be performed by each handler,
|
@@ -130,7 +138,7 @@ module Rollbar
|
|
130
138
|
nil
|
131
139
|
end
|
132
140
|
|
133
|
-
def handle_too_large_payload(stringified_payload,
|
141
|
+
def handle_too_large_payload(stringified_payload, _final_payload, attempts)
|
134
142
|
uuid = stringified_payload['data']['uuid']
|
135
143
|
host = stringified_payload['data'].fetch('server', {})['host']
|
136
144
|
|
@@ -142,17 +150,16 @@ module Rollbar
|
|
142
150
|
:host => host
|
143
151
|
}
|
144
152
|
|
145
|
-
notifier.send_failsafe(
|
146
|
-
|
147
|
-
|
148
|
-
|
149
|
-
)
|
150
|
-
logger.error("[Rollbar] Payload too large to be sent for UUID #{uuid}: #{Rollbar::JSON.dump(payload)}")
|
153
|
+
notifier.send_failsafe(too_large_payload_string(attempts), nil, original_error)
|
154
|
+
|
155
|
+
logger.error('[Rollbar] Payload too large to be sent for UUID ' \
|
156
|
+
"#{uuid}: #{Rollbar::JSON.dump(payload)}")
|
151
157
|
end
|
152
158
|
|
153
159
|
def too_large_payload_string(attempts)
|
154
160
|
'Could not send payload due to it being too large after truncating attempts. ' \
|
155
|
-
"Original size: #{attempts.first} Attempts: #{attempts.join(', ')}
|
161
|
+
"Original size: #{attempts.first} Attempts: #{attempts.join(', ')} " \
|
162
|
+
"Final size: #{attempts.last}"
|
156
163
|
end
|
157
164
|
|
158
165
|
def ignored?
|
@@ -170,9 +177,10 @@ module Rollbar
|
|
170
177
|
# When using async senders, if the access token is changed dynamically in
|
171
178
|
# the main process config, the sender process won't see that change.
|
172
179
|
#
|
173
|
-
# Until the delayed sender interface is changed to allow passing dynamic
|
174
|
-
# this workaround allows the main process to set the token
|
175
|
-
|
180
|
+
# Until the delayed sender interface is changed to allow passing dynamic
|
181
|
+
# config options, this workaround allows the main process to set the token
|
182
|
+
# by adding it to the payload.
|
183
|
+
if configuration && configuration.use_payload_access_token
|
176
184
|
payload['access_token'] ||= configuration.access_token
|
177
185
|
end
|
178
186
|
|
@@ -207,7 +215,8 @@ module Rollbar
|
|
207
215
|
if custom_data_method? && !Rollbar::Util.method_in_stack(:custom_data, __FILE__)
|
208
216
|
Util.deep_merge(scrub(custom_data), merged_extra)
|
209
217
|
else
|
210
|
-
|
218
|
+
# avoid putting an empty {} in the payload.
|
219
|
+
merged_extra.empty? ? nil : merged_extra
|
211
220
|
end
|
212
221
|
end
|
213
222
|
|
data/lib/rollbar/json.rb
CHANGED
data/lib/rollbar/lazy_store.rb
CHANGED
data/lib/rollbar/logger.rb
CHANGED
@@ -16,7 +16,9 @@ module Rollbar
|
|
16
16
|
# Rails.logger.extend(ActiveSupport::Logger.broadcast(Rollbar::Logger.new))
|
17
17
|
class Logger < ::Logger
|
18
18
|
class Error < RuntimeError; end
|
19
|
+
|
19
20
|
class DatetimeFormatNotSupported < Error; end
|
21
|
+
|
20
22
|
class FormatterNotSupported < Error; end
|
21
23
|
|
22
24
|
def initialize
|
data/lib/rollbar/logger_proxy.rb
CHANGED
@@ -23,7 +23,9 @@ module Rollbar
|
|
23
23
|
end
|
24
24
|
|
25
25
|
def log(level, message)
|
26
|
-
|
26
|
+
unless Rollbar.configuration.enabled && acceptable_levels.include?(level.to_sym)
|
27
|
+
return
|
28
|
+
end
|
27
29
|
|
28
30
|
@object.send(level, message)
|
29
31
|
rescue StandardError
|
@@ -10,11 +10,11 @@ module Rollbar
|
|
10
10
|
class Js
|
11
11
|
include Rollbar::RequestDataExtractor
|
12
12
|
|
13
|
-
attr_reader :app
|
14
|
-
attr_reader :config
|
13
|
+
attr_reader :app, :config
|
15
14
|
|
16
15
|
JS_IS_INJECTED_KEY = 'rollbar.js_is_injected'.freeze
|
17
|
-
SNIPPET = File.read(File.expand_path('../../../../data/rollbar.snippet.js',
|
16
|
+
SNIPPET = File.read(File.expand_path('../../../../data/rollbar.snippet.js',
|
17
|
+
__FILE__))
|
18
18
|
|
19
19
|
def initialize(app, config)
|
20
20
|
@app = app
|
@@ -30,7 +30,9 @@ module Rollbar
|
|
30
30
|
response_string = add_js(env, app_result[2])
|
31
31
|
build_response(env, app_result, response_string)
|
32
32
|
rescue StandardError => e
|
33
|
-
Rollbar.log_error(
|
33
|
+
Rollbar.log_error(
|
34
|
+
"[Rollbar] Rollbar.js could not be added because #{e} exception"
|
35
|
+
)
|
34
36
|
|
35
37
|
app_result
|
36
38
|
end
|
@@ -58,7 +60,8 @@ module Rollbar
|
|
58
60
|
def streaming?(env)
|
59
61
|
return false unless defined?(ActionController::Live)
|
60
62
|
|
61
|
-
env['action_controller.instance']
|
63
|
+
env['action_controller.instance']
|
64
|
+
.class.included_modules.include?(ActionController::Live)
|
62
65
|
end
|
63
66
|
|
64
67
|
def add_js(env, response)
|
@@ -72,7 +75,9 @@ module Rollbar
|
|
72
75
|
|
73
76
|
build_body_with_js(env, body, insert_after_idx)
|
74
77
|
rescue StandardError => e
|
75
|
-
Rollbar.log_error(
|
78
|
+
Rollbar.log_error(
|
79
|
+
"[Rollbar] Rollbar.js could not be added because #{e} exception"
|
80
|
+
)
|
76
81
|
nil
|
77
82
|
end
|
78
83
|
|
@@ -82,13 +87,17 @@ module Rollbar
|
|
82
87
|
env[JS_IS_INJECTED_KEY] = true
|
83
88
|
|
84
89
|
status, headers, = app_result
|
85
|
-
|
90
|
+
if headers.key?('Content-Length')
|
91
|
+
headers['Content-Length'] =
|
92
|
+
response_string.bytesize.to_s
|
93
|
+
end
|
86
94
|
|
87
95
|
response = ::Rack::Response.new(response_string, status, headers)
|
88
96
|
|
89
97
|
finished = response.finish
|
90
98
|
|
91
|
-
# Rack < 2.x Response#finish returns self in array[2].
|
99
|
+
# Rack < 2.x Response#finish returns self in array[2].
|
100
|
+
# Rack >= 2.x returns self.body.
|
92
101
|
# Always return with the response object here regardless of rack version.
|
93
102
|
finished[2] = response
|
94
103
|
finished
|
@@ -155,13 +164,13 @@ module Rollbar
|
|
155
164
|
end
|
156
165
|
|
157
166
|
def script_tag(content, env)
|
158
|
-
|
159
|
-
|
160
|
-
|
161
|
-
|
162
|
-
|
163
|
-
|
164
|
-
|
167
|
+
nonce = rails5_nonce(env) || secure_headers_nonce(env)
|
168
|
+
script_tag_content = if nonce
|
169
|
+
"\n<script type=\"text/javascript\" " \
|
170
|
+
"nonce=\"#{nonce}\">#{content}</script>"
|
171
|
+
else
|
172
|
+
"\n<script type=\"text/javascript\">#{content}</script>"
|
173
|
+
end
|
165
174
|
|
166
175
|
html_safe_if_needed(script_tag_content)
|
167
176
|
end
|
@@ -207,9 +216,10 @@ module Rollbar
|
|
207
216
|
|
208
217
|
config = ::SecureHeaders::Configuration
|
209
218
|
|
210
|
-
|
211
|
-
|
212
|
-
|
219
|
+
has_nonce = ::SecureHeaders.respond_to?(
|
220
|
+
:content_security_policy_script_nonce
|
221
|
+
)
|
222
|
+
secure_headers_cls = if !has_nonce
|
213
223
|
SecureHeadersFalse
|
214
224
|
elsif config.respond_to?(:get)
|
215
225
|
SecureHeaders3To5
|
@@ -223,7 +233,8 @@ module Rollbar
|
|
223
233
|
end
|
224
234
|
|
225
235
|
def secure_headers_nonce_key(req)
|
226
|
-
defined?(::SecureHeaders::NONCE_KEY) &&
|
236
|
+
defined?(::SecureHeaders::NONCE_KEY) &&
|
237
|
+
req.env[::SecureHeaders::NONCE_KEY]
|
227
238
|
end
|
228
239
|
|
229
240
|
class SecureHeadersResolver
|
@@ -263,7 +274,8 @@ module Rollbar
|
|
263
274
|
if csp.respond_to?(:opt_out?) && csp.opt_out?
|
264
275
|
csp.opt_out?
|
265
276
|
# secure_headers csp 3.0.x-3.4.x doesn't respond to 'opt_out?'
|
266
|
-
elsif defined?(::SecureHeaders::OPT_OUT) &&
|
277
|
+
elsif defined?(::SecureHeaders::OPT_OUT) &&
|
278
|
+
::SecureHeaders::OPT_OUT.is_a?(Symbol)
|
267
279
|
csp == ::SecureHeaders::OPT_OUT
|
268
280
|
end
|
269
281
|
end
|
@@ -14,8 +14,8 @@ module Rollbar
|
|
14
14
|
Rollbar.scoped(fetch_scope(env)) do
|
15
15
|
begin
|
16
16
|
call_without_rollbar(env)
|
17
|
-
rescue ::Exception =>
|
18
|
-
report_exception_to_rollbar(env,
|
17
|
+
rescue ::Exception => e # rubocop:disable Lint/RescueException
|
18
|
+
report_exception_to_rollbar(env, e)
|
19
19
|
raise
|
20
20
|
end
|
21
21
|
end
|
@@ -26,7 +26,7 @@ module Rollbar
|
|
26
26
|
:request => proc { extract_request_data_from_rack(env) },
|
27
27
|
:person => person_data_proc(env)
|
28
28
|
}
|
29
|
-
rescue Exception => e
|
29
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
30
30
|
report_exception_to_rollbar(env, e)
|
31
31
|
raise
|
32
32
|
end
|
@@ -6,9 +6,9 @@ module Rollbar
|
|
6
6
|
|
7
7
|
def env_for_with_rollbar(path, env)
|
8
8
|
env_for_without_rollbar(path, env)
|
9
|
-
rescue Exception =>
|
10
|
-
report_exception_to_rollbar(env,
|
11
|
-
raise
|
9
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
10
|
+
report_exception_to_rollbar(env, e)
|
11
|
+
raise e
|
12
12
|
end
|
13
13
|
|
14
14
|
def self.included(base)
|
@@ -21,7 +21,7 @@ module Rollbar
|
|
21
21
|
response = @app.call(env)
|
22
22
|
report_exception_to_rollbar(env, framework_error(env)) if framework_error(env)
|
23
23
|
response
|
24
|
-
rescue Exception => e
|
24
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
25
25
|
report_exception_to_rollbar(env, e)
|
26
26
|
raise
|
27
27
|
ensure
|
@@ -35,7 +35,7 @@ module Rollbar
|
|
35
35
|
:request => proc { extract_request_data_from_rack(env) },
|
36
36
|
:person => person_data_proc(env)
|
37
37
|
}
|
38
|
-
rescue Exception => e
|
38
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
39
39
|
report_exception_to_rollbar(env, e)
|
40
40
|
raise
|
41
41
|
end
|
@@ -44,8 +44,8 @@ module Rollbar
|
|
44
44
|
proc { extract_person_data_from_controller(env) }
|
45
45
|
end
|
46
46
|
|
47
|
-
def framework_error(
|
48
|
-
|
47
|
+
def framework_error(env)
|
48
|
+
env['rack.exception']
|
49
49
|
end
|
50
50
|
end
|
51
51
|
end
|
@@ -29,8 +29,8 @@ module Rollbar
|
|
29
29
|
end
|
30
30
|
|
31
31
|
response
|
32
|
-
rescue Exception =>
|
33
|
-
report_exception_to_rollbar(env,
|
32
|
+
rescue Exception => e # rubocop:disable Lint/RescueException
|
33
|
+
report_exception_to_rollbar(env, e)
|
34
34
|
raise
|
35
35
|
ensure
|
36
36
|
Rollbar.notifier.disable_locals
|
@@ -63,7 +63,9 @@ module Rollbar
|
|
63
63
|
|
64
64
|
def person_data_proc(env)
|
65
65
|
block = proc { extract_person_data_from_controller(env) }
|
66
|
-
|
66
|
+
unless defined?(ActiveRecord::Base) && ActiveRecord::Base.connected?
|
67
|
+
return block
|
68
|
+
end
|
67
69
|
|
68
70
|
proc do
|
69
71
|
begin
|
@@ -75,11 +77,12 @@ module Rollbar
|
|
75
77
|
end
|
76
78
|
|
77
79
|
def context(request_data)
|
78
|
-
return unless request_data[:params]
|
79
|
-
|
80
80
|
route_params = request_data[:params]
|
81
|
+
|
81
82
|
# make sure route is a hash built by RequestDataExtractor
|
82
|
-
return
|
83
|
+
return unless route_params.is_a?(Hash) && !route_params.empty?
|
84
|
+
|
85
|
+
"#{route_params[:controller]}##{route_params[:action]}"
|
83
86
|
end
|
84
87
|
end
|
85
88
|
end
|
@@ -20,20 +20,24 @@ module Rollbar
|
|
20
20
|
|
21
21
|
def call_with_rollbar(env)
|
22
22
|
call_without_rollbar(env)
|
23
|
-
rescue ActionController::RoutingError =>
|
23
|
+
rescue ActionController::RoutingError => e
|
24
24
|
# won't reach here if show_detailed_exceptions is true
|
25
25
|
scope = extract_scope_from(env)
|
26
26
|
|
27
27
|
Rollbar.scoped(scope) do
|
28
|
-
report_exception_to_rollbar(env,
|
28
|
+
report_exception_to_rollbar(env, e)
|
29
29
|
end
|
30
30
|
|
31
|
-
raise
|
31
|
+
raise e
|
32
32
|
end
|
33
33
|
|
34
34
|
def extract_scope_from(env)
|
35
35
|
scope = env['rollbar.scope']
|
36
|
-
|
36
|
+
unless scope
|
37
|
+
Rollbar.log_warn(
|
38
|
+
'[Rollbar] rollbar.scope key has been removed from Rack env.'
|
39
|
+
)
|
40
|
+
end
|
37
41
|
|
38
42
|
scope || {}
|
39
43
|
end
|
@@ -36,7 +36,8 @@ module Rollbar
|
|
36
36
|
def trace_point
|
37
37
|
return unless defined?(TracePoint)
|
38
38
|
|
39
|
-
@trace_point ||= TracePoint.new(:call, :return, :b_call, :b_return, :c_call,
|
39
|
+
@trace_point ||= TracePoint.new(:call, :return, :b_call, :b_return, :c_call,
|
40
|
+
:c_return, :raise) do |tp|
|
40
41
|
case tp.event
|
41
42
|
when :call, :b_call, :c_call, :class
|
42
43
|
frames.push frame(tp)
|
@@ -44,7 +45,8 @@ module Rollbar
|
|
44
45
|
frames.pop
|
45
46
|
when :raise
|
46
47
|
unless detect_reraise(tp) # ignore reraised exceptions
|
47
|
-
|
48
|
+
# may be possible to optimize better than #dup
|
49
|
+
@exception_frames = @frames.dup
|
48
50
|
@exception_signature = exception_signature(tp)
|
49
51
|
end
|
50
52
|
end
|