Module: Gruf::Lightstep::Configuration
- Included in:
- Gruf::Lightstep
- Defined in:
- lib/gruf/lightstep/configuration.rb
Overview
General configuration for lightstep integration
Constant Summary collapse
- VALID_CONFIG_KEYS =
{ default_error_code: GRPC::Core::StatusCodes::INTERNAL }.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.
-
#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
34 35 36 |
# File 'lib/gruf/lightstep/configuration.rb', line 34 def self.extended(base) base.reset end |
Instance Method Details
#configure {|_self| ... } ⇒ Bigcommerce::Instrumentation::Configuration
Yield self for ruby-style initialization
44 45 46 47 48 |
# File 'lib/gruf/lightstep/configuration.rb', line 44 def configure reset unless @configured yield self @configured = true end |
#environment ⇒ Object
Automatically determine environment
75 76 77 78 79 80 81 |
# File 'lib/gruf/lightstep/configuration.rb', line 75 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
55 56 57 58 59 60 61 |
# File 'lib/gruf/lightstep/configuration.rb', line 55 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
66 67 68 69 70 |
# File 'lib/gruf/lightstep/configuration.rb', line 66 def reset VALID_CONFIG_KEYS.each do |k, v| send("#{k}=".to_sym, v) end end |