Class: Skylight::Normalizers::ActiveRecord::SQL Private

Inherits:
Normalizer show all
Defined in:
lib/skylight/normalizers/active_record/sql.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

CAT =

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.sql.query".freeze

Instance Attribute Summary

Attributes inherited from Normalizer

#config

Instance Method Summary collapse

Methods inherited from Normalizer

#initialize, register

Constructor Details

This class inherits a constructor from Skylight::Normalizers::Normalizer

Instance Method Details

#normalize(trace, 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.



14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/skylight/normalizers/active_record/sql.rb', line 14

def normalize(trace, name, payload)
  case payload[:name]
  when "SCHEMA", "CACHE"
    return :skip
  else
    name  = CAT
    title = payload[:name] || "SQL"
  end

  binds = payload[:binds]

  if binds && !binds.empty?
    binds = binds.map { |col, val| val.inspect }
  end

  extracted_title, sql, binds, _ = extract_binds(payload, binds)
  title = extracted_title if extracted_title

  if sql
    annotations = {
      sql:   sql,
      binds: binds,
    }
  end

  [ name, title, sql, annotations ]
end