lib/instana/config.rb in instana-1.195.4 vs lib/instana/config.rb in instana-1.197.0.pre1

- old
+ new

@@ -1,30 +1,25 @@ # (c) Copyright IBM Corp. 2021 # (c) Copyright Instana Inc. 2016 module Instana class Config - - def initialize + def initialize(logger: ::Instana.logger, agent_host: ENV['INSTANA_AGENT_HOST'], agent_port: ENV['INSTANA_AGENT_PORT']) @config = {} - if ENV.key?('INSTANA_AGENT_HOST') - ::Instana.logger.debug "Using custom agent host location specified in INSTANA_AGENT_HOST (#{ENV['INSTANA_AGENT_HOST']})" - @config[:agent_host] = ENV['INSTANA_AGENT_HOST'] + if agent_host + logger.debug "Using custom agent host location specified in INSTANA_AGENT_HOST (#{ENV['INSTANA_AGENT_HOST']})" + @config[:agent_host] = agent_host else @config[:agent_host] = '127.0.0.1' end - if ENV.key?('INSTANA_AGENT_PORT') - ::Instana.logger.debug "Using custom agent port specified in INSTANA_AGENT_PORT (#{ENV['INSTANA_AGENT_PORT']})" - @config[:agent_port] = ENV['INSTANA_AGENT_PORT'] + if agent_port + logger.debug "Using custom agent port specified in INSTANA_AGENT_PORT (#{ENV['INSTANA_AGENT_PORT']})" + @config[:agent_port] = agent_port else @config[:agent_port] = 42699 end - # This option has been DEPRECATED. Use the INSTANA_DISABLE environment variable instead. - # https://docs.instana.io/ecosystem/ruby/configuration/ - @config[:enabled] = true - # Enable/disable metrics globally or individually (default: all enabled) @config[:metrics] = { :enabled => true } @config[:metrics][:gc] = { :enabled => true } @config[:metrics][:memory] = { :enabled => true } @config[:metrics][:thread] = { :enabled => true } @@ -78,18 +73,9 @@ @config[key.to_sym] end def []=(key, value) @config[key.to_sym] = value - - if key == :enabled - # Configuring global enable/disable flag, then set the - # appropriate children flags. - @config[:metrics][:enabled] = value - @config[:tracing][:enabled] = value - - ::Instana.logger.warn "::Instana.config[:enabled] has been deprecated. Set INSTANA_DISABLE environment variable to any value instead." - end end end end ::Instana.config = ::Instana::Config.new