Sha256: c08c556d73e1c016d810ed3834fe3edfa676465b9d062710965a726a8a51715b

Contents?: true

Size: 972 Bytes

Versions: 7

Compression:

Stored size: 972 Bytes

Contents

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

      def call(worker, msg, queue)
        now = Time.current
        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 = (Time.current - now) * 1000
          record.save
        end
      end
    end
  end
end

Version data entries

7 entries across 7 versions & 1 rubygems

Version Path
rails_performance-1.4.0.alpha3 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.4.0.alpha2 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.4.0.alpha1 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.3.3 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.3.2 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.3.1 lib/rails_performance/gems/sidekiq_ext.rb
rails_performance-1.3.0 lib/rails_performance/gems/sidekiq_ext.rb