Sha256: c0ae62f54bb527299262895a3693c947c8ea09a2d5e80b45f5f1f6955ae4f21f
Contents?: true
Size: 1012 Bytes
Versions: 3
Compression:
Stored size: 1012 Bytes
Contents
# frozen_string_literal: true module ActiveJob module Instrumentation #:nodoc: extend ActiveSupport::Concern included do around_enqueue do |_, block| scheduled_at ? instrument(:enqueue_at, &block) : instrument(:enqueue, &block) end around_perform do |_, block| instrument :perform_start instrument :perform, &block end end private def instrument(operation, payload = {}, &block) enhanced_block = ->(event_payload) do block.call if block if defined?(@_halted_callback_hook_called) && @_halted_callback_hook_called event_payload[:aborted] = true @_halted_callback_hook_called = nil end end ActiveSupport::Notifications.instrument \ "#{operation}.active_job", payload.merge(adapter: queue_adapter, job: self), &enhanced_block end def halted_callback_hook(*) super @_halted_callback_hook_called = true end end end
Version data entries
3 entries across 3 versions & 1 rubygems
Version | Path |
---|---|
activejob-6.1.0 | lib/active_job/instrumentation.rb |
activejob-6.1.0.rc2 | lib/active_job/instrumentation.rb |
activejob-6.1.0.rc1 | lib/active_job/instrumentation.rb |