Class: Errsight::Configuration

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

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



7
8
9
10
11
12
13
14
15
16
17
18
19
# File 'lib/errsight/configuration.rb', line 7

def initialize
  @api_key       = ENV["ERRSIGHT_API_KEY"]
  @environment   = ENV.fetch("ERRSIGHT_ENV", "production")
  @min_level     = :warning
  @host          = ENV.fetch("ERRSIGHT_HOST", "https://errsight.com")
  @timeout       = 5
  @enabled       = true
  @batch_size    = 10
  @flush_interval = 2  # seconds
  @max_queue_size = 1_000
  @logger                  = defined?(Rails) ? Rails.logger : Logger.new($stdout)
  @attach_to_rails_logger  = true
end

Instance Attribute Details

#api_keyObject

Returns the value of attribute api_key.



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

def api_key
  @api_key
end

#attach_to_rails_loggerObject

Returns the value of attribute attach_to_rails_logger.



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

def attach_to_rails_logger
  @attach_to_rails_logger
end

#batch_sizeObject

Returns the value of attribute batch_size.



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

def batch_size
  @batch_size
end

#enabledObject

Returns the value of attribute enabled.



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

def enabled
  @enabled
end

#environmentObject

Returns the value of attribute environment.



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

def environment
  @environment
end

#flush_intervalObject

Returns the value of attribute flush_interval.



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

def flush_interval
  @flush_interval
end

#hostObject

Returns the value of attribute host.



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

def host
  @host
end

#loggerObject

Returns the value of attribute logger.



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

def logger
  @logger
end

#max_queue_sizeObject

Returns the value of attribute max_queue_size.



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

def max_queue_size
  @max_queue_size
end

#min_levelObject

Returns the value of attribute min_level.



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

def min_level
  @min_level
end

#timeoutObject

Returns the value of attribute timeout.



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

def timeout
  @timeout
end

Instance Method Details

#enabled?Boolean

Returns:

  • (Boolean)


21
22
23
# File 'lib/errsight/configuration.rb', line 21

def enabled?
  @enabled && !api_key.nil? && !api_key.strip.empty?
end

#events_endpointObject



29
30
31
# File 'lib/errsight/configuration.rb', line 29

def events_endpoint
  "#{host.chomp('/')}/api/v1/events"
end

#validate!Object

Raises:



25
26
27
# File 'lib/errsight/configuration.rb', line 25

def validate!
  raise ConfigurationError, "api_key is required" if api_key.nil? || api_key.strip.empty?
end