Class: ElasticAPM::Normalizers::ActiveRecord::SqlNormalizer Private

Inherits:
Normalizer
  • Object
show all
Defined in:
lib/elastic_apm/normalizers/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.

Instance Method Summary collapse

Methods inherited from Normalizer

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.



12
13
14
15
16
17
# File 'lib/elastic_apm/normalizers/active_record.rb', line 12

def initialize(*args)
  super

  @type = format('db.%s.sql', lookup_adapter || 'unknown').freeze
  @summarizer = SqlSummarizer.new
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.



19
20
21
22
23
24
25
26
# File 'lib/elastic_apm/normalizers/active_record.rb', line 19

def normalize(_transaction, _name, payload)
  return :skip if %w[SCHEMA CACHE].include?(payload[:name])

  name = summarize(payload[:sql]) || payload[:name]
  context =
    Span::Context.new(db: { statement: payload[:sql], type: 'sql' })
  [name, @type, context]
end