Class: Stackify::Configuration

Inherits:
Object
  • Object
show all
Defined in:
lib/stackify/utils/configuration.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
# File 'lib/stackify/utils/configuration.rb', line 11

def initialize
  @base_api_url = 'https://api.stackify.com'
  @errors = []
  @app_name = ''
  @api_key = ''
  @transport = get_env 'STACKIFY_TRANSPORT', 'default'
  @env = :production
  @flood_limit = 100
  @queue_max_size = 10000
  @send_interval = 60
  @api_enabled = true
  @log_level = :info
  @mode = MODES[:both]
  @logger = Logger.new(STDOUT)
  @logger.level = Logger::UNKNOWN
  @agent_log_url = '/log'
  @unix_socket_path = '/usr/local/stackify/stackify.sock'
  @http_endpoint = get_env 'STACKIFY_TRANSPORT_HTTP_ENDPOINT', 'https://localhost:10601'
  @stdout_output = false
  @buffered_logger = false
  @default_rum_script_url = 'https://stckjs.stackify.com/stckjs.js'
  @default_rum_key = ''

  self.rum_key = get_env 'RETRACE_RUM_KEY', @default_rum_key
  self.rum_script_url = get_env 'RETRACE_RUM_SCRIPT_URL', @default_rum_script_url
end

Instance Attribute Details

#agent_log_urlObject (readonly)

Returns the value of attribute agent_log_url.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def agent_log_url
  @agent_log_url
end

#api_enabledObject

Returns the value of attribute api_enabled.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def api_enabled
  @api_enabled
end

#api_keyObject

Returns the value of attribute api_key.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def api_key
  @api_key
end

#app_locationObject

Returns the value of attribute app_location.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def app_location
  @app_location
end

#app_nameObject

Returns the value of attribute app_name.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def app_name
  @app_name
end

#base_api_urlObject

Returns the value of attribute base_api_url.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def base_api_url
  @base_api_url
end

#buffered_loggerObject

Returns the value of attribute buffered_logger.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def buffered_logger
  @buffered_logger
end

#envObject

Returns the value of attribute env.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def env
  @env
end

#errorsObject

Returns the value of attribute errors.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def errors
  @errors
end

#flood_limitObject (readonly)

Returns the value of attribute flood_limit.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def flood_limit
  @flood_limit
end

#http_endpointObject

Returns the value of attribute http_endpoint.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def http_endpoint
  @http_endpoint
end

#log_levelObject

Returns the value of attribute log_level.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def log_level
  @log_level
end

#loggerObject

Returns the value of attribute logger.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def logger
  @logger
end

#modeObject

Returns the value of attribute mode.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def mode
  @mode
end

#proxyObject

Returns the value of attribute proxy.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def proxy
  @proxy
end

#queue_max_sizeObject (readonly)

Returns the value of attribute queue_max_size.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def queue_max_size
  @queue_max_size
end

#rum_keyObject

Returns the value of attribute rum_key.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def rum_key
  @rum_key
end

#rum_script_urlObject

Returns the value of attribute rum_script_url.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def rum_script_url
  @rum_script_url
end

#send_intervalObject (readonly)

Returns the value of attribute send_interval.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def send_interval
  @send_interval
end

#stdout_outputObject

Returns the value of attribute stdout_output.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def stdout_output
  @stdout_output
end

#transportObject

Returns the value of attribute transport.



5
6
7
# File 'lib/stackify/utils/configuration.rb', line 5

def transport
  @transport
end

#unix_socket_pathObject (readonly)

Returns the value of attribute unix_socket_path.



8
9
10
# File 'lib/stackify/utils/configuration.rb', line 8

def unix_socket_path
  @unix_socket_path
end

Instance Method Details

#get_env(env_key, default) ⇒ Object



38
39
40
41
42
43
44
# File 'lib/stackify/utils/configuration.rb', line 38

def get_env env_key, default
  value = default
  if ENV.keys.include? env_key
    value = ENV[env_key]
  end
  return value
end

#is_valid?Boolean

Returns:

  • (Boolean)


46
47
48
49
50
51
52
53
54
# File 'lib/stackify/utils/configuration.rb', line 46

def is_valid?
  case Stackify.configuration.transport
  when Stackify::DEFAULT
    validate_default_transport
  when Stackify::UNIX_SOCKET, Stackify::AGENT_HTTP
    validate_agent_transport
  end
  @errors.empty?
end

#validate_transport_typeObject



56
57
58
59
# File 'lib/stackify/utils/configuration.rb', line 56

def validate_transport_type
  return true if ['agent_socket', 'agent_http', 'default'].include? @transport
  @errors << 'Transport should be one of these values: [agent_socket, agent_http, default]. Should be a String.'
end