Sha256: 9c0b6881f8bed9c1e022cabcedbe41f80daaea31bbc51953bbf3316dee0f73a2

Contents?: true

Size: 1004 Bytes

Versions: 5

Compression:

Stored size: 1004 Bytes

Contents

module RailsPerformance
  module Gems
    class SidekiqExt
      def initialize(options = nil)
      end

      def call(worker, msg, queue)
        now = RailsPerformance::Utils.time
        record = RailsPerformance::Models::SidekiqRecord.new(
          enqueued_ati: msg["enqueued_at"].to_i,
          datetimei: 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
          result = yield
          record.status = "success"
          result
        rescue Exception => ex # rubocop:disable Lint/RescueException
          record.status = "exception"
          record.message = ex.message
          raise ex
        ensure
          # store in ms instead of seconds
          record.duration = (RailsPerformance::Utils.time - now) * 1000
          record.save
        end
      end
    end
  end
end

Version data entries

5 entries across 5 versions & 1 rubygems

Version Path
rails_performance-1.4.1 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.4.1.alpha1 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.4.0 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.4.0.alpha5 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.4.0.alpha4 lib/rails_performance/gems/sidekiq_ext.rb