Class: NurseAndrea::Configuration

Inherits:
Object
  • Object
show all
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

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

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_keyObject 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_connectObject

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_hoursObject

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_sizeObject

Returns the value of attribute batch_size.



3
4
5
# File 'lib/nurse_andrea/configuration.rb', line 3

def batch_size
  @batch_size
end

#debugObject

Returns the value of attribute debug.



3
4
5
# File 'lib/nurse_andrea/configuration.rb', line 3

def debug
  @debug
end

#enabledObject

Returns the value of attribute enabled.



3
4
5
# File 'lib/nurse_andrea/configuration.rb', line 3

def enabled
  @enabled
end

#flush_intervalObject

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_msObject

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_cacheObject

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_databaseObject

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_enabledObject

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_jobsObject

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_mailerObject

Returns the value of attribute hooks_mailer.



3
4
5
# File 'lib/nurse_andrea/configuration.rb', line 3

def hooks_mailer
  @hooks_mailer
end

#hostObject

Returns the value of attribute host.



3
4
5
# File 'lib/nurse_andrea/configuration.rb', line 3

def host
  @host
end

#log_file_pathObject

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_levelObject

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_detectionObject

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_languageObject

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_versionObject

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_discoveryObject

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_nameObject

Returns the value of attribute service_name.



3
4
5
# File 'lib/nurse_andrea/configuration.rb', line 3

def service_name
  @service_name
end

#timeoutObject

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

Returns:

  • (Boolean)


47
48
49
# File 'lib/nurse_andrea/configuration.rb', line 47

def enabled?
  @enabled
end

#handshake_urlObject



45
# File 'lib/nurse_andrea/configuration.rb', line 45

def handshake_url = "#{normalised_host}/api/v1/handshake"

#ingest_urlObject

All endpoint URLs derived from host



42
# File 'lib/nurse_andrea/configuration.rb', line 42

def ingest_url    = "#{normalised_host}/api/v1/ingest"

#metrics_urlObject



43
# File 'lib/nurse_andrea/configuration.rb', line 43

def metrics_url   = "#{normalised_host}/api/v1/metrics"

#min_log_level_intObject



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_urlObject



44
# File 'lib/nurse_andrea/configuration.rb', line 44

def traces_url    = "#{normalised_host}/api/v1/traces"

#valid?Boolean

Returns:

  • (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