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.
added mongoid support. still need to add tests
- Loading branch information
Karl
committed
May 15, 2010
1 parent
1682dae
commit 8e6fafe
Showing
4 changed files
with
92 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,60 @@ | ||
if defined?(::MongoMapper) && !NewRelic::Control.instance['disable_mongodb'] | ||
|
||
module Mongoid #:nodoc: | ||
module Document | ||
|
||
#adding call to super | ||
class << self | ||
alias :old_included :included | ||
|
||
def included(model) | ||
old_included(model) | ||
super | ||
end | ||
end | ||
end | ||
end | ||
|
||
module RPMContrib::Instrumentation | ||
|
||
module Mongoid | ||
def included(model) | ||
model.metaclass.class_eval do | ||
add_method_tracer :create, 'Database/#{self.name}/create' | ||
add_method_tracer :create!, 'Database/#{self.name}/create!' | ||
add_method_tracer :delete_all, 'Database/#{self.name}/delete_all' | ||
add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all' | ||
add_method_tracer :all, 'Database/#{self.name}/all' | ||
add_method_tracer :find, 'Database/#{self.name}/find' | ||
add_method_tracer :first, 'Database/#{self.name}/first' | ||
add_method_tracer :last, 'Database/#{self.name}/last' | ||
add_method_tracer :find_or_create_by, 'Database/#{self.name}/find_or_create_by' | ||
add_method_tracer :find_or_initialize_by, 'Database/#{self.name}/find_or_initialize_by' | ||
add_method_tracer :min, 'Database/#{self.name}/min' | ||
add_method_tracer :max, 'Database/#{self.name}/max' | ||
add_method_tracer :sum, 'Database/#{self.name}/sum' | ||
end | ||
|
||
model.class_eval do | ||
add_method_tracer :update_attributes, 'Database/#{self.class.name}/update_attributes' | ||
add_method_tracer :update_attributes!, 'Database/#{self.class.name}/update_attributes!' | ||
add_method_tracer :save, 'Database/#{self.class.name}/save' | ||
add_method_tracer :save!, 'Database/#{self.class.name}/save!' | ||
add_method_tracer :delete, 'Database/#{self.class.name}/delete' | ||
add_method_tracer :destroy, 'Database/#{self.class.name}/destroy' | ||
|
||
end | ||
super | ||
end | ||
end | ||
::Mongoid::Document.extend(RPMContrib::Instrumentation::Mongoid) | ||
end | ||
end | ||
|
||
|
||
|
||
|
||
|
||
|
||
|
||
|
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,31 @@ | ||
require "#{File.dirname(__FILE__)}/helper" | ||
require 'mongoid' | ||
|
||
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 | ||
|
||
# To change this template use File | Settings | File Templates. | ||
fail("Not implemented") | ||
end | ||
end |
Empty file.