-
-
Save revans/272146 to your computer and use it in GitHub Desktop.
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
# Just drop this little diddy in your app to get some (not perfect) information on query times and such | |
# This will eventually become an official plugin but for those who can't wait, enjoy. | |
if defined?(NewRelic) | |
module MMNewRelicTracing | |
def self.included(model) | |
meths = %w[find find! paginate first last all count create create! update delete delete_all destroy destroy_all exists? find_by_id increment decrement set push push_all push_uniq pull pull_all] | |
model.metaclass.class_eval do | |
meths.each do |meth| | |
add_method_tracer meth.to_sym, 'Database/#{self.name}/' + meth | |
end | |
end | |
model.class_eval do | |
add_method_tracer :save, 'Database/#{self.class.name}/save' | |
end | |
end | |
end | |
MongoMapper::Document.append_inclusions(MMNewRelicTracing) | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment