Module: Oboe::Inst::ConnectionAdapters::Utils
- Included in:
- AbstractMysqlAdapter, LegacyMysqlAdapter, LegacyPostgreSQLAdapter, Mysql2Adapter, MysqlAdapter, PostgreSQLAdapter
- Defined in:
- lib/oboe/frameworks/rails/inst/active_record.rb
Instance Method Summary collapse
- #begin_db_transaction_with_oboe ⇒ Object
- #cfg ⇒ Object
- #exec_delete_with_oboe(sql, name = nil, binds = []) ⇒ Object
- #exec_insert_with_oboe(sql, name = nil, binds = []) ⇒ Object
- #exec_query_with_oboe(sql, name = nil, binds = []) ⇒ Object
- #execute_with_oboe(sql, name = nil) ⇒ Object
- #extract_trace_details(sql, name = nil) ⇒ Object
-
#ignore_payload?(name) ⇒ Boolean
We don’t want to trace framework caches.
Instance Method Details
#begin_db_transaction_with_oboe ⇒ Object
86 87 88 89 90 91 92 93 94 95 96 97 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 86 def begin_db_transaction_with_oboe() if Oboe::Config.tracing? opts = {} opts[:Query] = "BEGIN" Oboe::API.trace('ActiveRecord', opts || {}) do begin_db_transaction_without_oboe() end else begin_db_transaction_without_oboe() end end |
#cfg ⇒ Object
34 35 36 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 34 def cfg @config end |
#exec_delete_with_oboe(sql, name = nil, binds = []) ⇒ Object
62 63 64 65 66 67 68 69 70 71 72 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 62 def exec_delete_with_oboe(sql, name = nil, binds = []) if Oboe::Config.tracing? and !ignore_payload?(name) opts = extract_trace_details(sql, name) Oboe::API.trace('ActiveRecord', opts || {}) do exec_delete_without_oboe(sql, name, binds) end else exec_delete_without_oboe(sql, name, binds) end end |
#exec_insert_with_oboe(sql, name = nil, binds = []) ⇒ Object
74 75 76 77 78 79 80 81 82 83 84 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 74 def exec_insert_with_oboe(sql, name = nil, binds = []) if Oboe::Config.tracing? and !ignore_payload?(name) opts = extract_trace_details(sql, name) Oboe::API.trace('ActiveRecord', opts || {}) do exec_insert_without_oboe(sql, name, binds) end else exec_insert_without_oboe(sql, name, binds) end end |
#exec_query_with_oboe(sql, name = nil, binds = []) ⇒ Object
50 51 52 53 54 55 56 57 58 59 60 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 50 def exec_query_with_oboe(sql, name = nil, binds = []) if Oboe::Config.tracing? and !ignore_payload?(name) opts = extract_trace_details(sql, name) Oboe::API.trace('ActiveRecord', opts || {}) do exec_query_without_oboe(sql, name, binds) end else exec_query_without_oboe(sql, name, binds) end end |
#execute_with_oboe(sql, name = nil) ⇒ Object
38 39 40 41 42 43 44 45 46 47 48 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 38 def execute_with_oboe(sql, name = nil) if Oboe::Config.tracing? and !ignore_payload?(name) opts = extract_trace_details(sql, name) Oboe::API.trace('ActiveRecord', opts || {}) do execute_without_oboe(sql, name) end else execute_without_oboe(sql, name) end end |
#extract_trace_details(sql, name = nil) ⇒ Object
8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 8 def extract_trace_details(sql, name = nil) opts = {} opts[:Query] = sql.to_s opts[:Name] = name.to_s if name if defined?(ActiveRecord::Base.connection.cfg) opts[:Database] = ActiveRecord::Base.connection.cfg[:database] if ActiveRecord::Base.connection.cfg.has_key?(:host) opts[:RemoteHost] = ActiveRecord::Base.connection.cfg[:host] end end if defined?(ActiveRecord::Base.connection.adapter_name) opts[:Flavor] = ActiveRecord::Base.connection.adapter_name end return opts || {} end |
#ignore_payload?(name) ⇒ Boolean
We don’t want to trace framework caches. Only instrument SQL that directly hits the database.
30 31 32 |
# File 'lib/oboe/frameworks/rails/inst/active_record.rb', line 30 def ignore_payload?(name) %w(SCHEMA EXPLAIN CACHE).include? name.to_s or (name and name.to_sym == :skip_logging) end |