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.



16
17
18
# File 'lib/stackify_apm/normalizers/active_record.rb', line 16

def initialize(*args)
  super(*args)
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.



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

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

  adapter = lookup_adapter(payload)
  statement = query_variables(payload, adapter)
  check_prepared_stmt(statement, payload, adapter)
  name = payload[:sql] || payload[:name] || 'Default'
  context = Span::Context.new(statement)

  type = format('db.%s.sql', adapter || 'unknown').freeze
  [name, type, context]
end