Sha256: 00daf28621304a7a8b12e4077171df000e250c8b55dce6391f357a16d0e75da2

Contents?: true

Size: 835 Bytes

Versions: 3

Compression:

Stored size: 835 Bytes

Contents

::PG::Connection.class_eval do
  alias_method :exec_without_tracebin, :exec
  alias_method :exec_params_without_tracebin, :exec_params

  def exec_params(*args, &block)
    start_time   = Time.now
    result       = exec_params_without_tracebin(*args, &block)
    end_time     = Time.now

    event_data = [
      'sql.postgres_exec',
      start_time,
      end_time,
      {
        sql: args[0]
      }
    ]

    ::Tracebin::Patches.handle_event :postgres, event_data

    result
  end

  def exec(*args, &block)
    start_time   = Time.now
    result       = exec_without_tracebin(*args, &block)
    end_time     = Time.now

    event_data = [
      'sql.postgres_exec',
      start_time,
      end_time,
      {
        sql: args[0]
      }
    ]

    ::Tracebin::Patches.handle_event :postgres, event_data

    result
  end
end

Version data entries

3 entries across 3 versions & 1 rubygems

Version Path
tracebin-0.0.10 lib/tracebin/patches/postgres.rb
tracebin-0.0.9 lib/tracebin/patches/postgres.rb
tracebin-0.0.8 lib/tracebin/patches/postgres.rb