Module: Bigcommerce::Lightstep::Configuration
- Included in:
- Bigcommerce::Lightstep
- Defined in:
- lib/bigcommerce/lightstep/configuration.rb
Overview
General configuration for lightstep integration
Constant Summary collapse
- VALID_CONFIG_KEYS =
{ component_name: '', controller_trace_prefix: 'controllers.', access_token: '', host: 'lightstep-collector.linkerd', port: 4140, ssl_verify_peer: true, open_timeout: 20, read_timeout: 20, continue_timeout: nil, keep_alive_timeout: 2, logger: nil, verbosity: 1, http1_error_code: 500, http1_error_code_minimum: 500, max_buffered_spans: 1_000, max_log_records: 1_000, max_reporting_interval_seconds: 3.0, enabled: true }.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::Instrumentation::Configuration
Yield self for ruby-style initialization.
- #configured? ⇒ Boolean
-
#environment ⇒ Object
Automatically determine environment.
-
#options ⇒ Hash
Return the current configuration options as a Hash.
-
#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
49 50 51 |
# File 'lib/bigcommerce/lightstep/configuration.rb', line 49 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Bigcommerce::Instrumentation::Configuration
Yield self for ruby-style initialization
59 60 61 62 63 |
# File 'lib/bigcommerce/lightstep/configuration.rb', line 59 def configure reset unless @configured yield self @configured = true end |
#configured? ⇒ Boolean
68 69 70 |
# File 'lib/bigcommerce/lightstep/configuration.rb', line 68 def configured? @configured end |
#environment ⇒ Object
Automatically determine environment
110 111 112 113 114 115 116 |
# File 'lib/bigcommerce/lightstep/configuration.rb', line 110 def environment if defined?(Rails) Rails.env else ENV['RACK_ENV'] || ENV['RAILS_ENV'] || 'development' end end |
#options ⇒ Hash
Return the current configuration options as a Hash
77 78 79 80 81 82 83 |
# File 'lib/bigcommerce/lightstep/configuration.rb', line 77 def opts = {} VALID_CONFIG_KEYS.each_key do |k| opts.merge!(k => send(k)) end opts end |
#reset ⇒ Object
Set the default configuration onto the extended class
88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 |
# File 'lib/bigcommerce/lightstep/configuration.rb', line 88 def reset VALID_CONFIG_KEYS.each do |k, v| send("#{k}=".to_sym, v) end self.component_name = ENV.fetch('LIGHTSTEP_COMPONENT_NAME', '') self.access_token = ENV.fetch('LIGHTSTEP_ACCESS_TOKEN', '') self.host = ENV.fetch('LIGHTSTEP_HOST', 'lightstep-collector.linkerd') self.port = ENV.fetch('LIGHTSTEP_PORT', 4140).to_i self.ssl_verify_peer = ENV.fetch('LIGHTSTEP_SSL_VERIFY_PEER', true) self.max_buffered_spans = ENV.fetch('LIGHTSTEP_MAX_BUFFERED_SPANS', 1_000).to_i self.max_log_records = ENV.fetch('LIGHTSTEP_MAX_LOG_RECORDS', 1_000).to_i self.max_reporting_interval_seconds = ENV.fetch('LIGHTSTEP_MAX_REPORTING_INTERVAL_SECONDS', 3.0).to_f self.verbosity = ENV.fetch('LIGHTSTEP_VERBOSITY', 1).to_i self.logger = defined?(Rails) ? Rails.logger : Logger.new(STDOUT) self.enabled = ENV.fetch('LIGHTSTEP_ENABLED', 1).to_i > 0 end |