Sha256: 39d0fd580c6f77234109e4547ea98b24d6cc694d9d80a7fe229f66314ffc3928

Contents?: true

Size: 778 Bytes

Versions: 3

Compression:

Stored size: 778 Bytes

Contents

# frozen_string_literal: true

require 'rails_autoscale_agent/logger'

module RailsAutoscaleAgent
  module WorkerAdapters
    class Sidekiq
      include RailsAutoscaleAgent::Logger
      include Singleton

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

      def collect!(store)
        log_msg = String.new

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

        logger.debug log_msg
      end
    end
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
rails_autoscale_agent-0.9.0.beta.4 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb
rails_autoscale_agent-0.9.0.beta.2 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb
rails_autoscale_agent-0.9.0.beta.1 lib/rails_autoscale_agent/worker_adapters/sidekiq.rb