Skip to content

Instantly share code, notes, and snippets.

@revans
Forked from jnunemaker/mongo_mapper_new_relic.rb
Created January 8, 2010 16:13
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save revans/272146 to your computer and use it in GitHub Desktop.
Save revans/272146 to your computer and use it in GitHub Desktop.
# 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