Class: NurseAndrea::Configuration
- Inherits:
-
Object
- Object
- NurseAndrea::Configuration
- Defined in:
- lib/nurse_andrea/configuration.rb
Constant Summary collapse
- LOG_LEVELS =
{ debug: 0, info: 1, warn: 2, error: 3, fatal: 4 }.freeze
- DEFAULT_HOST =
"https://nurseandrea.io"
Instance Attribute Summary collapse
-
#api_key ⇒ Object
(also: #token)
Returns the value of attribute api_key.
-
#backfill_hours ⇒ Object
Returns the value of attribute backfill_hours.
-
#batch_size ⇒ Object
Returns the value of attribute batch_size.
-
#debug ⇒ Object
Returns the value of attribute debug.
-
#enabled ⇒ Object
Returns the value of attribute enabled.
-
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
-
#host ⇒ Object
Returns the value of attribute host.
-
#log_file_path ⇒ Object
Returns the value of attribute log_file_path.
-
#log_level ⇒ Object
Returns the value of attribute log_level.
-
#service_name ⇒ Object
Returns the value of attribute service_name.
-
#timeout ⇒ Object
Returns the value of attribute timeout.
Instance Method Summary collapse
- #enabled? ⇒ Boolean
- #handshake_url ⇒ Object
-
#ingest_url ⇒ Object
All endpoint URLs derived from host.
-
#initialize ⇒ Configuration
constructor
A new instance of Configuration.
- #metrics_url ⇒ Object
- #min_log_level_int ⇒ Object
- #traces_url ⇒ Object
- #valid? ⇒ Boolean
- #validate! ⇒ Object
Constructor Details
#initialize ⇒ Configuration
Returns a new instance of Configuration.
10 11 12 13 14 15 16 17 18 19 20 21 |
# File 'lib/nurse_andrea/configuration.rb', line 10 def initialize @host = DEFAULT_HOST @timeout = 5 @log_level = :debug @batch_size = 100 @flush_interval = 10 @backfill_hours = 24 @log_file_path = nil @enabled = true @debug = false @service_name = default_service_name end |
Instance Attribute Details
#api_key ⇒ Object Also known as: token
Returns the value of attribute api_key.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def api_key @api_key end |
#backfill_hours ⇒ Object
Returns the value of attribute backfill_hours.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def backfill_hours @backfill_hours end |
#batch_size ⇒ Object
Returns the value of attribute batch_size.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def batch_size @batch_size end |
#debug ⇒ Object
Returns the value of attribute debug.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def debug @debug end |
#enabled ⇒ Object
Returns the value of attribute enabled.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def enabled @enabled end |
#flush_interval ⇒ Object
Returns the value of attribute flush_interval.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def flush_interval @flush_interval end |
#host ⇒ Object
Returns the value of attribute host.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def host @host end |
#log_file_path ⇒ Object
Returns the value of attribute log_file_path.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def log_file_path @log_file_path end |
#log_level ⇒ Object
Returns the value of attribute log_level.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def log_level @log_level end |
#service_name ⇒ Object
Returns the value of attribute service_name.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def service_name @service_name end |
#timeout ⇒ Object
Returns the value of attribute timeout.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def timeout @timeout end |
Instance Method Details
#enabled? ⇒ Boolean
32 33 34 |
# File 'lib/nurse_andrea/configuration.rb', line 32 def enabled? @enabled end |
#handshake_url ⇒ Object
30 |
# File 'lib/nurse_andrea/configuration.rb', line 30 def handshake_url = "#{normalised_host}/api/v1/handshake" |
#ingest_url ⇒ Object
All endpoint URLs derived from host
27 |
# File 'lib/nurse_andrea/configuration.rb', line 27 def ingest_url = "#{normalised_host}/api/v1/ingest" |
#metrics_url ⇒ Object
28 |
# File 'lib/nurse_andrea/configuration.rb', line 28 def metrics_url = "#{normalised_host}/api/v1/metrics" |
#min_log_level_int ⇒ Object
36 37 38 |
# File 'lib/nurse_andrea/configuration.rb', line 36 def min_log_level_int LOG_LEVELS.fetch(log_level.to_sym, 0) end |
#traces_url ⇒ Object
29 |
# File 'lib/nurse_andrea/configuration.rb', line 29 def traces_url = "#{normalised_host}/api/v1/traces" |
#valid? ⇒ Boolean
40 41 42 |
# File 'lib/nurse_andrea/configuration.rb', line 40 def valid? !api_key.nil? && !api_key.to_s.strip.empty? && !host.nil? end |
#validate! ⇒ Object
44 45 46 47 48 49 50 51 52 |
# File 'lib/nurse_andrea/configuration.rb', line 44 def validate! unless valid? raise NurseAndrea::ConfigurationError, "[NurseAndrea] Configuration invalid. " \ "Set NURSE_ANDREA_TOKEN and NURSE_ANDREA_HOST, then call " \ "NurseAndrea.configure in config/initializers/nurse_andrea.rb" end self end |