rpm_contrib 1.0.2 → 1.0.3

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.3
2
+
3
+ MongoDB instrumentation contributed by John Nunemaker
4
+
1
5
  * Version 1.0.2
2
6
 
3
7
  Improved Camping support
data/README.md CHANGED
@@ -4,11 +4,103 @@ The `rpm_contrib` gem contains instrumentation for the New Relic RPM agent
4
4
  contributed by the community of RPM users. It requires the RPM Agent
5
5
  to run.
6
6
 
7
+ To use the contrib gem, install the `rpm_contrib` gem off gemcutter. It will
8
+ also install the required version of the `newrelic_rpm` gem if it's not
9
+ already installed.
10
+
11
+ For Rails 2.1 and later, add the dependency in your initializer:
12
+
13
+ config.gem 'rpm_contrib'
14
+
15
+ For other frameworks, make sure you load rubygems if it isn't already, then
16
+ just require the contrib gem:
17
+
18
+ require 'rubygems'
19
+ require 'rpm_contrib'
20
+
21
+ When you load the rpm_contrib gem, the `newrelic_rpm` gem will also be initialized.
22
+ No need for a separate require statement for `newrelic_rpm`.
23
+
24
+ **It's important that you don't load the newrelic_rpm gem separately.** The
25
+ `rpm_contrib` gem must be loaded before the `newrelic_rpm` gem initializes.
26
+
27
+ # How to Add Custom Instrumentation
28
+
7
29
  We encourage contributions to this project and will provide whatever
8
30
  assistance we can to those wishing to develop instrumentation for
9
31
  other open source Ruby libraries.
10
32
 
11
- ## Note on Patches/Pull Requests
33
+ When adding instrumentation to this gem, be sure and get familiar with the
34
+ [RPM Agent API](http://newrelic.github.com/rpm/classes/NewRelic/Agent.html)
35
+ and contact support@newrelic.com with any questions.
36
+
37
+ There are several extension points in the agent you can take advantage of
38
+ with this gem.
39
+
40
+ * Custom tracers which measure methods and give visibility to
41
+ otherwise unmeasured libraries.
42
+ * Samplers which sample some value about once a minute.
43
+ * Dispatcher support for web request handlers which would otherwise be undetected.
44
+ In order for the agent to turn on in 'auto' mode it needs to discover a
45
+ web dispatcher, or be [started manually](http://support.newrelic.com/faqs/general/manual-start).
46
+ * Framework support, for alternatives to Rails like Camping or Ramaze
47
+
48
+ ## Custom Tracers
49
+
50
+ Custom tracers for frameworks should be added to the `lib/rpm_contrib/instrumentation`
51
+ directory. These files are loaded at the time the Agent starts. **They will not
52
+ be loaded if the Agent does not start up.**
53
+
54
+ It is important that you wrap any instrumentation with the checks necessary
55
+ to determine if the code being instrumented is loaded. You can't add code to the
56
+ contrib gem that will break when run in any other context besides yours.
57
+
58
+
59
+ For details on how to define custom tracers, refer to the [support documentation on adding
60
+ custom tracers](http://support.newrelic.com/faqs/docs/custom-metric-collection). You
61
+ can also get detailed information on the API from the
62
+ [Agent method tracing rdocs](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer.html),
63
+ especially the [add_method_tracer](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer/ClassMethods.html)
64
+ docs.
65
+
66
+ A good example can be found in `lib/rpm_contrib/instrumentation/paperclip.rb`.
67
+
68
+ ## Samplers
69
+
70
+ You can add samplers which will record metrics approximately once a minute. Samplers
71
+ are useful for capturing generic instrumentation for display in
72
+ [custom views](http://support.newrelic.com/faqs/docs/custom-dashboard-specification).
73
+
74
+ Samplers should extend the [`NewRelic::Agent::Sampler`](http://newrelic.github.com/rpm/classes/NewRelic/Agent/Sampler.html)
75
+ class. They should be placed in the `samplers` directory.
76
+
77
+ Refer to examples in the RPM agent to see how to get started.
78
+
79
+ ## Supporting New Dispatchers
80
+
81
+ If you want to add support for a new dispatcher which is not being recognized by default
82
+ by the RPM agent, add code to the `rpm_contrib/detection` directory. This code needs
83
+ to define a module in the `NewRelic::LocalEnvironment` class. This module will be
84
+ accessed at the time environment detection takes place, when the agent is initialized.
85
+
86
+ This module should define the method `discover_dispatcher` and return the name of the
87
+ dispatcher if detected, or defer to super. See `rpm_contrib/detection/camping.rb`
88
+ for a good example.
89
+
90
+ ## Supporting New Frameworks
91
+
92
+ Supporting new frameworks can be pretty involved and generally involves both
93
+ adding custom instrumentation as well as framework and dispatcher detection.
94
+
95
+ In addition it will be necessary to define a new control class with the same
96
+ name as the framework. This control class must go in `new_relic/control`.
97
+
98
+ Refer to the camping example in this gem to see how this is done in general.
99
+
100
+ If you decide to tackle any new frameworks, contact support@newrelic.com and
101
+ we'll be happy to help you work through it.
102
+
103
+ # Note on Patches/Pull Requests
12
104
 
13
105
  * Fork the http://www.github.com/newrelic/rpm_contrib project.
14
106
  * Add instrumentation files to `lib/rpm_contrib/instrumentation`. These
@@ -21,7 +113,7 @@ other open source Ruby libraries.
21
113
  commit by itself I can ignore when I pull)
22
114
  * Send me a pull request. Bonus points for topic branches.
23
115
 
24
- ## Further Information
116
+ # Further Information
25
117
 
26
118
  Refer to the [Agent API Documentation](http://newrelic.github.com/rpm).
27
119
 
@@ -29,6 +121,6 @@ See [the support site](http://support.newrelic.com/faqs) for additional tips and
29
121
 
30
122
  Contact support@newrelic.com for help.
31
123
 
32
- ## Copyright
124
+ ### Copyright
33
125
 
34
126
  Copyright (c) 2010 New Relic. See LICENSE for details.
data/Rakefile CHANGED
@@ -56,5 +56,7 @@ Rake::RDocTask.new do |rdoc|
56
56
  rdoc.rdoc_dir = 'rdoc'
57
57
  rdoc.title = "rpm_contrib #{version}"
58
58
  rdoc.rdoc_files.include('README*')
59
+ rdoc.rdoc_files.include('LICENSE')
60
+ rdoc.rdoc_files.include('CHANGELOG')
59
61
  rdoc.rdoc_files.include('lib/**/*.rb')
60
62
  end
@@ -0,0 +1,40 @@
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
+ if defined?(::MongoMapper)
5
+ module MMNewRelicTracing
6
+ def self.included(model)
7
+ model.metaclass.class_eval do
8
+ add_method_tracer :find, 'Database/#{self.name}/find'
9
+ add_method_tracer :find!, 'Database/#{self.name}/find!'
10
+ add_method_tracer :paginate, 'Database/#{self.name}/paginate'
11
+ add_method_tracer :first, 'Database/#{self.name}/first'
12
+ add_method_tracer :last, 'Database/#{self.name}/last'
13
+ add_method_tracer :all, 'Database/#{self.name}/all'
14
+ add_method_tracer :count, 'Database/#{self.name}/count'
15
+ add_method_tracer :create, 'Database/#{self.name}/create'
16
+ add_method_tracer :create!, 'Database/#{self.name}/create!'
17
+ add_method_tracer :update, 'Database/#{self.name}/update'
18
+ add_method_tracer :delete, 'Database/#{self.name}/delete'
19
+ add_method_tracer :delete_all, 'Database/#{self.name}/delete_all'
20
+ add_method_tracer :destroy, 'Database/#{self.name}/destroy'
21
+ add_method_tracer :destroy_all, 'Database/#{self.name}/destroy_all'
22
+ add_method_tracer :exists?, 'Database/#{self.name}/exists?'
23
+ add_method_tracer :find_by_id, 'Database/#{self.name}/find_by_id'
24
+ add_method_tracer :increment, 'Database/#{self.name}/increment'
25
+ add_method_tracer :decrement, 'Database/#{self.name}/decrement'
26
+ add_method_tracer :set, 'Database/#{self.name}/set'
27
+ add_method_tracer :push, 'Database/#{self.name}/push'
28
+ add_method_tracer :push_all, 'Database/#{self.name}/push_all'
29
+ add_method_tracer :push_uniq, 'Database/#{self.name}/push_uniq'
30
+ add_method_tracer :pull, 'Database/#{self.name}/pull'
31
+ add_method_tracer :pull_all, 'Database/#{self.name}/pull_all'
32
+ end
33
+
34
+ model.class_eval do
35
+ add_method_tracer :save, 'Database/#{self.class.name}/save'
36
+ end
37
+ end
38
+ end
39
+ ::MongoMapper::Document.append_inclusions(MMNewRelicTracing)
40
+ end
metadata CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
5
5
  segments:
6
6
  - 1
7
7
  - 0
8
- - 2
9
- version: 1.0.2
8
+ - 3
9
+ version: 1.0.3
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-03-05 00:00:00 -08:00
17
+ date: 2010-03-11 00:00:00 -08:00
18
18
  default_executable:
19
19
  dependencies:
20
20
  - !ruby/object:Gem::Dependency
@@ -50,6 +50,7 @@ files:
50
50
  - lib/rpm_contrib/detection/camping.rb
51
51
  - lib/rpm_contrib/instrumentation/authlogic.rb
52
52
  - lib/rpm_contrib/instrumentation/camping.rb
53
+ - lib/rpm_contrib/instrumentation/mongodb.rb
53
54
  - lib/rpm_contrib/instrumentation/paperclip.rb
54
55
  - test/helper.rb
55
56
  - test/schema.rb