Sha256: 8e78040e2df5afad87283aa7246f5d1bcbd8d9becc6b014ad1a06c0135a72e38
Contents?: true
Size: 1014 Bytes
Versions: 1
Compression:
Stored size: 1014 Bytes
Contents
require 'vizsla/helpers' module Vizsla class Patches include ::Vizsla::Helpers class << self def patch_postgres(&block) @postgres_event_handler = block ::PG::Connection.class_eval do alias_method :exec_without_profiling, :exec def exec(*args, &blk) return exec_without_profiling(*args, &blk) start_time = Time.now result = exec_without_profiling(*args, &blk) 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 end def handle_event(handler_name, event_data) handler = self.get_instance_variable "@#{handler_name}_event_handler" hanlder.call event_data unless hanlder.nil? end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
vizsla-0.0.6 | lib/vizsla/patches.rb |