Sha256: 21e36abb546002dc5edf126753a00d683affc3548c27039b901cd033a051a189

Contents?: true

Size: 712 Bytes

Versions: 1

Compression:

Stored size: 712 Bytes

Contents

require 'logger'
require 'benchmark'

module ResqueMods
  module LoggedJob
    def around_perform_log_job(*args)
      clazz = self.name
      ResqueMods.logger.info "#{clazz} starting up with: #{args.join(", ")}"
      begin 
        run_time = Benchmark.realtime do 
          yield *args
        end 
      rescue => e
        ResqueMods.logger.info "#{clazz} completed unsuccessfully in #{run_time.round unless run_time.nil?} seconds with #{e.class}:#{e.message}"
        raise
      end 
      Librato.measure("resque_mods.logged_job.#{clazz}.run_time", run_time.round(3))
      ResqueMods.logger.info "#{clazz} completed successfully in #{run_time.round unless run_time.nil?} seconds"
    end 
  end 
end 

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
resque-mods-1.0.3 lib/resque-mods/logged_job.rb