Class: Bigcommerce::Prometheus::Instrumentors::Resque

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

Overview

Instrumentors for resque process

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initialize(app:) ⇒ Resque

Returns a new instance of Resque.



27
28
29
30
31
32
33
34
35
36
# File 'lib/bigcommerce/prometheus/instrumentors/resque.rb', line 27

def initialize(app:)
  @app = app
  @enabled = Bigcommerce::Prometheus.enabled
  @process_name = Bigcommerce::Prometheus.process_name
  @server_port = Bigcommerce::Prometheus.server_port
  @server_timeout = Bigcommerce::Prometheus.server_timeout
  @server_prefix = Bigcommerce::Prometheus.server_prefix
  @collectors = Bigcommerce::Prometheus.resque_collectors || []
  @type_collectors = Bigcommerce::Prometheus.resque_type_collectors || []
end

Instance Method Details

#startObject

Start the web instrumentor



41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
# File 'lib/bigcommerce/prometheus/instrumentors/resque.rb', line 41

def start
  unless @enabled
    logger.debug "[bigcommerce-prometheus][#{@process_name}] Prometheus disabled, skipping resque start..."
    return
  end

  server.add_type_collector(PrometheusExporter::Server::ActiveRecordCollector.new)
  server.add_type_collector(Bigcommerce::Prometheus::TypeCollectors::Resque.new)
  @type_collectors.each do |tc|
    server.add_type_collector(tc)
  end
  server.start
  setup_middleware
rescue StandardError => e
  logger.error "[bigcommerce-prometheus][#{@process_name}] Failed to start resque instrumentation - #{e.message} - #{e.backtrace[0..4].join("\n")}"
end