Class: BrainzLab::Instrumentation::ActiveRecord

Inherits:
Object
  • Object
show all
Defined in:
lib/brainzlab/instrumentation/active_record.rb

Constant Summary collapse

SCHEMA_QUERIES =
%w[SCHEMA EXPLAIN].freeze
INTERNAL_TABLES =
%w[pg_ information_schema sqlite_ mysql.].freeze
SLOW_QUERY_THRESHOLD =

Slow-query / N+1 thresholds + log levels are now configurable — see BrainzLab::Configuration (slow_query_threshold, very_slow_query_threshold, slow_query_log_level, very_slow_query_log_level, n_plus_one_threshold, n_plus_one_log_level) + their BRAINZLAB_* env vars. These constants are kept only as legacy fallbacks and are no longer read by the instrumentation.

100
VERY_SLOW_QUERY_THRESHOLD =
1000
N_PLUS_ONE_THRESHOLD =

queries to same table in single request

5
N_PLUS_ONE_WINDOW =

max queries to track per request

50

Class Method Summary collapse

Class Method Details

.install!Object



20
21
22
23
24
25
26
27
28
29
30
31
32
# File 'lib/brainzlab/instrumentation/active_record.rb', line 20

def install!
  return unless defined?(::ActiveRecord)
  return if @installed

  install_sql_subscriber!
  install_instantiation_subscriber!
  install_transaction_subscribers!
  install_strict_loading_subscriber!
  install_deprecated_association_subscriber!

  @installed = true
  BrainzLab.debug_log('ActiveRecord instrumentation installed (sql, instantiation, transactions, strict_loading)')
end

.installed?Boolean

Returns:

  • (Boolean)


34
35
36
# File 'lib/brainzlab/instrumentation/active_record.rb', line 34

def installed?
  @installed == true
end