class TCellAgent::Configuration

Attributes

api_key[RW]

Common config returned by libtcellagent

app_id[RW]

Common config returned by libtcellagent

disable_all[RW]

internal Ruby configurations

disabled_instrumentation[RW]

Common config returned by libtcellagent

enable_intercept_requests[RW]

Common config returned by libtcellagent

enable_policy_polling[RW]

Ruby config returned by libtcellagent

enabled[RW]

Common config returned by libtcellagent

fetch_policies_from_tcell[RW]

Common config returned by libtcellagent

hmac_key[RW]

Common config returned by libtcellagent

host_identifier[RW]

Common config returned by libtcellagent

instrument[RW]

Common config returned by libtcellagent

log_dir[RW]

Common config returned by libtcellagent

logging_options[RW]

Common config returned by libtcellagent

password_hmac_key[RW]

Common config returned by libtcellagent

reverse_proxy[RW]

Common config returned by libtcellagent

reverse_proxy_ip_address_header[RW]

Common config returned by libtcellagent

tcell_api_url[RW]

Common config returned by libtcellagent

Public Class Methods

new() click to toggle source
# File lib/tcell_agent/configuration.rb, line 59
def initialize
  # ruby agent defaults
  @disable_all = false
  @logging_options = {}

  check_for_disabled_instrumentation(get_config_file_name)
end

Public Instance Methods

check_for_disabled_instrumentation(filename) click to toggle source
# File lib/tcell_agent/configuration.rb, line 78
def check_for_disabled_instrumentation(filename)
  return unless File.file?(filename)

  begin
    config = JSON.parse(File.open(filename).read)

    if config['version'] == 1
      app_data = config['applications'][0]
      @disable_all = to_bool(app_data.fetch('disable_all', @disable_all))
    end
  rescue StandardError
    # do nothing
  end
end
get_config_file_name() click to toggle source
# File lib/tcell_agent/configuration.rb, line 74
def get_config_file_name
  ENV['TCELL_AGENT_CONFIG'] || File.join(Dir.getwd, '/config/tcell_agent.config')
end
get_config_file_path() click to toggle source
# File lib/tcell_agent/configuration.rb, line 67
def get_config_file_path
  return nil unless ENV['TCELL_AGENT_HOME']
  return nil if ENV['TCELL_AGENT_CONFIG']

  File.join(Dir.getwd, '/config/tcell_agent.config')
end
populate_configuration(native_agent_config_response) click to toggle source
# File lib/tcell_agent/configuration.rb, line 97
def populate_configuration(native_agent_config_response)
  # config
  @enabled = native_agent_config_response['enabled']
  @disabled_instrumentation = Set.new(native_agent_config_response['disabled_instrumentation'])
  @fetch_policies_from_tcell = native_agent_config_response['update_policy']
  @instrument = native_agent_config_response['instrument']

  # app config
  apps = native_agent_config_response['applications'] ? native_agent_config_response['applications']['first'] : {}
  @app_id = apps['app_id']
  @api_key = apps['api_key']
  @hmac_key = apps['hmac_key']
  @password_hmac_key = apps['password_hmac_key']

  # proxy config
  @reverse_proxy = apps['reverse_proxy']
  @reverse_proxy_ip_address_header = apps['reverse_proxy_ip_address_header']

  # endpoint config
  endpoint = native_agent_config_response['endpoint_config'] || {}
  @tcell_api_url = endpoint['api_url']

  # ruby config
  ruby_config = native_agent_config_response['ruby_config'] || {}
  @enable_policy_polling = ruby_config['enable_policy_polling']
  @enable_intercept_requests = !@disabled_instrumentation.include?('intercept_requests')
end
should_instrument?(func = nil) click to toggle source
# File lib/tcell_agent/configuration.rb, line 48
def should_instrument?(func = nil)
  return false unless @enabled && @instrument # never instrument if disabled
  return true if func.nil?                    # always instrument if enabled and nothing given

  !@disabled_instrumentation.include?(func)
end
should_intercept_requests?() click to toggle source
# File lib/tcell_agent/configuration.rb, line 55
def should_intercept_requests?
  @enabled && @enable_intercept_requests
end
should_start_policy_poll?() click to toggle source
# File lib/tcell_agent/configuration.rb, line 44
def should_start_policy_poll?
  @enabled && @enable_policy_polling && @fetch_policies_from_tcell # fetch_policies_from_tcel = legacy
end
to_bool(var) click to toggle source
# File lib/tcell_agent/configuration.rb, line 93
def to_bool(var)
  { 'true' => true, 'false' => false }[var.to_s.downcase]
end