rollbar 3.2.0 → 3.3.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +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
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,33 +649,44 @@ module Rollbar
|
|
626
649
|
end
|
627
650
|
|
628
651
|
def do_post(uri, body, access_token)
|
629
|
-
|
630
|
-
http = Net::HTTP.new(uri.host, uri.port, proxy.host, proxy.port, proxy.user, proxy.password)
|
631
|
-
|
632
|
-
http.open_timeout = configuration.open_timeout
|
633
|
-
http.read_timeout = configuration.request_timeout
|
634
|
-
|
635
|
-
if uri.scheme == 'https'
|
636
|
-
http.use_ssl = true
|
637
|
-
http.verify_mode = ssl_verify_mode
|
638
|
-
end
|
652
|
+
http = init_http(uri)
|
639
653
|
|
640
654
|
request = Net::HTTP::Post.new(uri.request_uri)
|
641
655
|
|
642
656
|
request.body = pack_ruby260_bytes(body)
|
643
657
|
|
644
658
|
# Ensure the payload token will be used if the option is set.
|
645
|
-
unless
|
659
|
+
unless configuration.use_payload_access_token
|
646
660
|
request.add_field('X-Rollbar-Access-Token', access_token)
|
647
661
|
end
|
648
662
|
|
649
663
|
handle_net_retries { http.request(request) }
|
650
664
|
end
|
651
665
|
|
666
|
+
def init_http(uri)
|
667
|
+
proxy = http_proxy(uri)
|
668
|
+
http = Net::HTTP.new(uri.host, uri.port, proxy.host, proxy.port, proxy.user,
|
669
|
+
proxy.password)
|
670
|
+
|
671
|
+
init_http_timeouts(http)
|
672
|
+
|
673
|
+
if uri.scheme == 'https'
|
674
|
+
http.use_ssl = true
|
675
|
+
http.verify_mode = ssl_verify_mode
|
676
|
+
end
|
677
|
+
|
678
|
+
http
|
679
|
+
end
|
680
|
+
|
681
|
+
def init_http_timeouts(http)
|
682
|
+
http.open_timeout = configuration.open_timeout
|
683
|
+
http.read_timeout = configuration.request_timeout
|
684
|
+
end
|
685
|
+
|
652
686
|
def pack_ruby260_bytes(body)
|
653
687
|
# Ruby 2.6.0 shipped with a bug affecting multi-byte body for Net::HTTP.
|
654
688
|
# Fix (committed one day after 2.6.0p0 shipped) is here:
|
655
|
-
#
|
689
|
+
# ruby/ruby/commit/1680a13a926b17661329beec1ded6b32aad16c1b
|
656
690
|
#
|
657
691
|
# We work around this by repacking the body as single byte chars if needed.
|
658
692
|
if RUBY_VERSION == '2.6.0' && multibyte?(body)
|
@@ -719,7 +753,9 @@ module Rollbar
|
|
719
753
|
if response.code == '200'
|
720
754
|
log_info '[Rollbar] Success'
|
721
755
|
else
|
722
|
-
log_warning
|
756
|
+
log_warning(
|
757
|
+
"[Rollbar] Got unexpected status code from Rollbar api: #{response.code}"
|
758
|
+
)
|
723
759
|
log_info "[Rollbar] Response: #{response.body}"
|
724
760
|
configuration.execute_hook(:on_error_response, response)
|
725
761
|
end
|
@@ -739,11 +775,7 @@ module Rollbar
|
|
739
775
|
body = item.dump
|
740
776
|
return unless body
|
741
777
|
|
742
|
-
file_name =
|
743
|
-
configuration.filepath.gsub(EXTENSION_REGEXP, "_#{Process.pid}\\0")
|
744
|
-
else
|
745
|
-
configuration.filepath
|
746
|
-
end
|
778
|
+
file_name = file_name_with_pid(configuration)
|
747
779
|
|
748
780
|
begin
|
749
781
|
@file ||= File.open(file_name, 'a')
|
@@ -758,11 +790,22 @@ module Rollbar
|
|
758
790
|
end
|
759
791
|
end
|
760
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
|
+
|
761
801
|
def update_file(file, file_name)
|
762
802
|
return unless configuration.files_processed_enabled
|
763
803
|
|
764
804
|
time_now = Time.now
|
765
|
-
|
805
|
+
if configuration.files_processed_duration > time_now - file.birthtime &&
|
806
|
+
file.size < configuration.files_processed_size
|
807
|
+
return
|
808
|
+
end
|
766
809
|
|
767
810
|
new_file_name = file_name.gsub(EXTENSION_REGEXP, "_processed_#{time_now.to_i}\\0")
|
768
811
|
File.rename(file, new_file_name)
|
@@ -771,31 +814,30 @@ module Rollbar
|
|
771
814
|
end
|
772
815
|
|
773
816
|
def failsafe_reason(message, exception)
|
774
|
-
|
817
|
+
return failsafe_exception_reason(message, exception) if exception
|
775
818
|
|
776
|
-
|
777
|
-
|
778
|
-
|
779
|
-
|
819
|
+
message.to_s
|
820
|
+
rescue StandardError
|
821
|
+
log_error('[Rollbar] Error building failsafe message')
|
822
|
+
''
|
823
|
+
end
|
780
824
|
|
781
|
-
|
782
|
-
|
783
|
-
|
784
|
-
exception_info += " in #{nearest_frame}" if nearest_frame
|
825
|
+
def failsafe_exception_reason(message, exception)
|
826
|
+
backtrace = exception.backtrace || []
|
827
|
+
nearest_frame = backtrace[0]
|
785
828
|
|
786
|
-
|
787
|
-
|
788
|
-
|
789
|
-
|
790
|
-
|
791
|
-
begin
|
792
|
-
body += message.to_s
|
793
|
-
rescue StandardError
|
794
|
-
log_error('[Rollbar] Error building failsafe message')
|
795
|
-
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}"]
|
796
834
|
end
|
835
|
+
exception_info += " in #{nearest_frame}" if nearest_frame
|
797
836
|
|
798
|
-
|
837
|
+
"#{exception_info}: #{message}"
|
838
|
+
rescue StandardError
|
839
|
+
log_error('[Rollbar] Error building failsafe exception message')
|
840
|
+
''
|
799
841
|
end
|
800
842
|
|
801
843
|
def failsafe_body(reason)
|
@@ -828,7 +870,8 @@ module Rollbar
|
|
828
870
|
configuration.async_handler.call(payload)
|
829
871
|
rescue StandardError
|
830
872
|
if configuration.failover_handlers.empty?
|
831
|
-
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"'
|
832
875
|
return
|
833
876
|
end
|
834
877
|
|
@@ -846,7 +889,8 @@ module Rollbar
|
|
846
889
|
rescue StandardError
|
847
890
|
next unless handler == failover_handlers.last
|
848
891
|
|
849
|
-
log_error
|
892
|
+
log_error '[Rollbar] All failover handlers failed while processing ' \
|
893
|
+
"item: #{Rollbar::JSON.dump(item.payload)}"
|
850
894
|
end
|
851
895
|
end
|
852
896
|
end
|
@@ -857,7 +901,9 @@ module Rollbar
|
|
857
901
|
return unless data[:uuid]
|
858
902
|
|
859
903
|
uuid_url = Util.uuid_rollbar_url(data, configuration)
|
860
|
-
log_info
|
904
|
+
log_info(
|
905
|
+
"[Rollbar] Details: #{uuid_url} (only available if report was successful)"
|
906
|
+
)
|
861
907
|
end
|
862
908
|
|
863
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,9 @@ 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
|
21
30
|
end
|
22
31
|
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,7 +62,8 @@ 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)
|