Module: Bigcommerce::Prometheus::Configuration
- Included in:
- Bigcommerce::Prometheus
- Defined in:
- lib/bigcommerce/prometheus/configuration.rb
Overview
General configuration for prometheus integration
Constant Summary collapse
- VALID_CONFIG_KEYS =
{ logger: nil, enabled: ENV.fetch('PROMETHEUS_ENABLED', 1).to_i.positive?, # Client configuration client_custom_labels: nil, client_max_queue_size: ENV.fetch('PROMETHEUS_CLIENT_MAX_QUEUE_SIZE', 10_000).to_i, client_thread_sleep: ENV.fetch('PROMETHEUS_CLIENT_THREAD_SLEEP', 0.5).to_f, # Integration configuration puma_collection_frequency: ENV.fetch('PROMETHEUS_PUMA_COLLECTION_FREQUENCY', 30).to_i, puma_process_label: ENV.fetch('PROMETHEUS_PUMA_PROCESS_LABEL', 'web').to_s, resque_collection_frequency: ENV.fetch('PROMETHEUS_RESQUE_COLLECTION_FREQUENCY', 30).to_i, resque_process_label: ENV.fetch('PROMETHEUS_REQUEST_PROCESS_LABEL', 'resque').to_s, # Server configuration not_found_body: ENV.fetch('PROMETHEUS_SERVER_NOT_FOUND_BODY', 'Not Found! The Prometheus Ruby Exporter only listens on /metrics and /send-metrics').to_s, server_host: ENV.fetch('PROMETHEUS_SERVER_HOST', '0.0.0.0').to_s, server_port: ENV.fetch('PROMETHEUS_SERVER_PORT', PrometheusExporter::DEFAULT_PORT).to_i, server_timeout: ENV.fetch('PROMETHEUS_DEFAULT_TIMEOUT', PrometheusExporter::DEFAULT_TIMEOUT).to_i, server_prefix: ENV.fetch('PROMETHEUS_DEFAULT_PREFIX', PrometheusExporter::DEFAULT_PREFIX).to_s, server_thread_pool_size: ENV.fetch('PROMETHEUS_SERVER_THREAD_POOL_SIZE', 3).to_i, # Custom collector configuration collector_collection_frequency: ENV.fetch('PROMETHEUS_DEFAULT_COLLECTOR_COLLECTION_FREQUENCY_SEC', 15).to_i, hutch_collectors: [], hutch_type_collectors: [], resque_collectors: [], resque_type_collectors: [], web_collectors: [], web_type_collectors: [], # Additional configuration railtie_disabled: ENV.fetch('PROMETHEUS_DISABLE_RAILTIE', 0).to_i.positive? }.freeze
Class Method Summary collapse
-
.extended(base) ⇒ Object
Whenever this is extended into a class, setup the defaults.
Instance Method Summary collapse
-
#configure {|_self| ... } ⇒ Bigcommerce::Prometheus::Configuration
Yield self for ruby-style initialization.
-
#options ⇒ Hash
Return the current configuration options as a Hash.
- #process_name ⇒ String
-
#reset ⇒ Object
Set the default configuration onto the extended class.
Class Method Details
.extended(base) ⇒ Object
Whenever this is extended into a class, setup the defaults
65 66 67 68 69 70 71 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 65 def self.extended(base) if defined?(Rails) Bigcommerce::Prometheus::Integrations::Railtie.config.before_initialize { base.reset } else base.reset end end |
Instance Method Details
#configure {|_self| ... } ⇒ Bigcommerce::Prometheus::Configuration
Yield self for ruby-style initialization
79 80 81 82 83 84 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 79 def configure reset unless @configured yield self @configured = true self end |
#options ⇒ Hash
Return the current configuration options as a Hash
91 92 93 94 95 96 97 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 91 def opts = {} VALID_CONFIG_KEYS.each_key do |k| opts.merge!(k => send(k)) end opts end |
#process_name ⇒ String
113 114 115 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 113 def process_name @process_name ||= ENV.fetch('PROCESS', 'unknown') end |
#reset ⇒ Object
Set the default configuration onto the extended class
102 103 104 105 106 107 108 109 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 102 def reset VALID_CONFIG_KEYS.each do |k, v| send("#{k}=".to_sym, v) end determine_logger self.web_type_collectors = [] end |