rpm_contrib 1.0.9 → 1.0.10

Sign up to get free protection for your applications and to get access to all the features.
data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ * Version 1.0.10
2
+
3
+ Mongoid support contributed by Karl Baum
4
+
1
5
  * Version 1.0.9
2
6
 
3
7
  Fixed dependency specification on newrelic_rpm
data/README.md CHANGED
@@ -39,8 +39,11 @@ it by setting `disable_paperclip` to true in the newrelic.yml file.
39
39
 
40
40
  ### MongoDB
41
41
 
42
- No special configuration required for MongoDB visibility. You can disable
43
- it by setting `disable_mongodb` to true in the newrelic.yml file.
42
+ The MongoMapper object mapper is the only currently supported mapper for RPM
43
+ visibility using this gem. Feel free to add others and let us know.
44
+
45
+ No special configuration required. You can disable it by setting
46
+ `disable_mongodb` to true in the newrelic.yml file.
44
47
 
45
48
  ### Resque
46
49
 
@@ -0,0 +1,44 @@
1
+ if defined?(::MongoMapper) && !NewRelic::Control.instance['disable_mongodb']
2
+
3
+ module RPMContrib::Instrumentation
4
+ # Just drop this little diddy in your app to get some (not perfect) information
5
+ # on query times and such.
6
+ #
7
+ # Currently only MongoMapper is implemented
8
+ module MongoMapper
9
+ def self.included(model)
10
+ model.metaclass.class_eval do
11
+ add_method_tracer :find, 'Database/#{self.name}/find'
12
+ add_method_tracer :find!, 'Database/#{self.name}/find!'
13
+ add_method_tracer :paginate, 'Database/#{self.name}/paginate'
14
+ add_method_tracer :first, 'Database/#{self.name}/first'
15
+ add_method_tracer :last, 'Database/#{self.name}/last'
16
+ add_method_tracer :all, 'Database/#{self.name}/all'
17
+ add_method_tracer :count, 'Database/#{self.name}/count'
18
+ add_method_tracer :create, 'Database/#{self.name}/create'
19
+ add_method_tracer :create!, 'Database/#{self.name}/create!'
20
+ add_method_tracer :update, 'Database/#{self.name}/update'
21
+ add_method_tracer :delete, 'Database/#{self.name}/delete'
22
+ add_method_tracer :delete_all, 'Database/#{self.name}/delete_all'
23
+ add_method_tracer :destroy, 'Database/#{self.name}/destroy'
24
+ add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
25
+ add_method_tracer :exists?, 'Database/#{self.name}/exists?'
26
+ add_method_tracer :find_by_id, 'Database/#{self.name}/find_by_id'
27
+ add_method_tracer :increment, 'Database/#{self.name}/increment'
28
+ add_method_tracer :decrement, 'Database/#{self.name}/decrement'
29
+ add_method_tracer :set, 'Database/#{self.name}/set'
30
+ add_method_tracer :push, 'Database/#{self.name}/push'
31
+ add_method_tracer :push_all, 'Database/#{self.name}/push_all'
32
+ add_method_tracer :push_uniq, 'Database/#{self.name}/push_uniq'
33
+ add_method_tracer :pull, 'Database/#{self.name}/pull'
34
+ add_method_tracer :pull_all, 'Database/#{self.name}/pull_all'
35
+ end
36
+
37
+ model.class_eval do
38
+ add_method_tracer :save, 'Database/#{self.class.name}/save'
39
+ end
40
+ end
41
+ end
42
+ ::MongoMapper::Document.append_inclusions(::RPMContrib::Instrumentation::MongoMapper)
43
+ end
44
+ end
@@ -0,0 +1,53 @@
1
+ if defined?(::Mongoid) && !NewRelic::Control.instance['disable_mongodb']
2
+
3
+ module Mongoid #:nodoc:
4
+ module Document
5
+
6
+ #adding call to super
7
+ class << self
8
+ alias :old_included :included
9
+
10
+ def included(model)
11
+ old_included(model)
12
+ super
13
+ end
14
+ end
15
+ end
16
+ end
17
+
18
+ module RPMContrib::Instrumentation
19
+
20
+ module Mongoid
21
+ def included(model)
22
+ model.metaclass.class_eval do
23
+ puts "adding mongoid method tracers for #{model.name}"
24
+ add_method_tracer :create, 'Database/#{self.name}/create'
25
+ add_method_tracer :create!, 'Database/#{self.name}/create!'
26
+ add_method_tracer :delete_all, 'Database/#{self.name}/delete_all'
27
+ add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
28
+ add_method_tracer :all, 'Database/#{self.name}/all'
29
+ add_method_tracer :find, 'Database/#{self.name}/find'
30
+ add_method_tracer :first, 'Database/#{self.name}/first'
31
+ add_method_tracer :last, 'Database/#{self.name}/last'
32
+ add_method_tracer :find_or_create_by, 'Database/#{self.name}/find_or_create_by'
33
+ add_method_tracer :find_or_initialize_by, 'Database/#{self.name}/find_or_initialize_by'
34
+ add_method_tracer :min, 'Database/#{self.name}/min'
35
+ add_method_tracer :max, 'Database/#{self.name}/max'
36
+ add_method_tracer :sum, 'Database/#{self.name}/sum'
37
+ end
38
+
39
+ model.class_eval do
40
+ add_method_tracer :update_attributes, 'Database/#{self.class.name}/update_attributes'
41
+ add_method_tracer :update_attributes!, 'Database/#{self.class.name}/update_attributes!'
42
+ add_method_tracer :save, 'Database/#{self.class.name}/save'
43
+ add_method_tracer :save!, 'Database/#{self.class.name}/save!'
44
+ add_method_tracer :delete, 'Database/#{self.class.name}/delete'
45
+ add_method_tracer :destroy, 'Database/#{self.class.name}/destroy'
46
+
47
+ end
48
+ super
49
+ end
50
+ end
51
+ ::Mongoid::Document.extend(RPMContrib::Instrumentation::Mongoid)
52
+ end
53
+ end
data/test/helper.rb CHANGED
@@ -2,11 +2,8 @@ require 'rubygems'
2
2
  require 'test/unit'
3
3
 
4
4
  $LOAD_PATH.unshift(File.dirname(__FILE__))
5
- $LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
6
- require 'newrelic_rpm'
7
- require 'rpm_contrib'
5
+ #$LOAD_PATH.unshift(File.join(File.dirname(__FILE__), '..', 'lib'))
8
6
 
9
- class Test::Unit::TestCase
10
- end
7
+ require File.expand_path("../../lib/rpm_contrib.rb", __FILE__)
11
8
 
12
9
  require 'schema.rb'
@@ -0,0 +1,42 @@
1
+ require "#{File.dirname(__FILE__)}/helper"
2
+ begin
3
+ require 'mongoid'
4
+ rescue LoadError
5
+ end
6
+
7
+ require "#{File.dirname(__FILE__)}/../lib/rpm_contrib/instrumentation/mongoid"
8
+
9
+ if defined?(::Mongoid)
10
+
11
+ Mongoid.configure do |config|
12
+ config.master = Mongo::Connection.new.db('animals')
13
+ end
14
+
15
+ class Dog
16
+ include Mongoid::Document
17
+
18
+ field :name
19
+ end
20
+
21
+ class MongoidTest < Test::Unit::TestCase
22
+
23
+ # Called before every test method runs. Can be used
24
+ # to set up fixture information.
25
+ def setup
26
+ # Do nothing
27
+ end
28
+
29
+ # Called after every test method runs. Can be used to tear
30
+ # down fixture information.
31
+
32
+ def teardown
33
+ # Do nothing
34
+ end
35
+
36
+ # Fake test
37
+ def test_fail
38
+ Dog.create!(:name=>'rover')
39
+
40
+ end
41
+ end
42
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 9
9
- version: 1.0.9
8
+ - 10
9
+ version: 1.0.10
10
10
  platform: ruby
11
11
  authors:
12
12
  - Bill Kayser
@@ -14,7 +14,7 @@ autorequire:
14
14
  bindir: bin
15
15
  cert_chain: []
16
16
 
17
- date: 2010-05-10 00:00:00 -07:00
17
+ date: 2010-05-21 00:00:00 -07:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -54,13 +54,14 @@ files:
54
54
  - lib/rpm_contrib/detection/camping.rb
55
55
  - lib/rpm_contrib/detection/resque.rb
56
56
  - lib/rpm_contrib/instrumentation/camping.rb
57
- - lib/rpm_contrib/instrumentation/mongodb.rb
57
+ - lib/rpm_contrib/instrumentation/mongo_mapper.rb
58
+ - lib/rpm_contrib/instrumentation/mongoid.rb
58
59
  - lib/rpm_contrib/instrumentation/paperclip.rb
59
60
  - lib/rpm_contrib/instrumentation/redis.rb
60
61
  - lib/rpm_contrib/instrumentation/resque.rb
61
62
  - test/helper.rb
62
63
  - test/schema.rb
63
- - test/test_rpm_contrib.rb
64
+ - test/test_mongoid.rb
64
65
  has_rdoc: true
65
66
  homepage: http://github.com/newrelic/rpm_contrib
66
67
  licenses: []
@@ -100,4 +101,4 @@ summary: Contributed Instrumentation for New Relic RPM
100
101
  test_files:
101
102
  - test/helper.rb
102
103
  - test/schema.rb
103
- - test/test_rpm_contrib.rb
104
+ - test/test_mongoid.rb
@@ -1,41 +0,0 @@
1
- # Just drop this little diddy in your app to get some (not perfect) information on query times and such
2
- # This will eventually become an official plugin but for those who can't wait, enjoy.
3
-
4
-
5
- module RPMContrib::Instrumentation
6
- module MongoDB
7
- def self.included(model)
8
- model.metaclass.class_eval do
9
- add_method_tracer :find, 'Database/#{self.name}/find'
10
- add_method_tracer :find!, 'Database/#{self.name}/find!'
11
- add_method_tracer :paginate, 'Database/#{self.name}/paginate'
12
- add_method_tracer :first, 'Database/#{self.name}/first'
13
- add_method_tracer :last, 'Database/#{self.name}/last'
14
- add_method_tracer :all, 'Database/#{self.name}/all'
15
- add_method_tracer :count, 'Database/#{self.name}/count'
16
- add_method_tracer :create, 'Database/#{self.name}/create'
17
- add_method_tracer :create!, 'Database/#{self.name}/create!'
18
- add_method_tracer :update, 'Database/#{self.name}/update'
19
- add_method_tracer :delete, 'Database/#{self.name}/delete'
20
- add_method_tracer :delete_all, 'Database/#{self.name}/delete_all'
21
- add_method_tracer :destroy, 'Database/#{self.name}/destroy'
22
- add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
23
- add_method_tracer :exists?, 'Database/#{self.name}/exists?'
24
- add_method_tracer :find_by_id, 'Database/#{self.name}/find_by_id'
25
- add_method_tracer :increment, 'Database/#{self.name}/increment'
26
- add_method_tracer :decrement, 'Database/#{self.name}/decrement'
27
- add_method_tracer :set, 'Database/#{self.name}/set'
28
- add_method_tracer :push, 'Database/#{self.name}/push'
29
- add_method_tracer :push_all, 'Database/#{self.name}/push_all'
30
- add_method_tracer :push_uniq, 'Database/#{self.name}/push_uniq'
31
- add_method_tracer :pull, 'Database/#{self.name}/pull'
32
- add_method_tracer :pull_all, 'Database/#{self.name}/pull_all'
33
- end
34
-
35
- model.class_eval do
36
- add_method_tracer :save, 'Database/#{self.class.name}/save'
37
- end
38
- end
39
- end
40
- ::MongoMapper::Document.append_inclusions(::RPMContrib::Instrumentation::MongoDB)
41
- end if defined?(::MongoMapper) && !NewRelic::Control.instance['disable_mongodb']
@@ -1,7 +0,0 @@
1
- require "#{File.dirname(__FILE__)}/helper"
2
-
3
- class TestRpmContrib < Test::Unit::TestCase
4
- def test_something_for_real
5
- flunk "hey buddy, you should probably rename this file and start testing for real"
6
- end
7
- end