Class: Bigcommerce::Prometheus::Servers::Thin::RackApp
- Inherits:
-
Object
- Object
- Bigcommerce::Prometheus::Servers::Thin::RackApp
- Defined in:
- lib/bigcommerce/prometheus/servers/thin/rack_app.rb
Overview
Handles metrics requests as a Rack App on the Thin server
Instance Method Summary collapse
-
#add_type_collector(collector) ⇒ Object
Add a type collector to this server.
- #call(env) ⇒ Object
-
#initialize(collector: nil, timeout: nil, logger: nil) ⇒ RackApp
constructor
A new instance of RackApp.
Constructor Details
#initialize(collector: nil, timeout: nil, logger: nil) ⇒ RackApp
Returns a new instance of RackApp.
28 29 30 31 32 33 |
# File 'lib/bigcommerce/prometheus/servers/thin/rack_app.rb', line 28 def initialize(collector: nil, timeout: nil, logger: nil) @timeout = timeout || ::Bigcommerce::Prometheus.server_timeout @collector = collector || ::PrometheusExporter::Server::Collector.new @logger = logger || ::Bigcommerce::Prometheus.logger @server_metrics = ::Bigcommerce::Prometheus::Servers::Thin::ServerMetrics.new(logger: @logger) end |
Instance Method Details
#add_type_collector(collector) ⇒ Object
Add a type collector to this server
50 51 52 |
# File 'lib/bigcommerce/prometheus/servers/thin/rack_app.rb', line 50 def add_type_collector(collector) @collector.register_collector(collector) end |
#call(env) ⇒ Object
35 36 37 38 39 40 41 42 43 |
# File 'lib/bigcommerce/prometheus/servers/thin/rack_app.rb', line 35 def call(env) request = ::Rack::Request.new(env) response = ::Rack::Response.new controller = route(request) handle(controller: controller, request: request, response: response) rescue StandardError => e @logger.error "Error: #{e.}" handle(controller: ::Bigcommerce::Prometheus::Servers::Thin::Controllers::ErrorController, request: request, response: response) end |