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
562 563 564 565 |
# File 'lib/logbrew/rails_integration.rb', line 562 def _perform_job operation = @logbrew_perform_operation operation.nil? ? super : operation.around { super } end |
#deserialize(payload) ⇒ Object
532 533 534 535 536 537 538 539 540 |
# File 'lib/logbrew/rails_integration.rb', line 532 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
508 509 510 511 512 513 514 515 516 517 |
# File 'lib/logbrew/rails_integration.rb', line 508 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
542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 |
# File 'lib/logbrew/rails_integration.rb', line 542 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
519 520 521 522 523 524 525 526 527 528 529 530 |
# File 'lib/logbrew/rails_integration.rb', line 519 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 |