forked from newrelic/rpm_contrib
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Bill Kayser
committed
May 22, 2010
1 parent
2ef7803
commit 7b297ba
Showing
9 changed files
with
96 additions
and
102 deletions.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,44 @@ | ||
if defined?(::MongoMapper) && !NewRelic::Control.instance['disable_mongodb'] | ||
|
||
module RPMContrib::Instrumentation | ||
# Just drop this little diddy in your app to get some (not perfect) information | ||
# on query times and such. | ||
# | ||
# Currently only MongoMapper is implemented | ||
module MongoMapper | ||
def self.included(model) | ||
model.metaclass.class_eval do | ||
add_method_tracer :find, 'Database/#{self.name}/find' | ||
add_method_tracer :find!, 'Database/#{self.name}/find!' | ||
add_method_tracer :paginate, 'Database/#{self.name}/paginate' | ||
add_method_tracer :first, 'Database/#{self.name}/first' | ||
add_method_tracer :last, 'Database/#{self.name}/last' | ||
add_method_tracer :all, 'Database/#{self.name}/all' | ||
add_method_tracer :count, 'Database/#{self.name}/count' | ||
add_method_tracer :create, 'Database/#{self.name}/create' | ||
add_method_tracer :create!, 'Database/#{self.name}/create!' | ||
add_method_tracer :update, 'Database/#{self.name}/update' | ||
add_method_tracer :delete, 'Database/#{self.name}/delete' | ||
add_method_tracer :delete_all, 'Database/#{self.name}/delete_all' | ||
add_method_tracer :destroy, 'Database/#{self.name}/destroy' | ||
add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all' | ||
add_method_tracer :exists?, 'Database/#{self.name}/exists?' | ||
add_method_tracer :find_by_id, 'Database/#{self.name}/find_by_id' | ||
add_method_tracer :increment, 'Database/#{self.name}/increment' | ||
add_method_tracer :decrement, 'Database/#{self.name}/decrement' | ||
add_method_tracer :set, 'Database/#{self.name}/set' | ||
add_method_tracer :push, 'Database/#{self.name}/push' | ||
add_method_tracer :push_all, 'Database/#{self.name}/push_all' | ||
add_method_tracer :push_uniq, 'Database/#{self.name}/push_uniq' | ||
add_method_tracer :pull, 'Database/#{self.name}/pull' | ||
add_method_tracer :pull_all, 'Database/#{self.name}/pull_all' | ||
end | ||
|
||
model.class_eval do | ||
add_method_tracer :save, 'Database/#{self.class.name}/save' | ||
end | ||
end | ||
end | ||
::MongoMapper::Document.append_inclusions(::RPMContrib::Instrumentation::MongoMapper) | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.
This file contains 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
This file contains 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
This file contains 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
This file was deleted.
Oops, something went wrong.
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
require "#{File.dirname(__FILE__)}/helper" | ||
begin | ||
require 'mongoid' | ||
rescue LoadError | ||
end | ||
|
||
require "#{File.dirname(__FILE__)}/../lib/rpm_contrib/instrumentation/mongoid" | ||
|
||
if defined?(::Mongoid) | ||
|
||
Mongoid.configure do |config| | ||
config.master = Mongo::Connection.new.db('animals') | ||
end | ||
|
||
class Dog | ||
include Mongoid::Document | ||
|
||
field :name | ||
end | ||
|
||
class MongoidTest < Test::Unit::TestCase | ||
|
||
# Called before every test method runs. Can be used | ||
# to set up fixture information. | ||
def setup | ||
# Do nothing | ||
end | ||
|
||
# Called after every test method runs. Can be used to tear | ||
# down fixture information. | ||
|
||
def teardown | ||
# Do nothing | ||
end | ||
|
||
# Fake test | ||
def test_fail | ||
Dog.create!(:name=>'rover') | ||
|
||
end | ||
end | ||
end |
This file was deleted.
Oops, something went wrong.