class PrometheusExporter::Server::Runner
Attributes
auth[W]
bind[W]
collector_class[W]
label[W]
port[W]
prefix[W]
realm[W]
server_class[W]
timeout[W]
type_collectors[W]
unicorn_listen_address[RW]
unicorn_pid_file[RW]
verbose[W]
Public Class Methods
new(options = {})
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 11 def initialize(options = {}) @timeout = nil @port = nil @bind = nil @collector_class = nil @type_collectors = nil @prefix = nil @auth = nil @realm = nil options.each do |k, v| send("#{k}=", v) if self.class.method_defined?("#{k}=") end end
Public Instance Methods
auth()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 52 def auth @auth || nil end
bind()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 68 def bind @bind || PrometheusExporter::DEFAULT_BIND_ADDRESS end
collector()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 93 def collector @_collector ||= collector_class.new end
collector_class()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 72 def collector_class @collector_class || PrometheusExporter::Server::Collector end
label()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 97 def label @label ||= PrometheusExporter::DEFAULT_LABEL end
port()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 64 def port @port || PrometheusExporter::DEFAULT_PORT end
prefix()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 60 def prefix @prefix || PrometheusExporter::DEFAULT_PREFIX end
realm()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 56 def realm @realm || PrometheusExporter::DEFAULT_REALM end
server_class()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 89 def server_class @server_class || PrometheusExporter::Server::WebServer end
start()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 26 def start PrometheusExporter::Metric::Base.default_prefix = prefix PrometheusExporter::Metric::Base.default_labels = label 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, auth: auth, realm: realm) server.start end
timeout()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 80 def timeout @timeout || PrometheusExporter::DEFAULT_TIMEOUT end
type_collectors()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 76 def type_collectors @type_collectors || [] end
verbose()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 84 def verbose return @verbose if defined? @verbose false end
Private Instance Methods
register_type_collectors()
click to toggle source
# File lib/prometheus_exporter/server/runner.rb, line 103 def register_type_collectors type_collectors.each do |klass| collector.register_collector klass.new STDERR.puts "Registered TypeCollector: #{klass}" if verbose end end