Module: AppPerfRpm::Instruments::ActiveRecord::Adapters::Sqlite3

Includes:
Utils
Defined in:
lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb

Constant Summary collapse

IGNORE_STATEMENTS =
{
  "SCHEMA" => true,
  "EXPLAIN" => true,
  "CACHE" => true
}

Instance Method Summary collapse

Methods included from Utils

#sanitize_sql

Instance Method Details

#begin_db_transaction_with_traceObject



86
87
88
89
90
91
92
93
94
95
96
97
98
# File 'lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb', line 86

def begin_db_transaction_with_trace
  if ::AppPerfRpm::Tracer.tracing?
    AppPerfRpm::Tracer.trace('activerecord', opts) do |span|
      span.options = {
        "adapter" => "postgresql",
        "query" => "BEGIN"
      }
      begin_db_transaction_without_trace
    end
  else
    begin_db_transaction_without_trace
  end
end

#exec_delete_with_trace(sql, name = nil, binds = []) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# File 'lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb', line 42

def exec_delete_with_trace(sql, name = nil, binds = [])
  if ::AppPerfRpm::Tracer.tracing?
    if ignore_trace?(name)
      exec_delete_without_trace(sql, name, binds)
    else
      sanitized_sql = sanitize_sql(sql, :sqlite)

      AppPerfRpm::Tracer.trace('activerecord', opts) do |span|
        span.options = {
          "adapter" => "postgresql",
          "query" => sanitized_sql,
          "name" => name
        }

        exec_delete_without_trace(sql, name, binds)
      end
    end
  else
    exec_delete_without_trace(sql, name, binds)
  end
end

#exec_insert_with_trace(sql, name = nil, binds = [], *args) ⇒ Object



64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
# File 'lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb', line 64

def exec_insert_with_trace(sql, name = nil, binds = [], *args)
  if ::AppPerfRpm::Tracer.tracing?
    if ignore_trace?(name)
      exec_insert_without_trace(sql, name, binds, *args)
    else
      sanitized_sql = sanitize_sql(sql, :sqlite)

      AppPerfRpm::Tracer.trace('activerecord', opts) do |span|
        span.options = {
          "adapter" => "postgresql",
          "query" => sanitized_sql,
          "name" => name
        }

        exec_insert_without_trace(sql, name, binds, *args)
      end
    end
  else
    exec_insert_without_trace(sql, name, binds, *args)
  end
end

#exec_query_with_trace(sql, name = nil, binds = []) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
# File 'lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb', line 20

def exec_query_with_trace(sql, name = nil, binds = [])
  if ::AppPerfRpm::Tracer.tracing?
    if ignore_trace?(name)
      exec_query_without_trace(sql, name, binds)
    else
      sanitized_sql = sanitize_sql(sql, :sqlite)

      AppPerfRpm::Tracer.trace('activerecord', opts) do |span|
        span.options = {
          "adapter" => "postgresql",
          "query" => sanitized_sql,
          "name" => name
        }

        exec_query_without_trace(sql, name, binds)
      end
    end
  else
    exec_query_without_trace(sql, name, binds)
  end
end

#ignore_trace?(name) ⇒ Boolean

Returns:

  • (Boolean)


14
15
16
17
18
# File 'lib/app_perf_rpm/instruments/active_record/adapters/sqlite3.rb', line 14

def ignore_trace?(name)
  IGNORE_STATEMENTS[name.to_s] ||
    (name && name.to_sym == :skip_logging) ||
    name == 'ActiveRecord::SchemaMigration Load'
end