Module: TraceView::Inst::ConnectionAdapters::FlavorInitializers

Defined in:
lib/traceview/frameworks/rails/inst/connection_adapters/mysql.rb,
lib/traceview/frameworks/rails/inst/connection_adapters/mysql2.rb,
lib/traceview/frameworks/rails/inst/connection_adapters/oracle.rb,
lib/traceview/frameworks/rails/inst/connection_adapters/postgresql.rb

Class Method Summary collapse

Class Method Details

.mysqlObject



8
9
10
11
12
13
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
# File 'lib/traceview/frameworks/rails/inst/connection_adapters/mysql.rb', line 8

def self.mysql
  TraceView.logger.info '[traceview/loading] Instrumenting activerecord mysqladapter' if TraceView::Config[:verbose]

  # ActiveRecord 3.2 and higher
  if (::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR >= 2) ||
      ::ActiveRecord::VERSION::MAJOR == 4

    # AbstractMysqlAdapter
    TraceView::Util.send_include(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter,
                            ::TraceView::Inst::ConnectionAdapters::Utils)
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::AbstractMysqlAdapter, :execute)

    # MysqlAdapter
    TraceView::Util.send_include(::ActiveRecord::ConnectionAdapters::MysqlAdapter,
                            ::TraceView::Inst::ConnectionAdapters::Utils)
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :exec_query)

  else
    # ActiveRecord 3.1 and below

    # MysqlAdapter
    TraceView::Util.send_include(::ActiveRecord::ConnectionAdapters::MysqlAdapter,
                            ::TraceView::Inst::ConnectionAdapters::Utils)

    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :execute)

    if ::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR == 1
      TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :begin_db_transaction)
      TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::MysqlAdapter, :exec_delete)
    end
  end
end

.mysql2Object



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
# File 'lib/traceview/frameworks/rails/inst/connection_adapters/mysql2.rb', line 8

def self.mysql2
  TraceView.logger.info '[traceview/loading] Instrumenting activerecord mysql2adapter' if TraceView::Config[:verbose]

  TraceView::Util.send_include(::ActiveRecord::ConnectionAdapters::Mysql2Adapter,
                          ::TraceView::Inst::ConnectionAdapters::Utils)

  if (::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR == 0) ||
      ::ActiveRecord::VERSION::MAJOR == 2
    # ActiveRecord 3.0 and prior
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :execute)
  else
    # ActiveRecord 3.1 and above
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :exec_insert)
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :exec_query)
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::Mysql2Adapter, :exec_delete)
  end
end

.oracleObject



8
9
10
11
12
13
# File 'lib/traceview/frameworks/rails/inst/connection_adapters/oracle.rb', line 8

def self.oracle
  TraceView.logger.info '[traceview/loading] Instrumenting activerecord oracleenhancedadapter' if TraceView::Config[:verbose]
  ::ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter.module_eval do
    include TraceView::Inst::ConnectionAdapters
  end if defined?(::ActiveRecord::ConnectionAdapters::OracleEnhancedAdapter)
end

.postgresqlObject



8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
# File 'lib/traceview/frameworks/rails/inst/connection_adapters/postgresql.rb', line 8

def self.postgresql

  TraceView.logger.info '[traceview/loading] Instrumenting activerecord postgresqladapter' if TraceView::Config[:verbose]

  TraceView::Util.send_include(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter,
                          ::TraceView::Inst::ConnectionAdapters::Utils)

  if (::ActiveRecord::VERSION::MAJOR == 3 && ::ActiveRecord::VERSION::MINOR > 0) ||
        ::ActiveRecord::VERSION::MAJOR == 4

    # ActiveRecord 3.1 and up
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, :exec_query)
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, :exec_delete)

  else
    # ActiveRecord 3.0 and prior
    TraceView::Util.method_alias(::ActiveRecord::ConnectionAdapters::PostgreSQLAdapter, :execute)
  end
end