Sha256: 8107ad5e7797e2b049753286509464b868dcf6479f09d74f021338755402293a

Contents?: true

Size: 931 Bytes

Versions: 6

Compression:

Stored size: 931 Bytes

Contents

module RailsPerformance
  module Gems
    class Sidekiq

      def initialize(options=nil)
      end

      def call(worker, msg, queue)
        now  = Time.now
        data = {
          enqueued_ati: msg['enqueued_at'].to_i,
          created_ati: msg['created_at'].to_i,
          jid: msg['jid'],
          queue: queue,
          start_timei: now.to_i,
          datetime: now.strftime(RailsPerformance::FORMAT),
          worker: msg['wrapped'.freeze] || worker.class.to_s
        }
        begin
          yield
          data[:status]   = "success"
        rescue Exception => ex
          data[:status]   = "exception"
          data[:message]  = ex.message
        ensure
          # store in ms instead of seconds
          data[:duration] = (Time.now - now) * 1000
          #puts data
          RailsPerformance::Utils.log_job_in_redis(data)
        end
      end

    end
  end
end

Version data entries

6 entries across 6 versions & 1 rubygems

Version Path
rails_performance-0.9.6 lib/rails_performance/gems/sidekiq.rb
rails_performance-0.9.5 lib/rails_performance/gems/sidekiq.rb
rails_performance-0.9.4 lib/rails_performance/gems/sidekiq.rb
rails_performance-0.9.3 lib/rails_performance/gems/sidekiq.rb
rails_performance-0.9.2 lib/rails_performance/gems/sidekiq.rb
rails_performance-0.9.1 lib/rails_performance/gems/sidekiq.rb