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.
-
#auto_connect ⇒ Object
Returns the value of attribute auto_connect.
-
#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.
-
#hook_interval_ms ⇒ Object
Returns the value of attribute hook_interval_ms.
-
#hooks_cache ⇒ Object
Returns the value of attribute hooks_cache.
-
#hooks_database ⇒ Object
Returns the value of attribute hooks_database.
-
#hooks_enabled ⇒ Object
Returns the value of attribute hooks_enabled.
-
#hooks_jobs ⇒ Object
Returns the value of attribute hooks_jobs.
-
#hooks_mailer ⇒ Object
Returns the value of attribute hooks_mailer.
-
#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.
-
#platform_detection ⇒ Object
Returns the value of attribute platform_detection.
-
#sdk_language ⇒ Object
Returns the value of attribute sdk_language.
-
#sdk_version ⇒ Object
Returns the value of attribute sdk_version.
-
#service_discovery ⇒ Object
Returns the value of attribute service_discovery.
-
#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.
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/nurse_andrea/configuration.rb', line 14 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 @sdk_version = NurseAndrea::VERSION @sdk_language = "ruby" @hooks_enabled = true @hooks_database = true @hooks_cache = true @hooks_jobs = true @hooks_mailer = true @hook_interval_ms = 10_000 @platform_detection = true @service_discovery = true @auto_connect = false 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 |
#auto_connect ⇒ Object
Returns the value of attribute auto_connect.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def auto_connect @auto_connect 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 |
#hook_interval_ms ⇒ Object
Returns the value of attribute hook_interval_ms.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def hook_interval_ms @hook_interval_ms end |
#hooks_cache ⇒ Object
Returns the value of attribute hooks_cache.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def hooks_cache @hooks_cache end |
#hooks_database ⇒ Object
Returns the value of attribute hooks_database.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def hooks_database @hooks_database end |
#hooks_enabled ⇒ Object
Returns the value of attribute hooks_enabled.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def hooks_enabled @hooks_enabled end |
#hooks_jobs ⇒ Object
Returns the value of attribute hooks_jobs.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def hooks_jobs @hooks_jobs end |
#hooks_mailer ⇒ Object
Returns the value of attribute hooks_mailer.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def hooks_mailer @hooks_mailer 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 |
#platform_detection ⇒ Object
Returns the value of attribute platform_detection.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def platform_detection @platform_detection end |
#sdk_language ⇒ Object
Returns the value of attribute sdk_language.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def sdk_language @sdk_language end |
#sdk_version ⇒ Object
Returns the value of attribute sdk_version.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def sdk_version @sdk_version end |
#service_discovery ⇒ Object
Returns the value of attribute service_discovery.
3 4 5 |
# File 'lib/nurse_andrea/configuration.rb', line 3 def service_discovery @service_discovery 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
47 48 49 |
# File 'lib/nurse_andrea/configuration.rb', line 47 def enabled? @enabled end |
#handshake_url ⇒ Object
45 |
# File 'lib/nurse_andrea/configuration.rb', line 45 def handshake_url = "#{normalised_host}/api/v1/handshake" |
#ingest_url ⇒ Object
All endpoint URLs derived from host
42 |
# File 'lib/nurse_andrea/configuration.rb', line 42 def ingest_url = "#{normalised_host}/api/v1/ingest" |
#metrics_url ⇒ Object
43 |
# File 'lib/nurse_andrea/configuration.rb', line 43 def metrics_url = "#{normalised_host}/api/v1/metrics" |
#min_log_level_int ⇒ Object
51 52 53 |
# File 'lib/nurse_andrea/configuration.rb', line 51 def min_log_level_int LOG_LEVELS.fetch(log_level.to_sym, 0) end |
#traces_url ⇒ Object
44 |
# File 'lib/nurse_andrea/configuration.rb', line 44 def traces_url = "#{normalised_host}/api/v1/traces" |
#valid? ⇒ Boolean
55 56 57 |
# File 'lib/nurse_andrea/configuration.rb', line 55 def valid? !api_key.nil? && !api_key.to_s.strip.empty? && !host.nil? end |
#validate! ⇒ Object
59 60 61 62 63 64 65 66 67 |
# File 'lib/nurse_andrea/configuration.rb', line 59 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 |