Module: LogBrew::Rails::ActiveJobExtension
- Defined in:
- lib/logbrew/rails_integration.rb
Overview
Adapter-neutral ActiveJob tracing installed through the Rails lazy-load hook.
Instance Method Summary collapse
- #_perform_job ⇒ Object
- #deserialize(payload) ⇒ Object
- #enqueue(options = {}) ⇒ Object
- #perform_now ⇒ Object
- #serialize ⇒ Object
Instance Method Details
#_perform_job ⇒ Object
706 707 708 709 |
# File 'lib/logbrew/rails_integration.rb', line 706 def _perform_job operation = @logbrew_perform_operation operation.nil? ? super : operation.around { super } end |
#deserialize(payload) ⇒ Object
676 677 678 679 680 681 682 683 684 |
# File 'lib/logbrew/rails_integration.rb', line 676 def deserialize(payload) result = super begin @logbrew_queue_carrier = QueueCarrier.read(payload[QueueCarrier::KEY]) if payload.is_a?(Hash) rescue StandardError => error LogBrew::Rails.runtime&.report_error("active_job_capture", error) end result end |
#enqueue(options = {}) ⇒ Object
652 653 654 655 656 657 658 659 660 661 |
# File 'lib/logbrew/rails_integration.rb', line 652 def enqueue( = {}) operation = ActiveJobOperation.create(LogBrew::Rails.runtime, self, :enqueue) return super if operation.nil? previous = @logbrew_enqueue_operation @logbrew_enqueue_operation = operation operation.around { super } ensure @logbrew_enqueue_operation = previous unless operation.nil? end |
#perform_now ⇒ Object
686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 |
# File 'lib/logbrew/rails_integration.rb', line 686 def perform_now operation = ActiveJobOperation.create(LogBrew::Rails.runtime, self, :perform, carrier: @logbrew_queue_carrier) return super if operation.nil? previous = @logbrew_perform_operation @logbrew_perform_operation = operation begin Trace.with_context(operation.context) { super } rescue Exception => error # rubocop:disable Lint/RescueException operation.finish(error) operation.capture_terminal_issue(error) raise ensure unless operation.nil? operation.finish @logbrew_perform_operation = previous end end end |
#serialize ⇒ Object
663 664 665 666 667 668 669 670 671 672 673 674 |
# File 'lib/logbrew/rails_integration.rb', line 663 def serialize payload = super operation = @logbrew_enqueue_operation return payload if operation.nil? begin payload[QueueCarrier::KEY] = QueueCarrier.create(operation.context) rescue StandardError => error LogBrew::Rails.runtime&.report_error("active_job_capture", error) end payload end |