Sha256: fac1da3b0a6862952ce4a87c7bfe03e4437b28a2471d92f991ca2438b61ecf3a

Contents?: true

Size: 1.74 KB

Versions: 20

Compression:

Stored size: 1.74 KB

Contents

if defined?(Resque::Worker)
  Resque.send(:extend, Resque::Additions)
  Resque::Worker.send(:include, Resque::DynamicQueues)
  Resque::Worker.send(:include, Resque::SilenceDone) if ZuoraConnect.configuration.silencer_resque_finish == true
  Resque::Job.send(:include, Resque::SelfLookup)
end

if defined?(Resque::Job) && defined?(Prometheus)
  module ResquePrometheusExtensions
    EXPORTER = Prometheus::ResqueExporter.new
    def perform
      super
      EXPORTER.export
    end
  end

  class Resque::Job
    prepend ResquePrometheusExtensions
  end
end

Resque.module_eval do
  # Returns a hash, mapping queue names to queue sizes
  def queue_sizes
    paused_queues = Resque.redis.zrange("PauseQueue", 0, -1).map! {|key| key.split("__")[0]}
    queue_names = queues.delete_if{|name| paused_queues.include?(name.split("_")[0])}

    sizes = redis.pipelined do
      queue_names.each do |name|
        redis.llen("queue:#{name}")
      end
    end

    Hash[queue_names.zip(sizes)]
  end
end

if defined?(Resque.logger)
  Resque.logger = ZuoraConnect.custom_logger(name: "Resque", type: 'Monologger', level: MonoLogger::INFO) 
  Resque::Scheduler.logger = ZuoraConnect.custom_logger(name: "ResqueScheduler") if defined?(Resque::Scheduler)
end
if defined?(Delayed::Worker.logger)
  Delayed::Worker.logger = ZuoraConnect.custom_logger(name: "DelayedJob", type: 'Monologger', level: MonoLogger::INFO) 
end

Makara::Logging::Logger.logger = ZuoraConnect.custom_logger(name: "Makara") if defined?(Makara)
ElasticAPM.agent.config.logger = ZuoraConnect.custom_logger(name: "ElasticAPM", level: MonoLogger::WARN) if defined?(ElasticAPM) && ElasticAPM.running?
ActionMailer::Base.logger = ZuoraConnect.custom_logger(name: "ActionMailer", type: 'Monologger') if defined?(ActionMailer)

Version data entries

20 entries across 20 versions & 1 rubygems

Version Path
zuora_connect-2.0.60v config/initializers/resque.rb
zuora_connect-2.0.60u config/initializers/resque.rb
zuora_connect-2.0.60t config/initializers/resque.rb
zuora_connect-2.0.60s config/initializers/resque.rb
zuora_connect-2.0.60r config/initializers/resque.rb
zuora_connect-2.0.60q config/initializers/resque.rb
zuora_connect-2.0.60p config/initializers/resque.rb
zuora_connect-2.0.60o config/initializers/resque.rb
zuora_connect-2.0.60n config/initializers/resque.rb
zuora_connect-2.0.60m config/initializers/resque.rb
zuora_connect-2.0.60l config/initializers/resque.rb
zuora_connect-2.0.60k config/initializers/resque.rb
zuora_connect-2.0.60j config/initializers/resque.rb
zuora_connect-2.0.60i config/initializers/resque.rb
zuora_connect-2.0.60h config/initializers/resque.rb
zuora_connect-2.0.60g config/initializers/resque.rb
zuora_connect-2.0.60f config/initializers/resque.rb
zuora_connect-2.0.60e config/initializers/resque.rb
zuora_connect-2.0.60d config/initializers/resque.rb
zuora_connect-2.0.60c config/initializers/resque.rb