module Gruf::Prometheus::Configuration
General configuration for gruf prometheus integration
Constants
- VALID_CONFIG_KEYS
Public Class Methods
extended(base)
click to toggle source
Whenever this is extended into a class, setup the defaults
# File lib/gruf/prometheus/configuration.rb, line 39 def self.extended(base) base.reset end
Public Instance Methods
configure() { |self| ... }
click to toggle source
Yield self for ruby-style initialization
@yields [Gruf::Prometheus::Configuration] @return [Gruf::Prometheus::Configuration]
# File lib/gruf/prometheus/configuration.rb, line 49 def configure reset unless @configured yield self @configured = true self end
environment()
click to toggle source
Automatically determine environment
@return [String] The current Ruby environment
# File lib/gruf/prometheus/configuration.rb, line 88 def environment if defined?(Rails) Rails.env.to_s else (ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development').to_s end end
options()
click to toggle source
Return the current configuration options as a Hash
@return [Hash]
# File lib/gruf/prometheus/configuration.rb, line 61 def options opts = {} VALID_CONFIG_KEYS.each_key do |k| opts.merge!(k => send(k)) end opts end
reset()
click to toggle source
Set the default configuration onto the extended class
# File lib/gruf/prometheus/configuration.rb, line 72 def reset VALID_CONFIG_KEYS.each do |k, v| send("#{k}=".to_sym, v) end self.process_label = ENV.fetch('PROMETHEUS_PROCESS_LABEL', 'grpc').to_s self.process_name = ENV.fetch('PROMETHEUS_PROCESS_NAME', 'grpc').to_s self.collection_frequency = ENV.fetch('PROMETHEUS_COLLECTION_FREQUENCY', 30).to_i self.server_measure_latency = ENV.fetch('PROMETHEUS_SERVER_MEASURE_LATENCY', 0).to_i.positive? self.client_measure_latency = ENV.fetch('PROMETHEUS_CLIENT_MEASURE_LATENCY', 0).to_i.positive? end