module Bigcommerce::Lightstep::Configuration

General configuration for lightstep 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/bigcommerce/lightstep/configuration.rb, line 57
def self.extended(base)
  base.reset
end

Public Instance Methods

configure() { |self| ... } click to toggle source

Yield self for ruby-style initialization

@yields [Bigcommerce::Instrumentation::Configuration] @return [Bigcommerce::Instrumentation::Configuration]

# File lib/bigcommerce/lightstep/configuration.rb, line 67
def configure
  reset unless @configured
  yield self
  @configured = true
end
configured?() click to toggle source

@return [Boolean]

# File lib/bigcommerce/lightstep/configuration.rb, line 76
def configured?
  @configured
end
environment() click to toggle source

Automatically determine environment

@return [String]

# File lib/bigcommerce/lightstep/configuration.rb, line 113
def environment
  if defined?(Rails)
    Rails.env
  else
    env['RACK_ENV'] || env['RAILS_ENV'] || 'development'
  end
end
options() click to toggle source

Return the current configuration options as a Hash

@return [Hash]

# File lib/bigcommerce/lightstep/configuration.rb, line 85
def options
  opts = {}
  VALID_CONFIG_KEYS.each_key do |k|
    opts.merge!(k => send(k))
  end
  opts
end
release() click to toggle source

@return [String]

# File lib/bigcommerce/lightstep/configuration.rb, line 124
def release
  unless @release
    app_name = env.fetch('LIGHTSTEP_APP_NAME', env.fetch('NOMAD_JOB_NAME', '')).to_s
    sha = env.fetch('LIGHTSTEP_RELEASE_SHA', env.fetch('NOMAD_META_RELEASE_SHA', '')).to_s
    default_release = app_name.empty? && sha.empty? ? '' : "#{app_name}@#{sha}"
    @release = env.fetch('LIGHTSTEP_RELEASE', default_release).to_s
  end
  @release
end
reset() click to toggle source

Set the default configuration onto the extended class

# File lib/bigcommerce/lightstep/configuration.rb, line 96
def reset
  VALID_CONFIG_KEYS.each do |k, v|
    send("#{k}=".to_sym, v)
  end

  default_logger = ::Logger.new($stdout)
  default_logger.level = ::Logger::INFO
  self.logger = defined?(Rails) ? Rails.logger : default_logger

  self.interceptors = ::Bigcommerce::Lightstep::Interceptors::Registry.new
end

Private Instance Methods

env() click to toggle source
# File lib/bigcommerce/lightstep/configuration.rb, line 136
def env
  ENV
end