Module: AppPerfRpm::Instruments::ActiveRecord::Adapters::Postgresql
- Includes:
- Utils
- Defined in:
- lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb
Constant Summary collapse
- IGNORE_STATEMENTS =
{ "SCHEMA" => true, "EXPLAIN" => true, "CACHE" => true }
Instance Method Summary collapse
- #begin_db_transaction_with_trace ⇒ Object
- #exec_delete_with_trace(sql, name = nil, binds = []) ⇒ Object
- #exec_insert_with_trace(sql, name = nil, binds = [], *args) ⇒ Object
- #exec_query_with_trace(sql, name = nil, binds = []) ⇒ Object
- #ignore_trace?(name) ⇒ Boolean
Methods included from Utils
Instance Method Details
#begin_db_transaction_with_trace ⇒ Object
84 85 86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb', line 84 def begin_db_transaction_with_trace if ::AppPerfRpm::Tracer.tracing? AppPerfRpm::Tracer.trace('activerecord') do |span| span. = { "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
41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb', line 41 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) AppPerfRpm::Tracer.trace('activerecord') do |span| span. = { "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
62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 |
# File 'lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb', line 62 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, :postgres) AppPerfRpm::Tracer.trace('activerecord') do |span| span. = { "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 |
# File 'lib/app_perf_rpm/instruments/active_record/adapters/postgresql.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, :postgres) AppPerfRpm::Tracer.trace('activerecord') do |span| span. = { "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
14 15 16 17 18 |
# File 'lib/app_perf_rpm/instruments/active_record/adapters/postgresql.rb', line 14 def ignore_trace?(name) IGNORE_STATEMENTS[name.to_s] || (name && name.to_sym == :skip_logging) || name == 'ActiveRecord::SchemaMigration Load' end |