Class: TCellAgent::Configuration
- Inherits:
-
Object
- Object
- TCellAgent::Configuration
- Defined in:
- lib/tcell_agent/configuration.rb
Direct Known Subclasses
Instance Attribute Summary collapse
-
#api_key ⇒ Object
Common config returned by libtcellagent.
-
#app_id ⇒ Object
Common config returned by libtcellagent.
-
#disable_all ⇒ Object
internal Ruby configurations.
-
#disabled_instrumentation ⇒ Object
Common config returned by libtcellagent.
-
#enable_intercept_requests ⇒ Object
Common config returned by libtcellagent.
-
#enable_policy_polling ⇒ Object
Ruby config returned by libtcellagent.
-
#enabled ⇒ Object
Common config returned by libtcellagent.
-
#fetch_policies_from_tcell ⇒ Object
Common config returned by libtcellagent.
-
#hmac_key ⇒ Object
Common config returned by libtcellagent.
-
#host_identifier ⇒ Object
Common config returned by libtcellagent.
-
#instrument ⇒ Object
Common config returned by libtcellagent.
-
#log_dir ⇒ Object
Common config returned by libtcellagent.
-
#logging_options ⇒ Object
Common config returned by libtcellagent.
-
#password_hmac_key ⇒ Object
Common config returned by libtcellagent.
-
#reverse_proxy ⇒ Object
Common config returned by libtcellagent.
-
#reverse_proxy_ip_address_header ⇒ Object
Common config returned by libtcellagent.
-
#tcell_api_url ⇒ Object
Common config returned by libtcellagent.
Instance Method Summary collapse
- #check_for_disabled_instrumentation(filename) ⇒ Object
- #get_config_file_name ⇒ Object
- #get_config_file_path ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #populate_configuration(native_agent_config_response) ⇒ Object
- #should_instrument?(func = nil) ⇒ Boolean
- #should_intercept_requests? ⇒ Boolean
- #should_start_policy_poll? ⇒ Boolean
- #to_bool(var) ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
59 60 61 62 63 64 65 |
# 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 |
Instance Attribute Details
#api_key ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def api_key @api_key end |
#app_id ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def app_id @app_id end |
#disable_all ⇒ Object
internal Ruby configurations
32 33 34 |
# File 'lib/tcell_agent/configuration.rb', line 32 def disable_all @disable_all end |
#disabled_instrumentation ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def disabled_instrumentation @disabled_instrumentation end |
#enable_intercept_requests ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def enable_intercept_requests @enable_intercept_requests end |
#enable_policy_polling ⇒ Object
Ruby config returned by libtcellagent
42 43 44 |
# File 'lib/tcell_agent/configuration.rb', line 42 def enable_policy_polling @enable_policy_polling end |
#enabled ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def enabled @enabled end |
#fetch_policies_from_tcell ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def fetch_policies_from_tcell @fetch_policies_from_tcell end |
#hmac_key ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def hmac_key @hmac_key end |
#host_identifier ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def host_identifier @host_identifier end |
#instrument ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def instrument @instrument end |
#log_dir ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def log_dir @log_dir end |
#logging_options ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def @logging_options end |
#password_hmac_key ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def password_hmac_key @password_hmac_key end |
#reverse_proxy ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def reverse_proxy @reverse_proxy end |
#reverse_proxy_ip_address_header ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def reverse_proxy_ip_address_header @reverse_proxy_ip_address_header end |
#tcell_api_url ⇒ Object
Common config returned by libtcellagent
35 36 37 |
# File 'lib/tcell_agent/configuration.rb', line 35 def tcell_api_url @tcell_api_url end |
Instance Method Details
#check_for_disabled_instrumentation(filename) ⇒ Object
78 79 80 81 82 83 84 85 86 87 88 89 90 91 |
# 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 ⇒ Object
74 75 76 |
# 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 ⇒ Object
67 68 69 70 71 72 |
# 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) ⇒ Object
97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 |
# 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) ⇒ Boolean
48 49 50 51 52 53 |
# 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? ⇒ Boolean
55 56 57 |
# File 'lib/tcell_agent/configuration.rb', line 55 def should_intercept_requests? @enabled && @enable_intercept_requests end |
#should_start_policy_poll? ⇒ Boolean
44 45 46 |
# 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) ⇒ Object
93 94 95 |
# File 'lib/tcell_agent/configuration.rb', line 93 def to_bool(var) { 'true' => true, 'false' => false }[var.to_s.downcase] end |