rollbar 2.22.1 → 3.4.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.github/pull_request_template.md +34 -0
- data/.github/workflows/ci.yml +104 -0
- data/.rubocop.yml +185 -33
- data/Gemfile +26 -28
- data/README.md +32 -8
- data/data/rollbar.snippet.js +1 -1
- data/docs/configuration.md +8 -0
- data/gemfiles/rails30.gemfile +17 -35
- data/gemfiles/rails31.gemfile +20 -37
- data/gemfiles/rails32.gemfile +13 -31
- data/gemfiles/rails40.gemfile +12 -32
- data/gemfiles/rails41.gemfile +11 -31
- data/gemfiles/rails42.gemfile +12 -32
- data/gemfiles/rails50.gemfile +16 -30
- data/gemfiles/rails51.gemfile +16 -30
- data/gemfiles/rails52.gemfile +10 -19
- data/gemfiles/rails60.gemfile +10 -25
- data/gemfiles/rails61.gemfile +52 -0
- data/gemfiles/rails70.gemfile +52 -0
- data/lib/generators/rollbar/rollbar_generator.rb +18 -14
- data/lib/rails/rollbar_runner.rb +11 -20
- data/lib/rollbar/capistrano.rb +17 -9
- data/lib/rollbar/capistrano3.rb +8 -2
- data/lib/rollbar/capistrano_tasks.rb +44 -8
- data/lib/rollbar/configuration.rb +138 -84
- data/lib/rollbar/delay/girl_friday.rb +3 -7
- data/lib/rollbar/delay/resque.rb +2 -3
- data/lib/rollbar/delay/shoryuken.rb +4 -3
- data/lib/rollbar/delay/sidekiq.rb +5 -5
- data/lib/rollbar/delay/sucker_punch.rb +4 -6
- data/lib/rollbar/delay/thread.rb +17 -2
- data/lib/rollbar/deploy.rb +8 -7
- data/lib/rollbar/encoding/encoder.rb +17 -6
- data/lib/rollbar/encoding.rb +2 -7
- data/lib/rollbar/exception_reporter.rb +17 -8
- data/lib/rollbar/item/backtrace.rb +22 -10
- data/lib/rollbar/item/frame.rb +8 -5
- data/lib/rollbar/item/locals.rb +49 -2
- data/lib/rollbar/item.rb +80 -50
- data/lib/rollbar/json.rb +2 -1
- data/lib/rollbar/language_support.rb +0 -6
- data/lib/rollbar/lazy_store.rb +3 -7
- data/lib/rollbar/logger.rb +2 -0
- data/lib/rollbar/logger_proxy.rb +3 -1
- data/lib/rollbar/middleware/js/json_value.rb +15 -5
- data/lib/rollbar/middleware/js.rb +70 -38
- 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 +13 -3
- data/lib/rollbar/notifier.rb +309 -172
- data/lib/rollbar/plugin.rb +8 -8
- data/lib/rollbar/plugins/active_job.rb +20 -3
- data/lib/rollbar/plugins/delayed_job/plugin.rb +19 -2
- data/lib/rollbar/plugins/error_context.rb +11 -0
- 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 +39 -21
- data/lib/rollbar/plugins/sidekiq.rb +1 -1
- data/lib/rollbar/plugins/thread.rb +8 -7
- data/lib/rollbar/plugins/validations.rb +3 -1
- data/lib/rollbar/rake_tasks.rb +1 -2
- data/lib/rollbar/request_data_extractor.rb +53 -19
- data/lib/rollbar/rollbar_test.rb +9 -118
- data/lib/rollbar/scrubbers/params.rb +13 -7
- data/lib/rollbar/scrubbers/url.rb +56 -17
- data/lib/rollbar/scrubbers.rb +2 -6
- data/lib/rollbar/truncation/frames_strategy.rb +1 -1
- data/lib/rollbar/truncation/mixin.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/truncation/strings_strategy.rb +4 -2
- data/lib/rollbar/util/hash.rb +14 -7
- data/lib/rollbar/util/ip_anonymizer.rb +1 -1
- data/lib/rollbar/util.rb +23 -13
- data/lib/rollbar/version.rb +1 -1
- data/lib/rollbar.rb +12 -7
- data/lib/tasks/benchmark.rake +2 -1
- data/rollbar.gemspec +6 -3
- data/spec/support/rollbar_api.rb +67 -0
- metadata +19 -12
- data/.travis.yml +0 -281
- data/lib/rollbar/encoding/legacy_encoder.rb +0 -20
- /data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
@@ -4,71 +4,82 @@ module Rollbar
|
|
4
4
|
class Configuration
|
5
5
|
SEND_EXTRA_FRAME_DATA_OPTIONS = [:none, :app, :all].freeze
|
6
6
|
|
7
|
-
attr_accessor :access_token
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
51
|
-
|
52
|
-
|
53
|
-
|
54
|
-
|
55
|
-
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
63
|
-
|
64
|
-
|
65
|
-
|
66
|
-
|
67
|
-
|
68
|
-
|
69
|
-
|
70
|
-
|
71
|
-
|
7
|
+
attr_accessor :access_token,
|
8
|
+
:anonymize_user_ip,
|
9
|
+
:async_handler,
|
10
|
+
:async_json_payload,
|
11
|
+
:async_skip_report_handler,
|
12
|
+
:backtrace_cleaner,
|
13
|
+
:branch,
|
14
|
+
:capture_uncaught,
|
15
|
+
:code_version,
|
16
|
+
:collect_user_ip,
|
17
|
+
:configured_options,
|
18
|
+
:custom_data_method,
|
19
|
+
:default_logger,
|
20
|
+
:delayed_job_enabled,
|
21
|
+
:disable_core_monkey_patch,
|
22
|
+
:disable_monkey_patch,
|
23
|
+
:disable_rack_monkey_patch,
|
24
|
+
:dj_threshold,
|
25
|
+
:enable_error_context,
|
26
|
+
:enabled,
|
27
|
+
:endpoint,
|
28
|
+
:environment,
|
29
|
+
:exception_level_filters,
|
30
|
+
:failover_handlers,
|
31
|
+
:filepath,
|
32
|
+
:files_processed_duration,
|
33
|
+
:files_processed_enabled,
|
34
|
+
:files_processed_size,
|
35
|
+
:files_with_pid_name_enabled,
|
36
|
+
:framework,
|
37
|
+
:ignore_internal_errors,
|
38
|
+
:ignored_person_ids,
|
39
|
+
:js_enabled,
|
40
|
+
:js_options,
|
41
|
+
:host,
|
42
|
+
:locals,
|
43
|
+
:log_payload,
|
44
|
+
:net_retries,
|
45
|
+
:open_timeout,
|
46
|
+
:payload_options,
|
47
|
+
:person_email_method,
|
48
|
+
:person_id_method,
|
49
|
+
:person_method,
|
50
|
+
:person_username_method,
|
51
|
+
:populate_empty_backtraces,
|
52
|
+
:proxy,
|
53
|
+
:raise_on_error,
|
54
|
+
:randomize_scrub_length,
|
55
|
+
:report_dj_data,
|
56
|
+
:request_timeout,
|
57
|
+
:root,
|
58
|
+
:safely,
|
59
|
+
:scrub_fields,
|
60
|
+
:scrub_password,
|
61
|
+
:scrub_user,
|
62
|
+
:scrub_whitelist,
|
63
|
+
:transmit,
|
64
|
+
:uncaught_exception_level,
|
65
|
+
:user_ip_obfuscator_secret,
|
66
|
+
:user_ip_rack_env_key,
|
67
|
+
:scrub_headers,
|
68
|
+
:sidekiq_threshold,
|
69
|
+
:sidekiq_use_scoped_block,
|
70
|
+
:use_async,
|
71
|
+
:use_exception_level_filters_default,
|
72
|
+
:use_payload_access_token,
|
73
|
+
:verify_ssl_peer,
|
74
|
+
:web_base,
|
75
|
+
:write_to_file
|
76
|
+
attr_reader :before_process,
|
77
|
+
:logger_level,
|
78
|
+
:project_gem_paths,
|
79
|
+
:send_extra_frame_data,
|
80
|
+
:transform,
|
81
|
+
:use_eventmachine
|
82
|
+
attr_writer :logger # seconds # bytes
|
72
83
|
|
73
84
|
alias safely? safely
|
74
85
|
|
@@ -76,18 +87,22 @@ module Rollbar
|
|
76
87
|
DEFAULT_WEB_BASE = 'https://rollbar.com'.freeze
|
77
88
|
|
78
89
|
def initialize
|
90
|
+
@access_token = nil
|
79
91
|
@async_handler = nil
|
80
92
|
@before_process = []
|
93
|
+
@branch = nil
|
81
94
|
@capture_uncaught = nil
|
82
95
|
@code_version = nil
|
83
96
|
@custom_data_method = nil
|
84
|
-
@default_logger = lambda { ::Logger.new(
|
97
|
+
@default_logger = lambda { ::Logger.new($stderr) }
|
85
98
|
@logger_level = :info
|
86
99
|
@delayed_job_enabled = true
|
87
100
|
@disable_monkey_patch = false
|
88
101
|
@disable_core_monkey_patch = false
|
89
102
|
@disable_rack_monkey_patch = false
|
103
|
+
@enable_error_context = true
|
90
104
|
@dj_threshold = 0
|
105
|
+
@async_skip_report_handler = nil
|
91
106
|
@enabled = nil # set to true when configure is called
|
92
107
|
@endpoint = DEFAULT_ENDPOINT
|
93
108
|
@environment = nil
|
@@ -98,7 +113,13 @@ module Rollbar
|
|
98
113
|
}
|
99
114
|
@failover_handlers = []
|
100
115
|
@framework = 'Plain'
|
116
|
+
@ignore_internal_errors = [
|
117
|
+
'Net::ReadTimeout',
|
118
|
+
'Net::OpenTimeout',
|
119
|
+
'SocketError'
|
120
|
+
]
|
101
121
|
@ignored_person_ids = []
|
122
|
+
@host = nil
|
102
123
|
@payload_options = {}
|
103
124
|
@person_method = 'current_user'
|
104
125
|
@person_id_method = 'id'
|
@@ -110,6 +131,7 @@ module Rollbar
|
|
110
131
|
@open_timeout = 3
|
111
132
|
@request_timeout = 3
|
112
133
|
@net_retries = 3
|
134
|
+
@root = nil
|
113
135
|
@js_enabled = false
|
114
136
|
@js_options = {}
|
115
137
|
@locals = {}
|
@@ -118,18 +140,19 @@ module Rollbar
|
|
118
140
|
:api_key, :access_token, :accessToken, :session_id]
|
119
141
|
@scrub_user = true
|
120
142
|
@scrub_password = true
|
121
|
-
@randomize_scrub_length =
|
143
|
+
@randomize_scrub_length = false
|
122
144
|
@scrub_whitelist = []
|
123
145
|
@uncaught_exception_level = 'error'
|
124
146
|
@scrub_headers = ['Authorization']
|
125
147
|
@sidekiq_threshold = 0
|
148
|
+
@sidekiq_use_scoped_block = false
|
126
149
|
@safely = false
|
127
150
|
@transform = []
|
128
151
|
@use_async = false
|
152
|
+
@async_json_payload = false
|
129
153
|
@use_eventmachine = false
|
130
154
|
@verify_ssl_peer = true
|
131
155
|
@web_base = DEFAULT_WEB_BASE
|
132
|
-
@write_to_file = false
|
133
156
|
@send_extra_frame_data = :none
|
134
157
|
@project_gem_paths = []
|
135
158
|
@use_exception_level_filters_default = false
|
@@ -139,11 +162,22 @@ module Rollbar
|
|
139
162
|
@log_payload = false
|
140
163
|
@collect_user_ip = true
|
141
164
|
@anonymize_user_ip = false
|
165
|
+
@user_ip_obfuscator_secret = nil
|
166
|
+
@user_ip_rack_env_key = nil
|
167
|
+
@backtrace_cleaner = nil
|
142
168
|
@hooks = {
|
143
169
|
:on_error_response => nil, # params: response
|
144
170
|
:on_report_internal_error => nil # params: exception
|
145
171
|
}
|
146
172
|
|
173
|
+
@write_to_file = false
|
174
|
+
@filepath = nil
|
175
|
+
@files_with_pid_name_enabled = false
|
176
|
+
@files_processed_enabled = false
|
177
|
+
@files_processed_duration = 60
|
178
|
+
@files_processed_size = 5 * 1000 * 1000
|
179
|
+
@use_payload_access_token = false
|
180
|
+
|
147
181
|
@configured_options = ConfiguredOptions.new(self)
|
148
182
|
end
|
149
183
|
|
@@ -186,7 +220,8 @@ module Rollbar
|
|
186
220
|
def use_active_job(options = {})
|
187
221
|
require 'rollbar/delay/active_job'
|
188
222
|
|
189
|
-
Rollbar::Delay::ActiveJob.queue_as(options[:queue] ||
|
223
|
+
Rollbar::Delay::ActiveJob.queue_as(options[:queue] ||
|
224
|
+
Rollbar::Delay::ActiveJob.default_queue_name)
|
190
225
|
|
191
226
|
@use_async = true
|
192
227
|
@async_handler = Rollbar::Delay::ActiveJob
|
@@ -226,15 +261,21 @@ module Rollbar
|
|
226
261
|
end
|
227
262
|
|
228
263
|
def use_sidekiq=(value)
|
229
|
-
deprecation_message = '#use_sidekiq=(value) has been deprecated in favor
|
230
|
-
|
264
|
+
deprecation_message = '#use_sidekiq=(value) has been deprecated in favor ' \
|
265
|
+
'of #use_sidekiq(options = {}). Please update your rollbar configuration.'
|
266
|
+
if defined?(ActiveSupport)
|
267
|
+
ActiveSupport::Deprecation.warn(deprecation_message)
|
268
|
+
else
|
269
|
+
puts(deprecation_message)
|
270
|
+
end
|
231
271
|
|
232
272
|
value.is_a?(Hash) ? use_sidekiq(value) : use_sidekiq
|
233
273
|
end
|
234
274
|
|
235
|
-
def use_thread
|
275
|
+
def use_thread(options = {})
|
236
276
|
require 'rollbar/delay/thread'
|
237
277
|
@use_async = true
|
278
|
+
Rollbar::Delay::Thread.options = options
|
238
279
|
@async_handler = Rollbar::Delay::Thread
|
239
280
|
end
|
240
281
|
|
@@ -245,8 +286,13 @@ module Rollbar
|
|
245
286
|
end
|
246
287
|
|
247
288
|
def use_sucker_punch=(_value)
|
248
|
-
deprecation_message = '#use_sucker_punch=(value) has been deprecated in
|
249
|
-
|
289
|
+
deprecation_message = '#use_sucker_punch=(value) has been deprecated in ' \
|
290
|
+
'favor of #use_sucker_punch. Please update your rollbar configuration.'
|
291
|
+
if defined?(ActiveSupport)
|
292
|
+
ActiveSupport::Deprecation.warn(deprecation_message)
|
293
|
+
else
|
294
|
+
puts(deprecation_message)
|
295
|
+
end
|
250
296
|
|
251
297
|
use_sucker_punch
|
252
298
|
end
|
@@ -261,7 +307,10 @@ module Rollbar
|
|
261
307
|
found = Gem::Specification.each.select { |spec| name === spec.name }
|
262
308
|
puts "[Rollbar] No gems found matching #{name.inspect}" if found.empty?
|
263
309
|
found
|
264
|
-
end
|
310
|
+
end
|
311
|
+
@project_gem_paths.flatten!
|
312
|
+
@project_gem_paths.uniq!
|
313
|
+
@project_gem_paths.map!(&:gem_dir)
|
265
314
|
end
|
266
315
|
|
267
316
|
def before_process=(*handler)
|
@@ -274,7 +323,9 @@ module Rollbar
|
|
274
323
|
|
275
324
|
def send_extra_frame_data=(value)
|
276
325
|
unless SEND_EXTRA_FRAME_DATA_OPTIONS.include?(value)
|
277
|
-
logger.warning(
|
326
|
+
logger.warning(
|
327
|
+
"Wrong 'send_extra_frame_data' value, :none, :app or :all is expected"
|
328
|
+
)
|
278
329
|
|
279
330
|
return
|
280
331
|
end
|
@@ -300,14 +351,14 @@ module Rollbar
|
|
300
351
|
end
|
301
352
|
|
302
353
|
def hook(symbol, &block)
|
303
|
-
|
304
|
-
|
305
|
-
|
306
|
-
|
307
|
-
|
308
|
-
|
354
|
+
unless @hooks.key?(symbol)
|
355
|
+
raise StandardError, "Hook :#{symbol} is not supported by Rollbar SDK."
|
356
|
+
end
|
357
|
+
|
358
|
+
if block_given?
|
359
|
+
@hooks[symbol] = block
|
309
360
|
else
|
310
|
-
|
361
|
+
@hooks[symbol]
|
311
362
|
end
|
312
363
|
end
|
313
364
|
|
@@ -328,7 +379,10 @@ module Rollbar
|
|
328
379
|
return super unless configuration.respond_to?(method)
|
329
380
|
|
330
381
|
method_string = method.to_s
|
331
|
-
|
382
|
+
if method_string.end_with?('=')
|
383
|
+
configured[method_string.chomp('=').to_sym] =
|
384
|
+
args.first
|
385
|
+
end
|
332
386
|
|
333
387
|
configuration.send(method, *args, &block)
|
334
388
|
end
|
@@ -12,13 +12,9 @@ module Rollbar
|
|
12
12
|
|
13
13
|
def queue
|
14
14
|
@queue ||= queue_class.new(nil, :size => 5) do |payload|
|
15
|
-
|
16
|
-
|
17
|
-
rescue
|
18
|
-
# According to https://github.com/mperham/girl_friday/wiki#error-handling
|
19
|
-
# we reraise the exception so it can be handled some way
|
20
|
-
raise
|
21
|
-
end
|
15
|
+
Rollbar.process_from_async_handler(payload)
|
16
|
+
|
17
|
+
# Do not rescue. GirlFriday will call the error handler.
|
22
18
|
end
|
23
19
|
end
|
24
20
|
end
|
data/lib/rollbar/delay/resque.rb
CHANGED
@@ -24,9 +24,8 @@ module Rollbar
|
|
24
24
|
|
25
25
|
def perform(payload)
|
26
26
|
Rollbar.process_from_async_handler(payload)
|
27
|
-
|
28
|
-
#
|
29
|
-
raise
|
27
|
+
|
28
|
+
# Do not rescue. Resque will call the error handler.
|
30
29
|
end
|
31
30
|
end
|
32
31
|
end
|
@@ -2,9 +2,10 @@ require 'shoryuken'
|
|
2
2
|
|
3
3
|
module Rollbar
|
4
4
|
module Delay
|
5
|
-
# Following class allows to send rollbars using Sho-ryu-ken as a background
|
6
|
-
#
|
7
|
-
#
|
5
|
+
# Following class allows to send rollbars using Sho-ryu-ken as a background
|
6
|
+
# jobs processor. See the queue_name method which states that your queues
|
7
|
+
# needs to be names as "rollbar_ENVIRONMENT". Retry intervals will be used
|
8
|
+
# to retry sending the same message again if failed before.
|
8
9
|
class Shoryuken
|
9
10
|
include ::Shoryuken::Worker
|
10
11
|
|
@@ -10,17 +10,17 @@ module Rollbar
|
|
10
10
|
end
|
11
11
|
|
12
12
|
def call(payload)
|
13
|
-
|
13
|
+
return unless ::Sidekiq::Client.push(@options.merge('args' => [payload])).nil?
|
14
|
+
|
15
|
+
raise(StandardError, 'Unable to push the job to Sidekiq')
|
14
16
|
end
|
15
17
|
|
16
18
|
include ::Sidekiq::Worker
|
17
19
|
|
18
20
|
def perform(*args)
|
19
21
|
Rollbar.process_from_async_handler(*args)
|
20
|
-
|
21
|
-
#
|
22
|
-
# and retry it
|
23
|
-
raise
|
22
|
+
|
23
|
+
# Do not rescue. Sidekiq will call the error handler.
|
24
24
|
end
|
25
25
|
end
|
26
26
|
end
|
@@ -7,8 +7,7 @@ module Rollbar
|
|
7
7
|
include ::SuckerPunch::Job
|
8
8
|
|
9
9
|
class << self
|
10
|
-
attr_accessor :perform_proc
|
11
|
-
attr_accessor :ready
|
10
|
+
attr_accessor :perform_proc, :ready
|
12
11
|
end
|
13
12
|
|
14
13
|
self.ready = false
|
@@ -33,7 +32,7 @@ module Rollbar
|
|
33
32
|
|
34
33
|
def perform(*args)
|
35
34
|
Rollbar.process_from_async_handler(*args)
|
36
|
-
|
35
|
+
|
37
36
|
# SuckerPunch can configure an exception handler with:
|
38
37
|
#
|
39
38
|
# SuckerPunch.exception_handler { # do something here }
|
@@ -41,9 +40,8 @@ module Rollbar
|
|
41
40
|
# This is just passed to Celluloid.exception_handler which will
|
42
41
|
# push the reiceved block to an array of handlers, by default empty, [].
|
43
42
|
#
|
44
|
-
|
45
|
-
#
|
46
|
-
raise
|
43
|
+
|
44
|
+
# Do not rescue. SuckerPunch will call the error handler.
|
47
45
|
end
|
48
46
|
end
|
49
47
|
end
|
data/lib/rollbar/delay/thread.rb
CHANGED
@@ -9,7 +9,10 @@ module Rollbar
|
|
9
9
|
Error = Class.new(StandardError)
|
10
10
|
TimeoutError = Class.new(Error)
|
11
11
|
|
12
|
+
DEFAULT_PRIORITY = 1
|
13
|
+
|
12
14
|
class << self
|
15
|
+
attr_writer :options
|
13
16
|
attr_reader :reaper
|
14
17
|
|
15
18
|
def call(payload)
|
@@ -20,6 +23,10 @@ module Rollbar
|
|
20
23
|
thread
|
21
24
|
end
|
22
25
|
|
26
|
+
def options
|
27
|
+
@options || {}
|
28
|
+
end
|
29
|
+
|
23
30
|
private
|
24
31
|
|
25
32
|
def threads
|
@@ -55,15 +62,23 @@ module Rollbar
|
|
55
62
|
reaper.join
|
56
63
|
end
|
57
64
|
rescue Timeout::Error
|
58
|
-
raise TimeoutError,
|
65
|
+
raise TimeoutError,
|
66
|
+
"unable to reap all threads within #{EXIT_TIMEOUT} seconds"
|
59
67
|
end
|
60
68
|
end
|
61
69
|
end
|
62
|
-
end
|
70
|
+
end
|
71
|
+
|
72
|
+
def priority
|
73
|
+
self.class.options[:priority] || DEFAULT_PRIORITY
|
74
|
+
end
|
63
75
|
|
64
76
|
def call(payload)
|
77
|
+
priority = self.priority
|
78
|
+
|
65
79
|
::Thread.new do
|
66
80
|
begin
|
81
|
+
::Thread.current.priority = priority
|
67
82
|
Rollbar.process_from_async_handler(payload)
|
68
83
|
rescue StandardError
|
69
84
|
# Here we swallow the exception:
|
data/lib/rollbar/deploy.rb
CHANGED
@@ -1,3 +1,5 @@
|
|
1
|
+
require 'json'
|
2
|
+
|
1
3
|
module Rollbar
|
2
4
|
# Deploy Tracking API wrapper module
|
3
5
|
module Deploy
|
@@ -28,9 +30,7 @@ module Rollbar
|
|
28
30
|
return {} unless access_token && !access_token.empty?
|
29
31
|
|
30
32
|
uri = ::URI.parse(
|
31
|
-
::Rollbar::Deploy::ENDPOINT
|
32
|
-
deploy_id.to_s +
|
33
|
-
'?access_token=' + access_token
|
33
|
+
"#{::Rollbar::Deploy::ENDPOINT}#{deploy_id}?access_token=#{access_token}"
|
34
34
|
)
|
35
35
|
|
36
36
|
request = ::Net::HTTP::Patch.new(uri.request_uri)
|
@@ -72,17 +72,18 @@ module Rollbar
|
|
72
72
|
|
73
73
|
def request_result(uri, request)
|
74
74
|
{
|
75
|
-
:request_info => uri.inspect
|
75
|
+
:request_info => "#{uri.inspect}: #{request.body}",
|
76
76
|
:request => request
|
77
77
|
}
|
78
78
|
end
|
79
79
|
|
80
80
|
def response_result(response)
|
81
|
+
code = response.code
|
82
|
+
message = response.message
|
83
|
+
body = response.body.delete("\n")
|
81
84
|
{
|
82
85
|
:response => response,
|
83
|
-
:response_info =>
|
84
|
-
response.message + '; ' +
|
85
|
-
response.body.delete("\n")
|
86
|
+
:response_info => "#{code}; #{message}; #{body}"
|
86
87
|
}.merge(::JSON.parse(response.body, :symbolize_names => true))
|
87
88
|
end
|
88
89
|
end
|
@@ -1,9 +1,10 @@
|
|
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,
|
5
|
-
|
6
|
-
|
4
|
+
ALL_ENCODINGS = [::Encoding::UTF_8, ::Encoding::ISO_8859_1, ::Encoding::ASCII_8BIT,
|
5
|
+
::Encoding::US_ASCII].freeze
|
6
|
+
ASCII_ENCODINGS = [::Encoding::US_ASCII, ::Encoding::ASCII_8BIT,
|
7
|
+
::Encoding::ISO_8859_1].freeze
|
7
8
|
UTF8 = 'UTF-8'.freeze
|
8
9
|
BINARY = 'binary'.freeze
|
9
10
|
|
@@ -21,10 +22,19 @@ module Rollbar
|
|
21
22
|
encoded_value = if encoding == ::Encoding::UTF_8 && value.valid_encoding?
|
22
23
|
value
|
23
24
|
else
|
24
|
-
force_encoding(value).encode(
|
25
|
+
force_encoding(value).encode(
|
26
|
+
*encoding_args(value),
|
27
|
+
# Ruby 2.7 requires this to look like keyword args,
|
28
|
+
# and Ruby 1.9.3 doesn't understand keyword args, so
|
29
|
+
# don't use hash rockets here and both will be happy.
|
30
|
+
invalid: :replace, undef: :replace, replace: '' # rubocop:disable Style/HashSyntax
|
31
|
+
)
|
25
32
|
end
|
26
33
|
|
27
34
|
object.is_a?(Symbol) ? encoded_value.to_sym : encoded_value
|
35
|
+
rescue StandardError => e
|
36
|
+
# If encoding fails for any reason, replace the string with a diagnostic error.
|
37
|
+
"error encoding string: #{e.class}: #{e.message}"
|
28
38
|
end
|
29
39
|
|
30
40
|
private
|
@@ -32,7 +42,9 @@ module Rollbar
|
|
32
42
|
def force_encoding(value)
|
33
43
|
return value if value.frozen?
|
34
44
|
|
35
|
-
|
45
|
+
if value.encoding == ::Encoding::UTF_8
|
46
|
+
value.force_encoding(detect_encoding(value))
|
47
|
+
end
|
36
48
|
|
37
49
|
value
|
38
50
|
end
|
@@ -54,7 +66,6 @@ module Rollbar
|
|
54
66
|
def encoding_args(value)
|
55
67
|
args = [UTF8]
|
56
68
|
args << BINARY if ASCII_ENCODINGS.include?(value.encoding)
|
57
|
-
args << ENCODING_OPTIONS
|
58
69
|
|
59
70
|
args
|
60
71
|
end
|
data/lib/rollbar/encoding.rb
CHANGED
@@ -5,13 +5,8 @@ module Rollbar
|
|
5
5
|
end
|
6
6
|
|
7
7
|
def self.setup
|
8
|
-
|
9
|
-
|
10
|
-
self.encoding_class = Rollbar::Encoding::Encoder
|
11
|
-
else
|
12
|
-
require 'rollbar/encoding/legacy_encoder'
|
13
|
-
self.encoding_class = Rollbar::Encoding::LegacyEncoder
|
14
|
-
end
|
8
|
+
require 'rollbar/encoding/encoder'
|
9
|
+
self.encoding_class = Rollbar::Encoding::Encoder
|
15
10
|
end
|
16
11
|
|
17
12
|
def self.encode(object)
|
@@ -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
|