Class: QueryOwl::Configuration

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

Constant Summary collapse

VALID_LOG_LEVELS =
%i[debug info warn].freeze
DEFAULT_BACKTRACE_FILTER =
->(line) { line !~ %r{/gems/|/rubygems/|/ruby/gems/|lib/query_owl/} }

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initializeConfiguration

Returns a new instance of Configuration.



24
25
26
27
28
29
30
31
32
33
34
35
36
37
# File 'lib/query_owl/configuration.rb', line 24

def initialize
  @enabled                 = Rails.env.development?
  @slow_query_threshold_ms = 100
  @n_plus_one_threshold    = 2
  @log_level               = :warn
  @backtrace_lines         = 5
  @backtrace_filter        = DEFAULT_BACKTRACE_FILTER
  @raise_on_n_plus_one     = false
  @event_store_size        = 100
  @dashboard_enabled       = Rails.env.development?
  @log_file                = nil
  @ignore_paths            = []
  @ignore_controllers      = []
end

Instance Attribute Details

#backtrace_filterObject

Returns the value of attribute backtrace_filter.



6
7
8
# File 'lib/query_owl/configuration.rb', line 6

def backtrace_filter
  @backtrace_filter
end

#backtrace_linesObject

Returns the value of attribute backtrace_lines.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def backtrace_lines
  @backtrace_lines
end

#dashboard_enabledObject

Returns the value of attribute dashboard_enabled.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def dashboard_enabled
  @dashboard_enabled
end

#enabledObject

Returns the value of attribute enabled.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def enabled
  @enabled
end

#event_store_sizeObject

Returns the value of attribute event_store_size.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def event_store_size
  @event_store_size
end

#ignore_controllersObject

Returns the value of attribute ignore_controllers.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def ignore_controllers
  @ignore_controllers
end

#ignore_pathsObject

Returns the value of attribute ignore_paths.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def ignore_paths
  @ignore_paths
end

#log_fileObject

Returns the value of attribute log_file.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def log_file
  @log_file
end

#log_levelObject

Returns the value of attribute log_level.



6
7
8
# File 'lib/query_owl/configuration.rb', line 6

def log_level
  @log_level
end

#n_plus_one_thresholdObject

Returns the value of attribute n_plus_one_threshold.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def n_plus_one_threshold
  @n_plus_one_threshold
end

#raise_on_n_plus_oneObject

Returns the value of attribute raise_on_n_plus_one.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def raise_on_n_plus_one
  @raise_on_n_plus_one
end

#slow_query_threshold_msObject

Returns the value of attribute slow_query_threshold_ms.



7
8
9
# File 'lib/query_owl/configuration.rb', line 7

def slow_query_threshold_ms
  @slow_query_threshold_ms
end

Instance Method Details

#notifiersObject



11
12
13
# File 'lib/query_owl/configuration.rb', line 11

def notifiers
  @notifiers ||= [Notifiers::Logger.new]
end

#notifiers=(arr) ⇒ Object



15
16
17
18
19
20
21
22
# File 'lib/query_owl/configuration.rb', line 15

def notifiers=(arr)
  arr.each do |notifier|
    unless notifier.respond_to?(:call)
      raise ArgumentError, "notifiers must respond to #call (#{notifier.class} does not)"
    end
  end
  @notifiers = arr
end