Class: PrometheusExporter::Server::Runner
- Inherits:
-
Object
- Object
- PrometheusExporter::Server::Runner
- Defined in:
- lib/prometheus_exporter/server/runner.rb
Instance Attribute Summary collapse
- #bind ⇒ Object
- #collector_class ⇒ Object
- #port ⇒ Object
- #prefix ⇒ Object
- #server_class ⇒ Object
- #timeout ⇒ Object
- #type_collectors ⇒ Object
-
#unicorn_listen_address ⇒ Object
Returns the value of attribute unicorn_listen_address.
-
#unicorn_pid_file ⇒ Object
Returns the value of attribute unicorn_pid_file.
- #verbose ⇒ Object
Instance Method Summary collapse
- #collector ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #start ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
11 12 13 14 15 |
# File 'lib/prometheus_exporter/server/runner.rb', line 11 def initialize( = {}) .each do |k, v| send("#{k}=", v) if self.class.method_defined?("#{k}=") end end |
Instance Attribute Details
#bind ⇒ Object
50 51 52 |
# File 'lib/prometheus_exporter/server/runner.rb', line 50 def bind @bind || PrometheusExporter::DEFAULT_BIND_ADDRESS end |
#collector_class ⇒ Object
54 55 56 |
# File 'lib/prometheus_exporter/server/runner.rb', line 54 def collector_class @collector_class || PrometheusExporter::Server::Collector end |
#port ⇒ Object
46 47 48 |
# File 'lib/prometheus_exporter/server/runner.rb', line 46 def port @port || PrometheusExporter::DEFAULT_PORT end |
#prefix ⇒ Object
42 43 44 |
# File 'lib/prometheus_exporter/server/runner.rb', line 42 def prefix @prefix || PrometheusExporter::DEFAULT_PREFIX end |
#server_class ⇒ Object
71 72 73 |
# File 'lib/prometheus_exporter/server/runner.rb', line 71 def server_class @server_class || PrometheusExporter::Server::WebServer end |
#timeout ⇒ Object
62 63 64 |
# File 'lib/prometheus_exporter/server/runner.rb', line 62 def timeout @timeout || PrometheusExporter::DEFAULT_TIMEOUT end |
#type_collectors ⇒ Object
58 59 60 |
# File 'lib/prometheus_exporter/server/runner.rb', line 58 def type_collectors @type_collectors || [] end |
#unicorn_listen_address ⇒ Object
Returns the value of attribute unicorn_listen_address.
39 40 41 |
# File 'lib/prometheus_exporter/server/runner.rb', line 39 def unicorn_listen_address @unicorn_listen_address end |
#unicorn_pid_file ⇒ Object
Returns the value of attribute unicorn_pid_file.
39 40 41 |
# File 'lib/prometheus_exporter/server/runner.rb', line 39 def unicorn_pid_file @unicorn_pid_file end |
#verbose ⇒ Object
66 67 68 69 |
# File 'lib/prometheus_exporter/server/runner.rb', line 66 def verbose return @verbose if defined? @verbose false end |
Instance Method Details
#collector ⇒ Object
75 76 77 |
# File 'lib/prometheus_exporter/server/runner.rb', line 75 def collector @_collector ||= collector_class.new end |
#start ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 |
# File 'lib/prometheus_exporter/server/runner.rb', line 17 def start PrometheusExporter::Metric::Base.default_prefix = prefix register_type_collectors unless collector.is_a?(PrometheusExporter::Server::CollectorBase) raise WrongInheritance, 'Collector class must be inherited from PrometheusExporter::Server::CollectorBase' end if unicorn_listen_address && unicorn_pid_file local_client = PrometheusExporter::LocalClient.new(collector: collector) PrometheusExporter::Instrumentation::Unicorn.start( pid_file: unicorn_pid_file, listener_address: unicorn_listen_address, client: local_client ) end server = server_class.new port: port, bind: bind, collector: collector, timeout: timeout, verbose: verbose server.start end |