Class: Bigcommerce::Prometheus::Collectors::Resque
- Inherits:
-
Object
- Object
- Bigcommerce::Prometheus::Collectors::Resque
- Includes:
- Loggable
- Defined in:
- lib/bigcommerce/prometheus/collectors/resque.rb
Overview
Collect metrics to push to the server type collector
Class Method Summary collapse
-
.start(client: nil, frequency: nil) ⇒ Object
Start the collector.
Instance Method Summary collapse
-
#initialize(client:, frequency: nil) ⇒ Resque
constructor
A new instance of Resque.
- #run ⇒ Object
Methods included from Loggable
Constructor Details
#initialize(client:, frequency: nil) ⇒ Resque
Returns a new instance of Resque.
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
#run ⇒ Object
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.}" ensure sleep @frequency end |