Class: PrometheusExporter::Server::Runner
- Inherits:
-
Object
- Object
- PrometheusExporter::Server::Runner
- Defined in:
- lib/prometheus_exporter/server/runner.rb
Instance Method Summary collapse
- #collector ⇒ Object
- #collector_class ⇒ Object
- #collector_class=(collector_class) ⇒ Object
-
#initialize(options = {}) ⇒ Runner
constructor
A new instance of Runner.
- #port ⇒ Object
- #port=(port) ⇒ Object
- #prefix ⇒ Object
- #prefix=(prefix) ⇒ Object
- #server_class ⇒ Object
- #server_class=(server_class) ⇒ Object
- #start ⇒ Object
- #timeout ⇒ Object
- #timeout=(timeout) ⇒ Object
- #type_collectors ⇒ Object
- #type_collectors=(type_collectors) ⇒ Object
- #verbose ⇒ Object
- #verbose=(verbose) ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
8 9 10 11 12 |
# File 'lib/prometheus_exporter/server/runner.rb', line 8 def initialize( = {}) .each do |k, v| send("#{k}=", v) if self.class.method_defined?("#{k}=") end end |
Instance Method Details
#collector ⇒ Object
84 85 86 |
# File 'lib/prometheus_exporter/server/runner.rb', line 84 def collector @_collector ||= collector_class.new end |
#collector_class ⇒ Object
47 48 49 |
# File 'lib/prometheus_exporter/server/runner.rb', line 47 def collector_class @collector_class || PrometheusExporter::Server::Collector end |
#collector_class=(collector_class) ⇒ Object
43 44 45 |
# File 'lib/prometheus_exporter/server/runner.rb', line 43 def collector_class=(collector_class) @collector_class = collector_class end |
#port ⇒ Object
39 40 41 |
# File 'lib/prometheus_exporter/server/runner.rb', line 39 def port @port || PrometheusExporter::DEFAULT_PORT end |
#port=(port) ⇒ Object
35 36 37 |
# File 'lib/prometheus_exporter/server/runner.rb', line 35 def port=(port) @port = port end |
#prefix ⇒ Object
31 32 33 |
# File 'lib/prometheus_exporter/server/runner.rb', line 31 def prefix @prefix || PrometheusExporter::DEFAULT_PREFIX end |
#prefix=(prefix) ⇒ Object
27 28 29 |
# File 'lib/prometheus_exporter/server/runner.rb', line 27 def prefix=(prefix) @prefix = prefix end |
#server_class ⇒ Object
80 81 82 |
# File 'lib/prometheus_exporter/server/runner.rb', line 80 def server_class @server_class || PrometheusExporter::Server::WebServer end |
#server_class=(server_class) ⇒ Object
76 77 78 |
# File 'lib/prometheus_exporter/server/runner.rb', line 76 def server_class=(server_class) @server_class = server_class end |
#start ⇒ Object
14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/prometheus_exporter/server/runner.rb', line 14 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 server = server_class.new port: port, collector: collector, timeout: timeout, verbose: verbose server.start end |
#timeout ⇒ Object
63 64 65 |
# File 'lib/prometheus_exporter/server/runner.rb', line 63 def timeout @timeout || PrometheusExporter::DEFAULT_TIMEOUT end |
#timeout=(timeout) ⇒ Object
59 60 61 |
# File 'lib/prometheus_exporter/server/runner.rb', line 59 def timeout=(timeout) @timeout = timeout end |
#type_collectors ⇒ Object
55 56 57 |
# File 'lib/prometheus_exporter/server/runner.rb', line 55 def type_collectors @type_collectors || [] end |
#type_collectors=(type_collectors) ⇒ Object
51 52 53 |
# File 'lib/prometheus_exporter/server/runner.rb', line 51 def type_collectors=(type_collectors) @type_collectors = type_collectors end |
#verbose ⇒ Object
71 72 73 74 |
# File 'lib/prometheus_exporter/server/runner.rb', line 71 def verbose return @verbose if defined? @verbose false end |
#verbose=(verbose) ⇒ Object
67 68 69 |
# File 'lib/prometheus_exporter/server/runner.rb', line 67 def verbose=(verbose) @verbose = verbose end |