Sha256: 932fb6627a64128b83c1f1d64198290f43fc2c47b3d7dd5bf59012d9113e20db

Contents?: true

Size: 588 Bytes

Versions: 4

Compression:

Stored size: 588 Bytes

Contents

# frozen_string_literal: true

require 'rails_autoscale_agent/logger'

module WorkerAdapters
  class Sidekiq
    include RailsAutoscaleAgent::Logger

    def enabled?
      require 'sidekiq/api'
      true
    rescue LoadError
      false
    end

    # TODO: specs
    def collect!(store)
      log_msg = String.new('Sidekiq latency ')

      ::Sidekiq::Queue.all.each do |queue|
        latency_ms = (queue.latency * 1000).ceil
        store.push latency_ms, Time.now, queue.name
        log_msg << "#{queue.name}=#{latency_ms} "
      end

      logger.debug log_msg
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
rails_autoscale_agent-0.7.0 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb
rails_autoscale_agent-0.6.3 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb
rails_autoscale_agent-0.6.2 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb
rails_autoscale_agent-0.6.1 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb