Sha256: e7eb6183bc0018ccb55091a6904f144d51b4e8ad003901402727c9e2697656bd

Contents?: true

Size: 823 Bytes

Versions: 1

Compression:

Stored size: 823 Bytes

Contents

::PG::Connection.class_eval do
  alias_method :exec_without_vizsla, :exec
  alias_method :exec_params_without_vizsla, :exec_params

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

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

    ::Vizsla::Patches.handle_event :postgres, event_data

    result
  end

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

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

    ::Vizsla::Patches.handle_event :postgres, event_data

    result
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
tracebin-0.0.7 lib/vizsla/patches/postgres.rb