Class: StackifyRubyAPM::Normalizers::ActiveRecord::SqlNormalizer Private

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

Constant Summary

Constants included from Log

Log::PREFIX

Instance Method Summary collapse

Methods included from Log

#debug, #error, #fatal, #info, #log, #warn

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.



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

def initialize(*args)
  super(*args)

  @type = format('db.%s.sql', lookup_adapter || 'unknown').freeze
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/stackify_apm/normalizers/active_record.rb', line 19

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

  statement = query_variables(payload)
  name = payload[:sql] || payload[:name] || 'Default'
  context = Span::Context.new(statement)
  [name, @type, context]
end