Skip to content

Commit

Permalink
Mongoid support
Browse files Browse the repository at this point in the history
  • Loading branch information
Bill Kayser committed May 22, 2010
1 parent 2ef7803 commit 7b297ba
Show file tree
Hide file tree
Showing 9 changed files with 96 additions and 102 deletions.
4 changes: 4 additions & 0 deletions CHANGELOG
Original file line number Diff line number Diff line change
@@ -1,3 +1,7 @@
* Version 1.0.10

Mongoid support contributed by Karl Baum

* Version 1.0.9

Fixed dependency specification on newrelic_rpm
Expand Down
44 changes: 44 additions & 0 deletions lib/rpm_contrib/instrumentation/mongo_mapper.rb
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
42 changes: 0 additions & 42 deletions lib/rpm_contrib/instrumentation/mongodb.rb

This file was deleted.

9 changes: 0 additions & 9 deletions lib/rpm_contrib/instrumentation/mongoid.rb
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
debugger
if defined?(::Mongoid) && !NewRelic::Control.instance['disable_mongodb']

module Mongoid #:nodoc:
Expand Down Expand Up @@ -52,11 +51,3 @@ def included(model)
::Mongoid::Document.extend(RPMContrib::Instrumentation::Mongoid)
end
end








6 changes: 4 additions & 2 deletions rpm_contrib.gemspec
Original file line number Diff line number Diff line change
Expand Up @@ -5,11 +5,11 @@

Gem::Specification.new do |s|
s.name = %q{rpm_contrib}
s.version = "1.0.9"
s.version = "1.0.10"

s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
s.authors = ["Bill Kayser"]
s.date = %q{2010-05-10}
s.date = %q{2010-05-21}
s.description = %q{Community contributed instrumentation for various frameworks based on
the New Relic Ruby monitoring gem newrelic_rpm.
}
Expand All @@ -35,6 +35,7 @@ the New Relic Ruby monitoring gem newrelic_rpm.
"lib/rpm_contrib/instrumentation/redis.rb",
"lib/rpm_contrib/instrumentation/resque.rb",
"test/helper.rb",
"test/mongoid_test.rb",
"test/schema.rb",
"test/test_rpm_contrib.rb"
]
Expand All @@ -45,6 +46,7 @@ the New Relic Ruby monitoring gem newrelic_rpm.
s.summary = %q{Contributed Instrumentation for New Relic RPM}
s.test_files = [
"test/helper.rb",
"test/mongoid_test.rb",
"test/schema.rb",
"test/test_rpm_contrib.rb"
]
Expand Down
8 changes: 2 additions & 6 deletions test/helper.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,12 +2,8 @@
require 'test/unit'

$LOAD_PATH.unshift(File.dirname(__FILE__))
$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
require 'rpm_contrib'
require 'newrelic_rpm'
#$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))


class Test::Unit::TestCase
end
require File.expand_path("../../lib/rpm_contrib.rb", __FILE__)

require 'schema.rb'
36 changes: 0 additions & 36 deletions test/mongoid_test.rb

This file was deleted.

42 changes: 42 additions & 0 deletions test/test_mongoid.rb
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
7 changes: 0 additions & 7 deletions test/test_rpm_contrib.rb

This file was deleted.

0 comments on commit 7b297ba

Please sign in to comment.