Class: Bigcommerce::Prometheus::Servers::Thin::Controllers::BaseController

Inherits:
Object
  • Object
show all
Defined in:
lib/bigcommerce/prometheus/servers/thin/controllers/base_controller.rb

Overview

Base thin controller for prometheus metrics

Instance Method Summary collapse

Constructor Details

#initialize(request:, response:, server_metrics:, collector:, logger:) ⇒ BaseController

Returns a new instance of BaseController.

Parameters:



34
35
36
37
38
39
40
# File 'lib/bigcommerce/prometheus/servers/thin/controllers/base_controller.rb', line 34

def initialize(request:, response:, server_metrics:, collector:, logger:)
  @request = request
  @response = response
  @collector = collector
  @server_metrics = server_metrics
  @logger = logger
end

Instance Method Details

#handleObject



42
43
44
45
# File 'lib/bigcommerce/prometheus/servers/thin/controllers/base_controller.rb', line 42

def handle
  call
  @response.finish
end

#set_header(key, value) ⇒ Object

Parameters:

  • key (String)
  • value (String)


51
52
53
54
55
56
57
# File 'lib/bigcommerce/prometheus/servers/thin/controllers/base_controller.rb', line 51

def set_header(key, value)
  if @response.respond_to?(:add_header) # rack 2.0+
    @response.add_header(key.to_s, value.to_s)
  else
    @response[key.to_s] = value.to_s
  end
end