rollbar 2.26.0 → 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 +52 -36
- data/Gemfile +25 -29
- data/README.md +32 -8
- data/data/rollbar.snippet.js +1 -1
- data/docs/configuration.md +7 -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 +11 -35
- data/gemfiles/rails50.gemfile +14 -32
- data/gemfiles/rails51.gemfile +13 -31
- 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 +8 -19
- 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 +122 -88
- 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/encoding.rb +2 -7
- 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 +5 -2
- data/lib/rollbar/item.rb +60 -38
- data/lib/rollbar/json.rb +1 -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 +59 -37
- 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 +180 -136
- data/lib/rollbar/plugin.rb +8 -8
- data/lib/rollbar/plugins/active_job.rb +15 -2
- data/lib/rollbar/plugins/delayed_job/plugin.rb +14 -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 +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 +48 -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 +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 +5 -3
- metadata +17 -12
- data/.travis.yml +0 -284
- data/lib/rollbar/encoding/legacy_encoder.rb +0 -20
- /data/lib/generators/rollbar/templates/{initializer.rb → initializer.erb} +0 -0
data/lib/rollbar/notifier.rb
CHANGED
@@ -15,9 +15,7 @@ module Rollbar
|
|
15
15
|
# The notifier class. It has the core functionality
|
16
16
|
# for sending reports to the API.
|
17
17
|
class Notifier
|
18
|
-
attr_accessor :configuration
|
19
|
-
attr_accessor :last_report
|
20
|
-
attr_accessor :scope_object
|
18
|
+
attr_accessor :configuration, :last_report, :scope_object
|
21
19
|
|
22
20
|
MUTEX = Mutex.new
|
23
21
|
EXTENSION_REGEXP = /.rollbar\z/.freeze
|
@@ -34,7 +32,9 @@ module Rollbar
|
|
34
32
|
self.scope_object = ::Rollbar::LazyStore.new(scope)
|
35
33
|
end
|
36
34
|
|
37
|
-
|
35
|
+
return unless payload_options
|
36
|
+
|
37
|
+
Rollbar::Util.deep_merge(configuration.payload_options, payload_options)
|
38
38
|
end
|
39
39
|
|
40
40
|
def reset!
|
@@ -134,17 +134,8 @@ module Rollbar
|
|
134
134
|
message, exception, extra, context = extract_arguments(args)
|
135
135
|
use_exception_level_filters = use_exception_level_filters?(extra)
|
136
136
|
|
137
|
-
return 'ignored' if ignored?(exception, use_exception_level_filters)
|
138
|
-
|
139
|
-
begin
|
140
|
-
status = call_before_process(:level => level,
|
141
|
-
:exception => exception,
|
142
|
-
:message => message,
|
143
|
-
:extra => extra)
|
144
|
-
return 'ignored' if status == 'ignored'
|
145
|
-
rescue Rollbar::Ignore
|
146
|
-
return 'ignored'
|
147
|
-
end
|
137
|
+
return 'ignored' if ignored?(exception, use_exception_level_filters) ||
|
138
|
+
ignore_before_process?(level, exception, message, extra)
|
148
139
|
|
149
140
|
level = lookup_exception_level(level, exception,
|
150
141
|
use_exception_level_filters)
|
@@ -156,6 +147,17 @@ module Rollbar
|
|
156
147
|
ret
|
157
148
|
end
|
158
149
|
|
150
|
+
def ignore_before_process?(level, exception, message, extra)
|
151
|
+
status = call_before_process(:level => level,
|
152
|
+
:exception => exception,
|
153
|
+
:message => message,
|
154
|
+
:extra => extra)
|
155
|
+
|
156
|
+
status == 'ignored'
|
157
|
+
rescue Rollbar::Ignore
|
158
|
+
true
|
159
|
+
end
|
160
|
+
|
159
161
|
def report_with_rescue(level, message, exception, extra, context)
|
160
162
|
report(level, message, exception, extra, context)
|
161
163
|
rescue StandardError, SystemStackError => e
|
@@ -202,23 +204,20 @@ module Rollbar
|
|
202
204
|
|
203
205
|
def enabled?
|
204
206
|
# Require access_token so we don't try to send events when unconfigured.
|
205
|
-
configuration.enabled &&
|
207
|
+
configuration.enabled &&
|
208
|
+
configuration.access_token &&
|
209
|
+
!configuration.access_token.empty?
|
206
210
|
end
|
207
211
|
|
208
212
|
def process_item(item)
|
209
|
-
|
210
|
-
|
211
|
-
|
212
|
-
|
213
|
-
|
214
|
-
else
|
215
|
-
do_write_item(item)
|
216
|
-
end
|
217
|
-
else
|
218
|
-
send_item(item)
|
219
|
-
end
|
213
|
+
return send_item(item) unless configuration.write_to_file
|
214
|
+
|
215
|
+
return do_write_item(item) unless configuration.use_async
|
216
|
+
|
217
|
+
MUTEX.synchronize { do_write_item(item) }
|
220
218
|
rescue StandardError => e
|
221
|
-
log_error
|
219
|
+
log_error '[Rollbar] Error processing the item: ' \
|
220
|
+
"#{e.class}, #{e.message}. Item: #{item.payload.inspect}"
|
222
221
|
raise e unless via_failsafe?(item)
|
223
222
|
|
224
223
|
log_error('[Rollbar] Item has already failed. Not re-raising')
|
@@ -254,10 +253,7 @@ module Rollbar
|
|
254
253
|
# The final payload has already been built.
|
255
254
|
send_body(payload)
|
256
255
|
else
|
257
|
-
item =
|
258
|
-
:notifier => self,
|
259
|
-
:configuration => configuration,
|
260
|
-
:logger => logger)
|
256
|
+
item = build_item_with_payload(payload)
|
261
257
|
|
262
258
|
process_item(item)
|
263
259
|
end
|
@@ -269,6 +265,12 @@ module Rollbar
|
|
269
265
|
end
|
270
266
|
end
|
271
267
|
|
268
|
+
def build_item_with_payload(payload)
|
269
|
+
Item.build_with(payload, :notifier => self,
|
270
|
+
:configuration => configuration,
|
271
|
+
:logger => logger)
|
272
|
+
end
|
273
|
+
|
272
274
|
def failsafe_initial_data(exception_reason)
|
273
275
|
{
|
274
276
|
:level => 'error',
|
@@ -300,21 +302,19 @@ module Rollbar
|
|
300
302
|
'data' => failsafe_data
|
301
303
|
}
|
302
304
|
|
303
|
-
|
304
|
-
item = Item.build_with(failsafe_payload,
|
305
|
-
:notifier => self,
|
306
|
-
:configuration => configuration,
|
307
|
-
:logger => logger)
|
308
|
-
|
309
|
-
process_item(item)
|
310
|
-
log_and_return_item_data(item)
|
311
|
-
rescue StandardError => e
|
312
|
-
log_error "[Rollbar] Error sending failsafe : #{e}"
|
313
|
-
end
|
305
|
+
process_failsafe_item(failsafe_payload)
|
314
306
|
|
315
307
|
failsafe_payload
|
316
308
|
end
|
317
309
|
|
310
|
+
def process_failsafe_item(failsafe_payload)
|
311
|
+
item = build_item_with_payload(failsafe_payload)
|
312
|
+
process_item(item)
|
313
|
+
log_and_return_item_data(item)
|
314
|
+
rescue StandardError => e
|
315
|
+
log_error "[Rollbar] Error sending failsafe : #{e}"
|
316
|
+
end
|
317
|
+
|
318
318
|
def failsafe_add_original_error_data(payload_notifier, original_error)
|
319
319
|
return unless original_error
|
320
320
|
|
@@ -328,8 +328,10 @@ module Rollbar
|
|
328
328
|
end
|
329
329
|
|
330
330
|
def add_original_message(diagnostic, original_error)
|
331
|
-
|
332
|
-
|
331
|
+
if original_error[:message]
|
332
|
+
diagnostic[:original_message] =
|
333
|
+
original_error[:message].truncate(FAILSAFE_STRING_LENGTH)
|
334
|
+
end
|
333
335
|
rescue StandardError => e
|
334
336
|
diagnostic[:original_message] = "Failed: #{e.message}"
|
335
337
|
end
|
@@ -343,7 +345,6 @@ module Rollbar
|
|
343
345
|
:stack => backtrace && backtrace.join(', ').truncate(FAILSAFE_STRING_LENGTH)
|
344
346
|
}
|
345
347
|
end
|
346
|
-
|
347
348
|
rescue StandardError => e
|
348
349
|
diagnostic[:original_error] = "Failed: #{e.message}"
|
349
350
|
end
|
@@ -351,9 +352,9 @@ module Rollbar
|
|
351
352
|
def add_configured_options(payload_notifier, original_error)
|
352
353
|
if original_error[:configuration]
|
353
354
|
configured = original_error[:configuration].configured_options.configured
|
354
|
-
payload_notifier[:configured_options] =
|
355
|
+
payload_notifier[:configured_options] =
|
356
|
+
::JSON.generate(configured).truncate(FAILSAFE_STRING_LENGTH)
|
355
357
|
end
|
356
|
-
|
357
358
|
rescue StandardError => e
|
358
359
|
payload_notifier[:configured_options] = "Failed: #{e.message}"
|
359
360
|
end
|
@@ -390,7 +391,8 @@ module Rollbar
|
|
390
391
|
end
|
391
392
|
|
392
393
|
def enable_locals?
|
393
|
-
configuration.locals[:enabled] &&
|
394
|
+
configuration.locals[:enabled] &&
|
395
|
+
[:app, :all].include?(configuration.send_extra_frame_data)
|
394
396
|
end
|
395
397
|
|
396
398
|
def enable_locals
|
@@ -412,13 +414,7 @@ module Rollbar
|
|
412
414
|
end
|
413
415
|
|
414
416
|
def call_before_process(options)
|
415
|
-
options =
|
416
|
-
:level => options[:level],
|
417
|
-
:scope => scope_object,
|
418
|
-
:exception => options[:exception],
|
419
|
-
:message => options[:message],
|
420
|
-
:extra => options[:extra]
|
421
|
-
}
|
417
|
+
options = options_for_handler(options)
|
422
418
|
handlers = configuration.before_process
|
423
419
|
|
424
420
|
handlers.each do |handler|
|
@@ -435,24 +431,30 @@ module Rollbar
|
|
435
431
|
end
|
436
432
|
end
|
437
433
|
|
434
|
+
def options_for_handler(options)
|
435
|
+
{
|
436
|
+
:level => options[:level],
|
437
|
+
:scope => scope_object,
|
438
|
+
:exception => options[:exception],
|
439
|
+
:message => options[:message],
|
440
|
+
:extra => options[:extra]
|
441
|
+
}
|
442
|
+
end
|
443
|
+
|
438
444
|
def extract_arguments(args)
|
439
|
-
message = nil
|
440
|
-
exception = nil
|
441
|
-
extra = nil
|
442
|
-
context = nil
|
445
|
+
message = exception = extra = context = nil
|
443
446
|
|
444
447
|
args.each do |arg|
|
445
448
|
if arg.is_a?(String)
|
446
449
|
message = arg
|
447
450
|
elsif arg.is_a?(Exception)
|
448
451
|
exception = arg
|
449
|
-
elsif
|
452
|
+
elsif java_exception?(arg)
|
450
453
|
exception = arg
|
451
454
|
elsif arg.is_a?(Hash)
|
452
455
|
extra = arg
|
453
456
|
|
454
|
-
context = extra
|
455
|
-
extra.delete :custom_data_method_context
|
457
|
+
context = extra.delete :custom_data_method_context
|
456
458
|
|
457
459
|
extra = nil if extra.empty?
|
458
460
|
end
|
@@ -461,6 +463,10 @@ module Rollbar
|
|
461
463
|
[message, exception, extra, context]
|
462
464
|
end
|
463
465
|
|
466
|
+
def java_exception?(obj)
|
467
|
+
RUBY_PLATFORM == 'java' && obj.is_a?(java.lang.Throwable)
|
468
|
+
end
|
469
|
+
|
464
470
|
def lookup_exception_level(orig_level, exception, use_exception_level_filters)
|
465
471
|
return orig_level unless use_exception_level_filters
|
466
472
|
|
@@ -491,7 +497,9 @@ module Rollbar
|
|
491
497
|
|
492
498
|
def report(level, message, exception, extra, context)
|
493
499
|
unless message || exception || extra
|
494
|
-
log_error
|
500
|
+
log_error(
|
501
|
+
'[Rollbar] Tried to send a report with no message, exception or extra data.'
|
502
|
+
)
|
495
503
|
|
496
504
|
return 'error'
|
497
505
|
end
|
@@ -518,37 +526,48 @@ module Rollbar
|
|
518
526
|
log_info "[Rollbar] Data: #{data}"
|
519
527
|
end
|
520
528
|
|
521
|
-
# Reports an internal error in the Rollbar library. This will be reported
|
522
|
-
# Rollbar project. We'll first attempt to provide a
|
523
|
-
# If that fails, we'll fall back
|
529
|
+
# Reports an internal error in the Rollbar library. This will be reported
|
530
|
+
# within the configured Rollbar project. We'll first attempt to provide a
|
531
|
+
# report including the exception traceback. If that fails, we'll fall back
|
532
|
+
# to a more static failsafe response.
|
524
533
|
def report_internal_error(exception, original_error = nil)
|
525
|
-
|
534
|
+
return if skip_reporting_internal_error(exception)
|
535
|
+
|
536
|
+
failsafe_message = ''
|
537
|
+
log_error(
|
538
|
+
'[Rollbar] Reporting internal error encountered while sending data to Rollbar.'
|
539
|
+
)
|
526
540
|
|
527
541
|
configuration.execute_hook(:on_report_internal_error, exception)
|
528
542
|
|
529
|
-
|
530
|
-
|
531
|
-
rescue StandardError => e
|
532
|
-
send_failsafe('build_item in exception_data', e, original_error)
|
533
|
-
log_error "[Rollbar] Exception: #{exception}"
|
534
|
-
return
|
535
|
-
end
|
543
|
+
failsafe_message = 'build_item in exception_data'
|
544
|
+
item = build_item('error', nil, exception, { :internal => true }, nil)
|
536
545
|
|
537
|
-
|
538
|
-
|
539
|
-
rescue StandardError => e
|
540
|
-
send_failsafe('error in process_item', e, original_error)
|
541
|
-
log_error "[Rollbar] Item: #{item}"
|
542
|
-
return
|
543
|
-
end
|
546
|
+
failsafe_message = 'error in process_item'
|
547
|
+
process_item(item)
|
544
548
|
|
545
|
-
|
546
|
-
|
547
|
-
|
548
|
-
|
549
|
-
|
550
|
-
|
549
|
+
failsafe_message = 'error logging instance link'
|
550
|
+
log_instance_link(item['data'])
|
551
|
+
rescue StandardError => e
|
552
|
+
send_failsafe(failsafe_message, e, original_error)
|
553
|
+
log_error(item ? "[Rollbar] Item: #{item}" : "[Rollbar] Exception: #{exception}")
|
554
|
+
end
|
555
|
+
|
556
|
+
def skip_reporting_internal_error(exception)
|
557
|
+
return true if configuration.ignore_internal_errors == true
|
558
|
+
|
559
|
+
configuration.ignore_internal_errors.each do |error_name|
|
560
|
+
begin
|
561
|
+
error_cls = error_name.split('::').reduce(Module, :const_get)
|
562
|
+
return true if exception.class <= error_cls
|
563
|
+
rescue NameError
|
564
|
+
# Ignore errors and continue matching.
|
565
|
+
# It's possible for a class name in the list to not be resolvable,
|
566
|
+
# and this is ok.
|
567
|
+
end
|
551
568
|
end
|
569
|
+
|
570
|
+
false
|
552
571
|
end
|
553
572
|
|
554
573
|
## Payload building functions
|
@@ -579,7 +598,8 @@ module Rollbar
|
|
579
598
|
|
580
599
|
headers = { 'X-Rollbar-Access-Token' => configuration.access_token }
|
581
600
|
options = http_proxy_for_em(uri)
|
582
|
-
req = EventMachine::HttpRequest.new(uri.to_s, options).post(:body => body,
|
601
|
+
req = EventMachine::HttpRequest.new(uri.to_s, options).post(:body => body,
|
602
|
+
:head => headers)
|
583
603
|
|
584
604
|
eventmachine_callback(req)
|
585
605
|
eventmachine_errback(req)
|
@@ -590,7 +610,8 @@ module Rollbar
|
|
590
610
|
if req.response_header.status == 200
|
591
611
|
log_info '[Rollbar] Success'
|
592
612
|
else
|
593
|
-
log_warning
|
613
|
+
log_warning '[Rollbar] Got unexpected status code from Rollbar.io api: ' \
|
614
|
+
"#{req.response_header.status}"
|
594
615
|
log_info "[Rollbar] Response: #{req.response}"
|
595
616
|
end
|
596
617
|
end
|
@@ -598,7 +619,9 @@ module Rollbar
|
|
598
619
|
|
599
620
|
def eventmachine_errback(req)
|
600
621
|
req.errback do
|
601
|
-
log_warning
|
622
|
+
log_warning(
|
623
|
+
"[Rollbar] Call to API failed, status code: #{req.response_header.status}"
|
624
|
+
)
|
602
625
|
log_info "[Rollbar] Error's response: #{req.response}"
|
603
626
|
end
|
604
627
|
end
|
@@ -626,29 +649,44 @@ module Rollbar
|
|
626
649
|
end
|
627
650
|
|
628
651
|
def do_post(uri, body, access_token)
|
652
|
+
http = init_http(uri)
|
653
|
+
|
654
|
+
request = Net::HTTP::Post.new(uri.request_uri)
|
655
|
+
|
656
|
+
request.body = pack_ruby260_bytes(body)
|
657
|
+
|
658
|
+
# Ensure the payload token will be used if the option is set.
|
659
|
+
unless configuration.use_payload_access_token
|
660
|
+
request.add_field('X-Rollbar-Access-Token', access_token)
|
661
|
+
end
|
662
|
+
|
663
|
+
handle_net_retries { http.request(request) }
|
664
|
+
end
|
665
|
+
|
666
|
+
def init_http(uri)
|
629
667
|
proxy = http_proxy(uri)
|
630
|
-
http = Net::HTTP.new(uri.host, uri.port, proxy.host, proxy.port, proxy.user,
|
668
|
+
http = Net::HTTP.new(uri.host, uri.port, proxy.host, proxy.port, proxy.user,
|
669
|
+
proxy.password)
|
631
670
|
|
632
|
-
http
|
633
|
-
http.read_timeout = configuration.request_timeout
|
671
|
+
init_http_timeouts(http)
|
634
672
|
|
635
673
|
if uri.scheme == 'https'
|
636
674
|
http.use_ssl = true
|
637
675
|
http.verify_mode = ssl_verify_mode
|
638
676
|
end
|
639
677
|
|
640
|
-
|
641
|
-
|
642
|
-
request.body = pack_ruby260_bytes(body)
|
643
|
-
request.add_field('X-Rollbar-Access-Token', access_token)
|
678
|
+
http
|
679
|
+
end
|
644
680
|
|
645
|
-
|
681
|
+
def init_http_timeouts(http)
|
682
|
+
http.open_timeout = configuration.open_timeout
|
683
|
+
http.read_timeout = configuration.request_timeout
|
646
684
|
end
|
647
685
|
|
648
686
|
def pack_ruby260_bytes(body)
|
649
687
|
# Ruby 2.6.0 shipped with a bug affecting multi-byte body for Net::HTTP.
|
650
688
|
# Fix (committed one day after 2.6.0p0 shipped) is here:
|
651
|
-
#
|
689
|
+
# ruby/ruby/commit/1680a13a926b17661329beec1ded6b32aad16c1b
|
652
690
|
#
|
653
691
|
# We work around this by repacking the body as single byte chars if needed.
|
654
692
|
if RUBY_VERSION == '2.6.0' && multibyte?(body)
|
@@ -698,8 +736,6 @@ module Rollbar
|
|
698
736
|
end
|
699
737
|
|
700
738
|
def handle_net_retries
|
701
|
-
return yield if skip_retries?
|
702
|
-
|
703
739
|
retries = configuration.net_retries - 1
|
704
740
|
|
705
741
|
begin
|
@@ -713,15 +749,13 @@ module Rollbar
|
|
713
749
|
end
|
714
750
|
end
|
715
751
|
|
716
|
-
def skip_retries?
|
717
|
-
Rollbar::LanguageSupport.ruby_19?
|
718
|
-
end
|
719
|
-
|
720
752
|
def handle_response(response)
|
721
753
|
if response.code == '200'
|
722
754
|
log_info '[Rollbar] Success'
|
723
755
|
else
|
724
|
-
log_warning
|
756
|
+
log_warning(
|
757
|
+
"[Rollbar] Got unexpected status code from Rollbar api: #{response.code}"
|
758
|
+
)
|
725
759
|
log_info "[Rollbar] Response: #{response.body}"
|
726
760
|
configuration.execute_hook(:on_error_response, response)
|
727
761
|
end
|
@@ -741,11 +775,7 @@ module Rollbar
|
|
741
775
|
body = item.dump
|
742
776
|
return unless body
|
743
777
|
|
744
|
-
file_name =
|
745
|
-
configuration.filepath.gsub(EXTENSION_REGEXP, "_#{Process.pid}\\0")
|
746
|
-
else
|
747
|
-
configuration.filepath
|
748
|
-
end
|
778
|
+
file_name = file_name_with_pid(configuration)
|
749
779
|
|
750
780
|
begin
|
751
781
|
@file ||= File.open(file_name, 'a')
|
@@ -760,11 +790,22 @@ module Rollbar
|
|
760
790
|
end
|
761
791
|
end
|
762
792
|
|
793
|
+
def file_name_with_pid(configuration)
|
794
|
+
if configuration.files_with_pid_name_enabled
|
795
|
+
configuration.filepath.gsub(EXTENSION_REGEXP, "_#{Process.pid}\\0")
|
796
|
+
else
|
797
|
+
configuration.filepath
|
798
|
+
end
|
799
|
+
end
|
800
|
+
|
763
801
|
def update_file(file, file_name)
|
764
802
|
return unless configuration.files_processed_enabled
|
765
803
|
|
766
804
|
time_now = Time.now
|
767
|
-
|
805
|
+
if configuration.files_processed_duration > time_now - file.birthtime &&
|
806
|
+
file.size < configuration.files_processed_size
|
807
|
+
return
|
808
|
+
end
|
768
809
|
|
769
810
|
new_file_name = file_name.gsub(EXTENSION_REGEXP, "_processed_#{time_now.to_i}\\0")
|
770
811
|
File.rename(file, new_file_name)
|
@@ -773,31 +814,30 @@ module Rollbar
|
|
773
814
|
end
|
774
815
|
|
775
816
|
def failsafe_reason(message, exception)
|
776
|
-
|
817
|
+
return failsafe_exception_reason(message, exception) if exception
|
777
818
|
|
778
|
-
|
779
|
-
|
780
|
-
|
781
|
-
|
819
|
+
message.to_s
|
820
|
+
rescue StandardError
|
821
|
+
log_error('[Rollbar] Error building failsafe message')
|
822
|
+
''
|
823
|
+
end
|
782
824
|
|
783
|
-
|
784
|
-
|
785
|
-
|
786
|
-
exception_info += " in #{nearest_frame}" if nearest_frame
|
825
|
+
def failsafe_exception_reason(message, exception)
|
826
|
+
backtrace = exception.backtrace || []
|
827
|
+
nearest_frame = backtrace[0]
|
787
828
|
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
|
792
|
-
|
793
|
-
begin
|
794
|
-
body += message.to_s
|
795
|
-
rescue StandardError
|
796
|
-
log_error('[Rollbar] Error building failsafe message')
|
797
|
-
end
|
829
|
+
exception_info = exception.class.name
|
830
|
+
# #to_s and #message defaults to class.to_s.
|
831
|
+
# Add message only if add valuable info.
|
832
|
+
if exception.message != exception.class.to_s
|
833
|
+
exception_info += %[: "#{exception.message}"]
|
798
834
|
end
|
835
|
+
exception_info += " in #{nearest_frame}" if nearest_frame
|
799
836
|
|
800
|
-
|
837
|
+
"#{exception_info}: #{message}"
|
838
|
+
rescue StandardError
|
839
|
+
log_error('[Rollbar] Error building failsafe exception message')
|
840
|
+
''
|
801
841
|
end
|
802
842
|
|
803
843
|
def failsafe_body(reason)
|
@@ -830,7 +870,8 @@ module Rollbar
|
|
830
870
|
configuration.async_handler.call(payload)
|
831
871
|
rescue StandardError
|
832
872
|
if configuration.failover_handlers.empty?
|
833
|
-
log_error '[Rollbar] Async handler failed, and there are no failover
|
873
|
+
log_error '[Rollbar] Async handler failed, and there are no failover ' \
|
874
|
+
'handlers configured. See the docs for "failover_handlers"'
|
834
875
|
return
|
835
876
|
end
|
836
877
|
|
@@ -848,7 +889,8 @@ module Rollbar
|
|
848
889
|
rescue StandardError
|
849
890
|
next unless handler == failover_handlers.last
|
850
891
|
|
851
|
-
log_error
|
892
|
+
log_error '[Rollbar] All failover handlers failed while processing ' \
|
893
|
+
"item: #{Rollbar::JSON.dump(item.payload)}"
|
852
894
|
end
|
853
895
|
end
|
854
896
|
end
|
@@ -859,7 +901,9 @@ module Rollbar
|
|
859
901
|
return unless data[:uuid]
|
860
902
|
|
861
903
|
uuid_url = Util.uuid_rollbar_url(data, configuration)
|
862
|
-
log_info
|
904
|
+
log_info(
|
905
|
+
"[Rollbar] Details: #{uuid_url} (only available if report was successful)"
|
906
|
+
)
|
863
907
|
end
|
864
908
|
|
865
909
|
def via_failsafe?(item)
|
data/lib/rollbar/plugin.rb
CHANGED
@@ -4,12 +4,8 @@ module Rollbar
|
|
4
4
|
# On Rollbar initialization, all plugins will be saved in memory and those that
|
5
5
|
# satisfy the dependencies will be loaded
|
6
6
|
class Plugin
|
7
|
-
attr_reader :name
|
8
|
-
|
9
|
-
attr_reader :callables
|
10
|
-
attr_reader :revert_callables
|
11
|
-
attr_accessor :on_demand
|
12
|
-
attr_accessor :loaded
|
7
|
+
attr_reader :name, :dependencies, :callables, :revert_callables
|
8
|
+
attr_accessor :on_demand, :loaded
|
13
9
|
|
14
10
|
private :loaded=
|
15
11
|
|
@@ -116,11 +112,15 @@ module Rollbar
|
|
116
112
|
end
|
117
113
|
|
118
114
|
def log_loading_error(error)
|
119
|
-
Rollbar.log_error(
|
115
|
+
Rollbar.log_error(
|
116
|
+
"Error trying to load plugin '#{name}': #{error.class}, #{error.message}"
|
117
|
+
)
|
120
118
|
end
|
121
119
|
|
122
120
|
def log_unloading_error(error)
|
123
|
-
Rollbar.log_error(
|
121
|
+
Rollbar.log_error(
|
122
|
+
"Error trying to unload plugin '#{name}': #{error.class}, #{error.message}"
|
123
|
+
)
|
124
124
|
end
|
125
125
|
end
|
126
126
|
end
|
@@ -3,11 +3,17 @@ module Rollbar
|
|
3
3
|
module ActiveJob
|
4
4
|
def self.included(base)
|
5
5
|
base.send :rescue_from, Exception do |exception|
|
6
|
+
args = if self.class.respond_to?(:log_arguments?) && !self.class.log_arguments?
|
7
|
+
arguments.map(&Rollbar::Scrubbers.method(:scrub_value))
|
8
|
+
else
|
9
|
+
arguments
|
10
|
+
end
|
11
|
+
|
6
12
|
Rollbar.error(exception,
|
7
13
|
:job => self.class.name,
|
8
14
|
:job_id => job_id,
|
9
15
|
:use_exception_level_filters => true,
|
10
|
-
:arguments =>
|
16
|
+
:arguments => args)
|
11
17
|
raise exception
|
12
18
|
end
|
13
19
|
end
|
@@ -17,6 +23,13 @@ end
|
|
17
23
|
if defined?(ActiveSupport) && ActiveSupport.respond_to?(:on_load)
|
18
24
|
ActiveSupport.on_load(:action_mailer) do
|
19
25
|
# Automatically add to ActionMailer::DeliveryJob
|
20
|
-
|
26
|
+
if defined?(ActionMailer::DeliveryJob)
|
27
|
+
ActionMailer::DeliveryJob.send(:include,
|
28
|
+
Rollbar::ActiveJob)
|
29
|
+
end
|
30
|
+
# Rails >= 6.0
|
31
|
+
if defined?(ActionMailer::MailDeliveryJob)
|
32
|
+
ActionMailer::MailDeliveryJob.send(:include, Rollbar::ActiveJob)
|
33
|
+
end
|
21
34
|
end
|
22
35
|
end
|
@@ -15,9 +15,15 @@ module Rollbar
|
|
15
15
|
|
16
16
|
# DelayedJob < 4.1 doesn't provide job#error
|
17
17
|
if job.class.method_defined? :error
|
18
|
-
|
18
|
+
if job.error
|
19
|
+
::Rollbar.scope(:request => data)
|
20
|
+
.error(job.error, :use_exception_level_filters => true)
|
21
|
+
end
|
19
22
|
elsif job.last_error
|
20
|
-
::Rollbar.scope(:request => data).error(
|
23
|
+
::Rollbar.scope(:request => data).error(
|
24
|
+
"Job has failed and won't be retried anymore: #{job.last_error}",
|
25
|
+
:use_exception_level_filters => true
|
26
|
+
)
|
21
27
|
end
|
22
28
|
end
|
23
29
|
end
|
@@ -56,10 +62,15 @@ module Rollbar
|
|
56
62
|
|
57
63
|
data = build_job_data(job)
|
58
64
|
|
59
|
-
::Rollbar.scope(:request => data)
|
65
|
+
::Rollbar.scope(:request => data)
|
66
|
+
.error(e, :use_exception_level_filters => true)
|
60
67
|
end
|
61
68
|
|
62
69
|
def self.skip_report?(job)
|
70
|
+
handler = ::Rollbar.configuration.async_skip_report_handler
|
71
|
+
|
72
|
+
return handler.call(job) if handler.respond_to?(:call)
|
73
|
+
|
63
74
|
job.attempts < ::Rollbar.configuration.dj_threshold
|
64
75
|
end
|
65
76
|
|