Sha256: d32a9b683b2cf23706ddc2a338df66f009b162cf735e35ca102ba39262809c07

Contents?: true

Size: 963 Bytes

Versions: 3

Compression:

Stored size: 963 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   = ::Tracebin::PatchHelper.timestamp_string
    result       = exec_params_without_tracebin(*args, &block)
    end_time     = ::Tracebin::PatchHelper.timestamp_string

    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   = ::Tracebin::PatchHelper.timestamp_string
    result       = exec_without_tracebin(*args, &block)
    end_time     = ::Tracebin::PatchHelper.timestamp_string

    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.13 lib/tracebin/patches/postgres.rb
tracebin-0.0.12 lib/tracebin/patches/postgres.rb
tracebin-0.0.11 lib/tracebin/patches/postgres.rb