Class: Stackify::Configuration
- Defined in:
- lib/stackify/utils/configuration.rb
Instance Attribute Summary collapse
-
#agent_log_url ⇒ Object
readonly
Returns the value of attribute agent_log_url.
-
#api_enabled ⇒ Object
Returns the value of attribute api_enabled.
-
#api_key ⇒ Object
Returns the value of attribute api_key.
-
#app_location ⇒ Object
Returns the value of attribute app_location.
-
#app_name ⇒ Object
Returns the value of attribute app_name.
-
#base_api_url ⇒ Object
Returns the value of attribute base_api_url.
-
#buffered_logger ⇒ Object
Returns the value of attribute buffered_logger.
-
#env ⇒ Object
Returns the value of attribute env.
-
#errors ⇒ Object
Returns the value of attribute errors.
-
#flood_limit ⇒ Object
readonly
Returns the value of attribute flood_limit.
-
#http_endpoint ⇒ Object
Returns the value of attribute http_endpoint.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#logger ⇒ Object
Returns the value of attribute logger.
-
#mode ⇒ Object
Returns the value of attribute mode.
-
#proxy ⇒ Object
Returns the value of attribute proxy.
-
#queue_max_size ⇒ Object
readonly
Returns the value of attribute queue_max_size.
-
#rum_key ⇒ Object
Returns the value of attribute rum_key.
-
#rum_script_url ⇒ Object
Returns the value of attribute rum_script_url.
-
#send_interval ⇒ Object
readonly
Returns the value of attribute send_interval.
-
#stdout_output ⇒ Object
Returns the value of attribute stdout_output.
-
#transport ⇒ Object
Returns the value of attribute transport.
-
#unix_socket_path ⇒ Object
readonly
Returns the value of attribute unix_socket_path.
Instance Method Summary collapse
- #get_env(env_key, default) ⇒ Object
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #is_valid? ⇒ Boolean
- #validate_transport_type ⇒ Object
Constructor Details
#initialize ⇒ Configuration
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_url ⇒ Object (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_enabled ⇒ Object
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_key ⇒ Object
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_location ⇒ Object
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_name ⇒ Object
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_url ⇒ Object
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_logger ⇒ Object
Returns the value of attribute buffered_logger.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def buffered_logger @buffered_logger end |
#env ⇒ Object
Returns the value of attribute env.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def env @env end |
#errors ⇒ Object
Returns the value of attribute errors.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def errors @errors end |
#flood_limit ⇒ Object (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_endpoint ⇒ Object
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_level ⇒ Object
Returns the value of attribute log_level.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def log_level @log_level end |
#logger ⇒ Object
Returns the value of attribute logger.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def logger @logger end |
#mode ⇒ Object
Returns the value of attribute mode.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def mode @mode end |
#proxy ⇒ Object
Returns the value of attribute proxy.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def proxy @proxy end |
#queue_max_size ⇒ Object (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_key ⇒ Object
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_url ⇒ Object
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_interval ⇒ Object (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_output ⇒ Object
Returns the value of attribute stdout_output.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def stdout_output @stdout_output end |
#transport ⇒ Object
Returns the value of attribute transport.
5 6 7 |
# File 'lib/stackify/utils/configuration.rb', line 5 def transport @transport end |
#unix_socket_path ⇒ Object (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
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_type ⇒ Object
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 |