Class: Atatus::Normalizers::ActiveRecord::SqlNormalizer Private

Inherits:
Normalizer
  • Object
show all
Defined in:
lib/atatus/normalizers/rails/active_record.rb

This class is part of a private API. You should avoid using this class if possible, as it may be removed or be changed in the future.

Constant Summary collapse

TYPE =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'db'
ACTION =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'sql'
SKIP_NAMES =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

%w[SCHEMA CACHE].freeze
UNKNOWN =

This constant is part of a private API. You should avoid using this constant if possible, as it may be removed or be changed in the future.

'unknown'

Instance Method Summary collapse

Methods inherited from Normalizer

#backtrace, register

Constructor Details

#initialize(*args) ⇒ SqlNormalizer

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.

Returns a new instance of SqlNormalizer.



34
35
36
37
38
39
40
# File 'lib/atatus/normalizers/rails/active_record.rb', line 34

def initialize(*args)
  super

  @summarizer = Sql::Signature::Summarizer.new

  @adapters = {}
end

Instance Method Details

#normalize(_transaction, _name, payload) ⇒ Object

This method is part of a private API. You should avoid using this method if possible, as it may be removed or be changed in the future.



42
43
44
45
46
47
48
49
50
51
52
53
54
55
# File 'lib/atatus/normalizers/rails/active_record.rb', line 42

def normalize(_transaction, _name, payload)
  return :skip if SKIP_NAMES.include?(payload[:name])

  name = summarize(payload[:sql]) || payload[:name]
  subtype = subtype_for(payload)

  context =
    Span::Context.new(
      db: { statement: payload[:sql], type: 'sql' },
      destination: { service: { name: subtype, resource: subtype, type: TYPE } }
    )

  [name, TYPE, subtype, ACTION, context]
end