Created
May 27, 2015 20:50
-
-
Save babney/f6a1fe75817bf746fb80 to your computer and use it in GitHub Desktop.
Log a stack trace for every transaction... action. Only for Mysql2adapter, could be fixed to work for others.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module TransactionScreamer | |
def begin_db_transaction | |
Rails.logger.debug "DB TRANSACTION STARTS" | |
Rails.logger.debug caller.join("\n") | |
super | |
end | |
def commit_db_transaction | |
Rails.logger.debug "DB TRANSACTION ENDS" | |
Rails.logger.debug caller.join("\n") | |
super | |
end | |
def rollback_db_transaction | |
Rails.logger.debug "DB TRANSACTION ROLLBACK" | |
Rails.logger.debug caller.join("\n") | |
super | |
end | |
end | |
# uncomment the following line to see stack traces every time a transaction | |
# starts, is committed, or rolls back | |
ActiveRecord::ConnectionAdapters::Mysql2Adapter.send :prepend, TransactionScreamer |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment