Class: Bigcommerce::Prometheus::Collectors::Resque

Inherits:
Object
  • Object
show all
Includes:
Loggable
Defined in:
lib/bigcommerce/prometheus/collectors/resque.rb

Overview

Collect metrics to push to the server type collector

Class Method Summary collapse

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initialize(client:, frequency: nil) ⇒ Resque

Returns a new instance of Resque.

Parameters:



31
32
33
34
# File 'lib/bigcommerce/prometheus/collectors/resque.rb', line 31

def initialize(client:, frequency: nil)
  @client = client || Bigcommerce::Prometheus.client
  @frequency = frequency || 15
end

Class Method Details

.start(client: nil, frequency: nil) ⇒ Object

Start the collector



39
40
41
42
43
44
45
46
# File 'lib/bigcommerce/prometheus/collectors/resque.rb', line 39

def self.start(client: nil, frequency: nil)
  collector = new(client: client, frequency: frequency)
  Thread.new do
    loop do
      collector.run
    end
  end
end

Instance Method Details

#runObject



48
49
50
51
52
53
54
55
56
# File 'lib/bigcommerce/prometheus/collectors/resque.rb', line 48

def run
  metric = collect
  logger.debug "[bigcommerce-prometheus] Pushing resque metrics to type collector: #{metric.inspect}"
  @client.send_json metric
rescue StandardError => e
  logger.error "[bigcommerce-prometheus] Failed to collect resque prometheus stats: #{e.message}"
ensure
  sleep @frequency
end