Class: Logister::SqlSubscriber

Inherits:
Object
  • Object
show all
Defined in:
lib/logister/sql_subscriber.rb

Constant Summary collapse

IGNORED_SQL_NAMES =
%w[SCHEMA TRANSACTION].freeze
MESSAGE =

Frozen constants for values emitted on every captured query.

'db.query'
LEVEL_WARN =
'warn'
LEVEL_INFO =
'info'
TAGS =
{ category: 'database' }.freeze
SQL_FINGERPRINT =
Digest::SHA256.hexdigest(MESSAGE)[0, 32].freeze

Class Method Summary collapse

Class Method Details

.install!Object



19
20
21
22
23
24
25
26
27
# File 'lib/logister/sql_subscriber.rb', line 19

def install!
  return if @installed

  ActiveSupport::Notifications.subscribe('sql.active_record') do |_name, started, finished, _id, payload|
    handle_sql_event(started, finished, payload)
  end

  @installed = true
end