Class: Bigcommerce::Prometheus::Instrumentors::Web

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

Overview

Instrumentors for web process

Instance Method Summary collapse

Methods included from Loggable

#logger

Constructor Details

#initialize(app:) ⇒ Web

Returns a new instance of Web.



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

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

Instance Method Details

#startObject

Start the web instrumentor



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

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

  setup_before_fork
  setup_after_fork
  setup_middleware
rescue StandardError => e
  logger.error "[bigcommerce-prometheus][#{@process_name}] Failed to start web instrumentation - #{e.message} - #{e.backtrace[0..4].join("\n")}"
end