Commit 8b16a614 authored by Ahmad Sherif's avatar Ahmad Sherif
Browse files

Add configuration for setting listen address and port

parent 9ffe258d
server:
listen_address: 0.0.0.0
listen_port: 4567
probes:
dead_tuples_count:
class_name: Database::DeadTuplesProber
......
......@@ -5,8 +5,20 @@ module GitLab
# Metrics web exporter
class WebExporter < Sinatra::Base
class << self
def setup(config) # rubocop:disable Metrics/AbcSize
config[:probes].each do |probe_name, params|
def setup(config)
setup_server(config[:server])
setup_probes(config[:probes])
end
def setup_server(config)
config ||= {}
set(:bind, config.fetch(:listen_address, "0.0.0.0"))
set(:port, config.fetch(:listen_port, 4567))
end
def setup_probes(config) # rubocop:disable Metrics/AbcSize
(config || {}).each do |probe_name, params|
prober_class_name = params.delete(:class_name) || Utils.camel_case_string("#{probe_name}_prober")
prober_class = resolve_prober_class(prober_class_name)
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment