Sha256: a3b7a544265c44b010dee150a7cdaa0cb3d666f6f571f63e10a64125af0a9464

Contents?: true

Size: 844 Bytes

Versions: 1

Compression:

Stored size: 844 Bytes

Contents

require 'vizsla/background_timer'
require 'vizsla/puppet_master'

module Resque
  module Plugins
    module VizslaInstrumentation
      module Job
        def before_perform_with_vizsla(*args)
          @vizsla_timer = ::Vizsla::BackgroundTimer.new
          @vizsla_timer.start!

          yield *args if block_given?
        end

        def after_perform_with_vizsla(*args)
          @vizsla_timer.stop!
          ::Vizsla::PuppetMaster.new(@vizsla_timer, logger: Resque.logger).process

          yield *args if block_given?
        end
      end
    end
  end
end

module Vizsla
  module BackgroundJobInstrumentation
    module ResqueInstrumentationInstaller
      def payload_class
        klass = super
        klass.instance_eval do
          extend ::Resque::Plugins::VizslaInstrumentation::Job
        end
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracebin-0.0.7 lib/vizsla/background_job_instrumentation/resque.rb