module TraceView::Inst::ConnectionAdapters::FlavorInitializers

Public Class Methods

mysql() click to toggle source
# 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
mysql2() click to toggle source
# 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
postgresql() click to toggle source
# 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