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

Instance Method Summary collapse

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

Yields:

  • (_self)

Yield Parameters:

Returns:

  • (Bigcommerce::Instrumentation::Configuration)


44
45
46
47
48
# File 'lib/gruf/lightstep/configuration.rb', line 44

def configure
  reset unless @configured
  yield self
  @configured = true
end

#environmentObject

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

#optionsHash

Return the current configuration options as a Hash

Returns:

  • (Hash)


55
56
57
58
59
60
61
# File 'lib/gruf/lightstep/configuration.rb', line 55

def options
  opts = {}
  VALID_CONFIG_KEYS.each_key do |k|
    opts.merge!(k => send(k))
  end
  opts
end

#resetObject

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