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, # 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: [] }.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
61 62 63 64 65 66 67 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 61 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
75 76 77 78 79 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 75 def configure reset unless @configured yield self @configured = true end |
#options ⇒ Hash
Return the current configuration options as a Hash
86 87 88 89 90 91 92 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 86 def opts = {} VALID_CONFIG_KEYS.each_key do |k| opts.merge!(k => send(k)) end opts end |
#process_name ⇒ String
108 109 110 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 108 def process_name @process_name ||= ENV.fetch('PROCESS', 'unknown') end |
#reset ⇒ Object
Set the default configuration onto the extended class
97 98 99 100 101 102 103 104 |
# File 'lib/bigcommerce/prometheus/configuration.rb', line 97 def reset VALID_CONFIG_KEYS.each do |k, v| send("#{k}=".to_sym, v) end determine_logger self.web_type_collectors = [] end |