class Vizsla::Patches
Public Class Methods
exec(*args, &blk)
click to toggle source
# File lib/vizsla/patches.rb, line 14 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
handle_event(handler_name, event_data)
click to toggle source
# File lib/vizsla/patches.rb, line 37 def handle_event(handler_name, event_data) handler = self.get_instance_variable "@#{handler_name}_event_handler" hanlder.call event_data unless hanlder.nil? end
patch_postgres(&block)
click to toggle source
# File lib/vizsla/patches.rb, line 8 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