Sha256: 2ec437aec5cda7930af035c6040ea07a18327b7c0d5402ccc15fdfa159479733

Contents?: true

Size: 1.27 KB

Versions: 8

Compression:

Stored size: 1.27 KB

Contents

module Hickory
  module LogSubscribers
    class ActiveJob < ActiveSupport::LogSubscriber
      def enqueue(event)
        logger.info('job-enqueued', job_metadata(event))
      end

      def enqueue_retry(event)
        metadata = job_metadata(event)
        metadata.merge!({
          error: event.payload[:error],
          wait: event.payload[:wait]
        })

        logger.info('job-retry-enqueued', metadata)
      end

      def perform_start(event)
        logger.info('job-perform-start', job_metadata(event))
      end

      def perform(event)
        logger.info('job-perform', job_metadata(event))
      end

      def retry_stopped(event)
        metadata = job_metadata(event)
        metadata.merge!({
          error: event.payload[:error]
        })

        logger.info('job-retry-stopped', metadata)
      end

      def retry_discard(event)
        metadata = job_metadata(event)
        metadata.merge!({
          error: event.payload[:error]
        })

        logger.info('job-discard', metadata)
      end

      private

      def job_metadata(event)
        job = event.payload[:job]

        {
          job_id: job.job_id,
          queue: job.queue_name,
          priority: job.priority,
          executions: job.executions
        }
      end

    end
  end
end

Version data entries

8 entries across 8 versions & 1 rubygems

Version Path
hickory-0.1.7 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.6 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.5 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.4 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.3 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.2 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.1 lib/hickory/log_subscribers/active_job.rb
hickory-0.1.0 lib/hickory/log_subscribers/active_job.rb