Class: PrometheusExporter::Server::Runner
- Inherits:
-
Object
- Object
- PrometheusExporter::Server::Runner
- Defined in:
- lib/prometheus_exporter/server/runner.rb
Instance Attribute Summary collapse
- #auth ⇒ Object
- #bind ⇒ Object
- #collector_class ⇒ Object
- #histogram ⇒ Object
- #label ⇒ Object
- #port ⇒ Object
- #prefix ⇒ Object
- #realm ⇒ Object
- #server_class ⇒ Object
- #timeout ⇒ Object
-
#tls_cert_file ⇒ Object
Returns the value of attribute tls_cert_file.
-
#tls_key_file ⇒ Object
Returns the value of attribute tls_key_file.
- #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
- #stop ⇒ Object
Constructor Details
#initialize(options = {}) ⇒ Runner
Returns a new instance of Runner.
13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/prometheus_exporter/server/runner.rb', line 13 def initialize( = {}) @timeout = nil @port = nil @bind = nil @collector_class = nil @type_collectors = nil @prefix = nil @auth = nil @realm = nil @histogram = nil .each { |k, v| send("#{k}=", v) if self.class.method_defined?("#{k}=") } end |
Instance Attribute Details
#auth ⇒ Object
86 87 88 |
# File 'lib/prometheus_exporter/server/runner.rb', line 86 def auth @auth || nil end |
#bind ⇒ Object
102 103 104 |
# File 'lib/prometheus_exporter/server/runner.rb', line 102 def bind @bind || PrometheusExporter::DEFAULT_BIND_ADDRESS end |
#collector_class ⇒ Object
106 107 108 |
# File 'lib/prometheus_exporter/server/runner.rb', line 106 def collector_class @collector_class || PrometheusExporter::Server::Collector end |
#histogram ⇒ Object
135 136 137 |
# File 'lib/prometheus_exporter/server/runner.rb', line 135 def histogram @histogram || false end |
#label ⇒ Object
131 132 133 |
# File 'lib/prometheus_exporter/server/runner.rb', line 131 def label @label ||= PrometheusExporter::DEFAULT_LABEL end |
#port ⇒ Object
98 99 100 |
# File 'lib/prometheus_exporter/server/runner.rb', line 98 def port @port || PrometheusExporter::DEFAULT_PORT end |
#prefix ⇒ Object
94 95 96 |
# File 'lib/prometheus_exporter/server/runner.rb', line 94 def prefix @prefix || PrometheusExporter::DEFAULT_PREFIX end |
#realm ⇒ Object
90 91 92 |
# File 'lib/prometheus_exporter/server/runner.rb', line 90 def realm @realm || PrometheusExporter::DEFAULT_REALM end |
#server_class ⇒ Object
123 124 125 |
# File 'lib/prometheus_exporter/server/runner.rb', line 123 def server_class @server_class || PrometheusExporter::Server::WebServer end |
#timeout ⇒ Object
114 115 116 |
# File 'lib/prometheus_exporter/server/runner.rb', line 114 def timeout @timeout || PrometheusExporter::DEFAULT_TIMEOUT end |
#tls_cert_file ⇒ Object
Returns the value of attribute tls_cert_file.
72 73 74 |
# File 'lib/prometheus_exporter/server/runner.rb', line 72 def tls_cert_file @tls_cert_file end |
#tls_key_file ⇒ Object
Returns the value of attribute tls_key_file.
72 73 74 |
# File 'lib/prometheus_exporter/server/runner.rb', line 72 def tls_key_file @tls_key_file end |
#type_collectors ⇒ Object
110 111 112 |
# File 'lib/prometheus_exporter/server/runner.rb', line 110 def type_collectors @type_collectors || [] end |
#unicorn_listen_address ⇒ Object
Returns the value of attribute unicorn_listen_address.
72 73 74 |
# File 'lib/prometheus_exporter/server/runner.rb', line 72 def unicorn_listen_address @unicorn_listen_address end |
#unicorn_pid_file ⇒ Object
Returns the value of attribute unicorn_pid_file.
72 73 74 |
# File 'lib/prometheus_exporter/server/runner.rb', line 72 def unicorn_pid_file @unicorn_pid_file end |
#verbose ⇒ Object
118 119 120 121 |
# File 'lib/prometheus_exporter/server/runner.rb', line 118 def verbose return @verbose if defined?(@verbose) false end |
Instance Method Details
#collector ⇒ Object
127 128 129 |
# File 'lib/prometheus_exporter/server/runner.rb', line 127 def collector @_collector ||= collector_class.new end |
#start ⇒ Object
27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 |
# File 'lib/prometheus_exporter/server/runner.rb', line 27 def start PrometheusExporter::Metric::Base.default_prefix = prefix PrometheusExporter::Metric::Base.default_labels = label if histogram PrometheusExporter::Metric::Base.default_aggregation = PrometheusExporter::Metric::Histogram end 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 require_relative "../instrumentation" 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, auth: auth, realm: realm, tls_cert_file: tls_cert_file, tls_key_file: tls_key_file, ) @server.start end |
#stop ⇒ Object
68 69 70 |
# File 'lib/prometheus_exporter/server/runner.rb', line 68 def stop @server.stop end |