mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
24 lines
619 B
Ruby
24 lines
619 B
Ruby
# 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)
|
|
ActiveSupport::Notifications.instrument \
|
|
"#{operation}.active_job", payload.merge(adapter: queue_adapter, job: self), &block
|
|
end
|
|
end
|
|
end
|