lib/sidekiq_prometheus.rb in sidekiq_prometheus-1.0.1 vs lib/sidekiq_prometheus.rb in sidekiq_prometheus-1.1.0

- old
+ new

@@ -45,10 +45,13 @@ attr_accessor :periodic_metrics_enabled # @return [Integer] Interval in seconds to record metrics. Default: 30 attr_accessor :periodic_reporting_interval + # @return [String] Host on which the metrics server will listen. Default: localhost + attr_accessor :metrics_host + # @return [Integer] Port on which the metrics server will listen. Default: 9357 attr_accessor :metrics_port # Override the default Prometheus::Client # @return [Prometheus::Client] @@ -64,10 +67,11 @@ self.gc_metrics_enabled = true self.periodic_metrics_enabled = true self.global_metrics_enabled = true self.periodic_reporting_interval = 30 + self.metrics_host = 'localhost' self.metrics_port = 9359 self.custom_labels = {} self.custom_metrics = [] module_function @@ -177,19 +181,20 @@ end end ## # Start a new Prometheus exporter in a new thread. - # Will listen on SidekiqPrometheus.metrics_port + # Will listen on SidekiqPrometheus.metrics_host and + # SidekiqPrometheus.metrics_port def metrics_server @_metrics_server ||= Thread.new do Rack::Handler::WEBrick.run( Rack::Builder.new { use Prometheus::Middleware::Exporter, registry: SidekiqPrometheus.registry run ->(_) { [301, { 'Location' => '/metrics' }, []] } }, Port: SidekiqPrometheus.metrics_port, - BindAddress: '127.0.0.1', + Host: SidekiqPrometheus.metrics_host, ) end end end