seanwalbran-rpm_contrib 2.1.6.1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (42) hide show
  1. data/CHANGELOG +133 -0
  2. data/Gemfile +13 -0
  3. data/LICENSE +20 -0
  4. data/README.md +293 -0
  5. data/Rakefile +79 -0
  6. data/lib/new_relic/control/camping.rb +14 -0
  7. data/lib/rpm_contrib/agent_compatibility.rb +11 -0
  8. data/lib/rpm_contrib/detection/camping.rb +24 -0
  9. data/lib/rpm_contrib/detection.rb +5 -0
  10. data/lib/rpm_contrib/instrumentation/active_messaging.rb +22 -0
  11. data/lib/rpm_contrib/instrumentation/aws.rb +68 -0
  12. data/lib/rpm_contrib/instrumentation/camping.rb +50 -0
  13. data/lib/rpm_contrib/instrumentation/cassandra.rb +30 -0
  14. data/lib/rpm_contrib/instrumentation/crack.rb +41 -0
  15. data/lib/rpm_contrib/instrumentation/curb.rb +52 -0
  16. data/lib/rpm_contrib/instrumentation/elastic_search.rb +26 -0
  17. data/lib/rpm_contrib/instrumentation/kyototycoon.rb +28 -0
  18. data/lib/rpm_contrib/instrumentation/mongo.rb +50 -0
  19. data/lib/rpm_contrib/instrumentation/paperclip.rb +29 -0
  20. data/lib/rpm_contrib/instrumentation/picky.rb +41 -0
  21. data/lib/rpm_contrib/instrumentation/redis.rb +42 -0
  22. data/lib/rpm_contrib/instrumentation/resque.rb +83 -0
  23. data/lib/rpm_contrib/instrumentation/riak_client.rb +48 -0
  24. data/lib/rpm_contrib/instrumentation/ripple.rb +37 -0
  25. data/lib/rpm_contrib/instrumentation/sinatra.rb +30 -0
  26. data/lib/rpm_contrib/instrumentation/thinking_sphinx.rb +22 -0
  27. data/lib/rpm_contrib/instrumentation/typhoeus.rb +33 -0
  28. data/lib/rpm_contrib/instrumentation/ultrasphinx.rb +22 -0
  29. data/lib/rpm_contrib/instrumentation/workling.rb +27 -0
  30. data/lib/rpm_contrib/instrumentation/yajl.rb +41 -0
  31. data/lib/rpm_contrib/instrumentation.rb +16 -0
  32. data/lib/rpm_contrib/language_support.rb +31 -0
  33. data/lib/rpm_contrib/samplers.rb +17 -0
  34. data/lib/rpm_contrib.rb +36 -0
  35. data/test/helper.rb +9 -0
  36. data/test/schema.rb +19 -0
  37. data/test/test_curb.rb +69 -0
  38. data/test/test_picky.rb +55 -0
  39. data/test/test_redis.rb +34 -0
  40. data/test/test_resque.rb +74 -0
  41. data/test/test_workling.rb +34 -0
  42. metadata +148 -0
data/CHANGELOG ADDED
@@ -0,0 +1,133 @@
1
+
2
+ * Version 2.1.6.1
3
+ - Merge upstream 2.1.6 with socialcast fork
4
+ - Avoid failures due to aws s3 instrumentation expecting a different flavor of aws s3
5
+
6
+ * Version 2.1.6
7
+ Community contributed instrumentation
8
+ - ThinkingSphinx instrumentation (W. Andrew Loe III)
9
+ - Riak instrumentation (Bryce Kerley)
10
+ - KyotoTycoon instrumentation (Keisuke Kawahara)
11
+ Community Contributed Bug Fixes
12
+ - MongoDB instrumentation (Kenn Ejima)
13
+ - Yajl instrumentation (Chris Griego)
14
+ - UltraSphinx instrumentation (Jonathan Rudenberg)
15
+ Renamed ActiveMQ instrumentation to ActiveMessaging (W. Andrew Loe III)
16
+
17
+ * Version 2.1.5
18
+
19
+ Changed the resque detection so it does not depend on the load
20
+ order of resque => rpm_contrib => newrelic_rpm. The gems can be
21
+ installed in any order.
22
+
23
+ * Version 2.1.4
24
+
25
+ Updated requirements to latest agent with some bug fixes for background jobs
26
+ Converted instrumentation to install with DependencyDetection in the latest Agent
27
+ Changed Resque instrumentation from a plugin back to method chaining
28
+ Fixed several reported bugs related to resque
29
+
30
+ * Version 2.1.3
31
+
32
+ Fixed typo in Resque instrumentation
33
+ Fixed double loading of AWS instrumentation
34
+
35
+ * Version 2.1.2
36
+
37
+ Add a manual shutdown to the Resque instrumentation to make sure data is saved and sent - thanks to Jade Rubick
38
+
39
+ * Version 2.1.1
40
+
41
+ Fix namespacing problem with Resque
42
+ Add instrumentation to Mongo::Cursor #refresh and #close - thanks to Chris Griego
43
+
44
+ * Version 2.1.0
45
+
46
+ Included instrumentation from the community:
47
+ - Alexey Palazhchenko - mongo ORM-agnostic instrumentation
48
+ - Michael Breen - Elastic Search
49
+ - Paul Ingles - Sinatra Template instrumentation
50
+ - Siddharth Dawara - Typhoeus instrumentation
51
+ - Rob Meyer - ActiveMQ instrumentation
52
+ - Greg Hazel - Curb instrumentation
53
+ - Ben Poweski - Crack and Yajl instrumentation
54
+ - Chad Ingram and Scott Fleckenstein - Workling instrumentation
55
+ - Adam Weller - UltraSphinx instrumentation
56
+ - Liron Yahdav - work on the Resque instrumentation
57
+
58
+ * Version 2.0.1
59
+
60
+ Fixed an error with Bundler and RubyGems 1.8.2 which caused the gem to always fail to load
61
+
62
+ * Version 2.0.0
63
+
64
+ Updated to use the latest version of the Ruby Agent
65
+
66
+ * Version 1.0.13
67
+
68
+ Removed use of 'metaclass' - no longer available from ActiveSupport as of Rails 3
69
+ Contributed by Chris Griego
70
+
71
+ * Version socialcast-1.0.12.7
72
+
73
+ Add support for resque jobs running in backgrounded
74
+
75
+ * Version 1.0.12
76
+
77
+ Better support for initialization within a Rails 3 application
78
+ rpm_contrib now depends on newrelic_rpm >= 2.13.1
79
+
80
+ * Version 1.0.11
81
+
82
+ AWS/S3 instrumentation contributed by Brian Doll
83
+ Cassandra instrumentation contributed by Ashley Martens
84
+ Updated Redis instrumentation for 1.x and 2.x contributed by Karl Baum
85
+
86
+ * Version 1.0.10
87
+
88
+ Mongoid support contributed by Karl Baum
89
+
90
+ * Version 1.0.9
91
+
92
+ Fixed dependency specification on newrelic_rpm
93
+
94
+ * Version 1.0.8
95
+
96
+ Redis instrumentation contributed by Ashley Martens
97
+ Authlogic moved into RPM Ruby Agent
98
+
99
+ * Version 1.0.7
100
+
101
+ Resque instrumentation now supports the resque-multi-job-forks plugin
102
+
103
+ * Version 1.0.6
104
+
105
+ Update newrelic dependency: depends on 2.11.1
106
+
107
+ * Version 1.0.5
108
+
109
+ Clear stats in forked resque jobs
110
+
111
+ * Version 1.0.4
112
+
113
+ Resque support
114
+
115
+ * Version 1.0.3
116
+
117
+ MongoDB instrumentation contributed by John Nunemaker
118
+
119
+ * Version 1.0.2
120
+
121
+ Improved Camping support
122
+
123
+ * Version 1.0.1
124
+
125
+ Removed DelayedJob, put back in core agent
126
+
127
+ * Version 1.0.0
128
+
129
+ Initial Release:
130
+ - Camping
131
+ - Authlogic
132
+ - DelayedJob
133
+ - Paperclip
data/Gemfile ADDED
@@ -0,0 +1,13 @@
1
+ source :rubygems
2
+
3
+ gem 'newrelic_rpm', '>=3.1.1'
4
+
5
+ group :test do
6
+ gem 'resque'
7
+ gem 'json'
8
+ gem 'mocha'
9
+ end
10
+
11
+ group :build do
12
+ gem 'jeweler'
13
+ end
data/LICENSE ADDED
@@ -0,0 +1,20 @@
1
+ Copyright (c) 2009-2010 New Relic, Inc.
2
+
3
+ Permission is hereby granted, free of charge, to any person obtaining
4
+ a copy of this software and associated documentation files (the
5
+ "Software"), to deal in the Software without restriction, including
6
+ without limitation the rights to use, copy, modify, merge, publish,
7
+ distribute, sublicense, and/or sell copies of the Software, and to
8
+ permit persons to whom the Software is furnished to do so, subject to
9
+ the following conditions:
10
+
11
+ The above copyright notice and this permission notice shall be
12
+ included in all copies or substantial portions of the Software.
13
+
14
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
15
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
16
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
17
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
18
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
19
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
20
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,293 @@
1
+ # The RPM Contrib Gem
2
+
3
+ The `rpm_contrib` gem contains instrumentation for the New Relic RPM agent
4
+ contributed by the community of RPM users. It requires the RPM Agent to run.
5
+
6
+ To use the rpm_contrib gem, install the `rpm_contrib` gem from rubygems.org.
7
+ It will also install the required version of the `newrelic_rpm` gem if it's not
8
+ already installed.
9
+
10
+ For Rails 3.0 and when using Bundler, add these dependencies to your Gemfile:
11
+
12
+ gem 'rpm_contrib'
13
+ gem 'newrelic_rpm'
14
+
15
+ For Rails 2.1 and later, add these dependencies to your in your environment.rb:
16
+
17
+ config.gem 'rpm_contrib'
18
+ config.gem 'newrelic_rpm'
19
+
20
+ For other frameworks, make sure you load rubygems if it isn't already, then just
21
+ require the rpm_contrib gem:
22
+
23
+ require 'rubygems'
24
+ require 'rpm_contrib'
25
+
26
+ When you load the rpm_contrib gem, the `newrelic_rpm` gem will also be
27
+ initialized. No need for a separate require statement for `newrelic_rpm`.
28
+
29
+ In non-Rails frameworks, it's important that the New Relic Agent gets
30
+ loaded as late as possible, or that the final initialization hook is called
31
+ after all other frameworks have loaded:
32
+
33
+ DependencyDetection.detect!
34
+
35
+ ### Troubleshooting Startup
36
+
37
+ If you've set up your gems to load as described above and you are still not seeing
38
+ data in RPM, there may be a bug in detecting your framework. Try setting the
39
+ environment variable `NEWRELIC_DISPATCHER` to the name of your app server (Camping,
40
+ Resque, Rake, etc), and please report to us if this fixes the problem so we can
41
+ fix the auto-detection logic.
42
+
43
+ If this does not help then set the `log_level` to `debug` in the `newrelic.yml` file
44
+ and examine the `newrelic_agent.log` file for errors after restarting your app.
45
+
46
+ ## Supported Frameworks
47
+
48
+ A number of frameworks are supported in the contrib gem. They are all turned on
49
+ by default but you can add settings to your newrelic.yml to disable any of them.
50
+
51
+ ### ActiveMessaging
52
+
53
+ The gem will detect the underlying ActiveMessaging::Processor class and instrument the `on_message` method
54
+
55
+ It can be disabled with the `disable_active_messaging` flag in your newrelic.yml file.
56
+
57
+ ### Cassandra
58
+
59
+ The gem will instrument Cassandra so it should be visible in transaction traces and the web transactions page.
60
+
61
+ You can disable it with `disable_cassandra_instrumentation` in your newrelic.yml file.
62
+
63
+ ### Camping
64
+
65
+ The gem will detect a Camping app but you need to manually add the
66
+ instrumentation to your configuration file. See
67
+ RPMContrib::Instrumentation::Camping for more information.
68
+
69
+ In addition you will need to load the gems in the following order: 1) Camping, 2) rpm_contrib,
70
+ 3) newrelic_rpm.
71
+
72
+ ### Crack
73
+
74
+ The gem will instrument the Crack parsers for JSON and XML - you
75
+ should see them in transaction traces and the web transactions page.
76
+
77
+ You can disable it with `disable_crack` in your newrelic.yml file.
78
+
79
+ ### Curb
80
+
81
+ The gem will instrument both Curl::Easy and Curl::Multi - they should show up similarly to Net::HTTP in the UI
82
+
83
+ You can disable it with `disable_curb` in your newrelic.yml file.
84
+
85
+ ## Elastic Search
86
+
87
+ The gem will instrument ElasticSearch::Client. The metrics should show up in the UI
88
+
89
+ You can disable it with `disable_elastic_search_instrumentation` in your newrelic.yml file.
90
+
91
+ ## KyotoTycoon
92
+
93
+ The gem will instrument KyotoTycoon.
94
+
95
+ You can disable it with `disable_kyototycoon` in your newrelic.yml file.
96
+
97
+ ### Paperclip
98
+
99
+ No special configuration required for Paperclip visibility.
100
+
101
+ You can disable it by setting `disable_paperclip` to true in your newrelic.yml file.
102
+
103
+ ### Picky
104
+
105
+ The gem will instrument the [Picky semantic search engine](http://florianhanke.com/picky/) so it should be visible in transaction traces and the web transactions page.
106
+
107
+ You can disable it with `disable_picky` in your newrelic.yml file.
108
+
109
+ ### MongoDB
110
+
111
+ Our instrumentation works on the underlying 'Mongo' library.
112
+
113
+ You can disable it by setting 'disable_mongodb' to true in your newrelic.yml file.
114
+
115
+ ### Resque
116
+
117
+ To instrument jobs you no longer need to have your Job class inherit from Resque::Job or include
118
+ the Resque::Plugins::NewRelicInstrumentation module. The module definition was left in for
119
+ backward compatibility.
120
+
121
+ To disable resque, set 'disable_resque' to true in your newrelic.yml file.
122
+
123
+ ### Redis
124
+
125
+ Redis instrumentation will record operations as well as `allWeb` and `allOther`
126
+ summary metrics under the `Database/Redis` metric namespace. This instrumentation
127
+ supports Redis versions 1.x and 2.x.
128
+
129
+ To disable Redis instrumentation, set 'disable_redis' to true in your newrelic.yml file.
130
+
131
+ ### Riak
132
+
133
+ RiakClient is instrumented. Its opereations are recorded under Database in the
134
+ the response time graph.
135
+
136
+ To disable Riak instrumentation, set 'disable_riak_client' to true in your newrelic.yml file.
137
+
138
+ ### Ripple
139
+
140
+ Ripple is instrumented. Its opereations are recorded under Database in the
141
+ the response time graph.
142
+
143
+ To disable Riak instrumentation, set 'disable_ripple' to true in your newrelic.yml file.
144
+
145
+ ### Sinatra view instrumentation
146
+
147
+ This adds instrumentation to the `render` methods in Sinatra::Base
148
+
149
+ You can disable it with `disable_sinatra_template` in your newrelic.yml file.
150
+
151
+ ### ThinkingSphinx instrumentation
152
+
153
+ This adds instrumentation to the `initialize` and `results` method of ThinkingSphinx::Search
154
+
155
+ You can disable it with `disable_thinking_sphinx` in your newrelic.yml file.
156
+
157
+
158
+ ### Typhoeus instrumentation
159
+
160
+ This adds instrumentation to the Typhoeus::Request class for 'GET' requests
161
+
162
+ You can disable it with `disable_typhoeus` in your newrelic.yml file.
163
+
164
+ ### Ultrasphinx instrumentation
165
+
166
+ This adds basic instrumentation to the `run` and `results` method of Ultrasphinx::Search
167
+
168
+ You can disable it with `disable_ultrasphinx` in your newrelic.yml file.
169
+
170
+ ### Workling
171
+
172
+ This adds instrumentation to the Workling::Base and all children, for all defined public methods not inherited from the Workling::Base class
173
+
174
+ You can disable it with `disable_workling` in your newrelic.yml file.
175
+
176
+ ### YAJL
177
+
178
+ This adds instrumentation to the YAJL json parser
179
+
180
+ You can disable it with `disable_yajl_instrumentation` in your newrelic.yml file.
181
+
182
+ ### AWS/S3
183
+
184
+ Get metrics on how S3 is performing for you in production. To disable AWS/S3, set
185
+ 'disable_aws-s3' to true in your newrelic.yml file. For more information on this
186
+ instrumentation, check out [our blog](http://blog.newrelic.com/2010/07/06/monitoring-aws-s3/).
187
+
188
+ # How to Add Custom Instrumentation
189
+
190
+ We encourage contributions to this project and will provide whatever assistance
191
+ we can to those wishing to develop instrumentation for other open source Ruby
192
+ libraries.
193
+
194
+ When adding instrumentation to this gem, be sure and get familiar with the [RPM
195
+ Agent API](http://newrelic.github.com/rpm/classes/NewRelic/Agent.html) and
196
+ contact support@newrelic.com with any questions.
197
+
198
+ There are several extension points in the agent you can take advantage of with
199
+ this gem.
200
+
201
+ * Custom tracers which measure methods and give visibility to
202
+ otherwise unmeasured libraries.
203
+ * Samplers which sample some value about once a minute.
204
+ * Dispatcher support for web request handlers which would otherwise be undetected.
205
+ In order for the agent to turn on in 'auto' mode it needs to discover a
206
+ web dispatcher, or be [started manually](http://support.newrelic.com/faqs/general/manual-start).
207
+ * Framework support, for alternatives to Rails like Camping or Ramaze
208
+
209
+ ## Custom Tracers
210
+
211
+ Custom tracers for frameworks should be added to the `lib/rpm_contrib/instrumentation`
212
+ directory. These files are loaded at the time the Agent starts. **They will not
213
+ be loaded if the Agent does not start up.**
214
+
215
+ It is important that you wrap any instrumentation with the checks necessary to
216
+ determine if the code being instrumented is loaded. You can't add code to the
217
+ contrib gem that will break when run in any other context besides yours.
218
+
219
+
220
+ For details on how to define custom tracers, refer to the [support documentation
221
+ on adding custom
222
+ tracers](http://support.newrelic.com/faqs/docs/custom-metric-collection). You
223
+ can also get detailed information on the API from the [Agent method tracing
224
+ rdocs](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer.html),
225
+ especially the
226
+ [add_method_tracer](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer/ClassMethods.html)
227
+ docs.
228
+
229
+ A good example can be found in `lib/rpm_contrib/instrumentation/paperclip.rb`.
230
+
231
+ ## Samplers
232
+
233
+ You can add samplers which will record metrics approximately once a minute.
234
+ Samplers are useful for capturing generic instrumentation for display in [custom
235
+ views](http://support.newrelic.com/faqs/docs/custom-dashboard-specification).
236
+
237
+ Samplers should extend the
238
+ [`NewRelic::Agent::Sampler`](http://newrelic.github.com/rpm/classes/NewRelic/Agent/Sampler.html)
239
+ class. They should be placed in the `samplers` directory.
240
+
241
+ Refer to examples in the RPM agent to see how to get started.
242
+
243
+ ## Supporting New Dispatchers
244
+
245
+ If you want to add support for a new dispatcher which is not being recognized by
246
+ default by the RPM agent, add code to the `rpm_contrib/detection` directory.
247
+ This code needs to define a module in the `NewRelic::LocalEnvironment` class.
248
+ This module will be accessed at the time environment detection takes place, when
249
+ the agent is initialized.
250
+
251
+ This module should define the method `discover_dispatcher` and return the name
252
+ of the dispatcher if detected, or defer to super. See
253
+ `rpm_contrib/detection/camping.rb` for a good example.
254
+
255
+ ## Supporting New Frameworks
256
+
257
+ Supporting new frameworks can be pretty involved and generally involves both
258
+ adding custom instrumentation as well as framework and dispatcher detection.
259
+
260
+ In addition it will be necessary to define a new control class with the same
261
+ name as the framework. This control class must go in `new_relic/control`.
262
+
263
+ Refer to the camping example in this gem to see how this is done in general.
264
+
265
+ If you decide to tackle any new frameworks, contact support@newrelic.com and
266
+ we'll be happy to help you work through it.
267
+
268
+ # Note on Patches/Pull Requests
269
+
270
+ * Fork the http://www.github.com/newrelic/rpm_contrib project.
271
+ * Add instrumentation files to `lib/rpm_contrib/instrumentation`. These
272
+ files will be loaded when the RPM agent is initialized.
273
+ * Add samplers to `lib/rpm_contrib/samplers`. These classes are
274
+ installed automatically when the RPM agent is initialized.
275
+ * Add tests.
276
+ * Update README.md
277
+ * Commit, do not mess with the Rakefile, version, or history. (if you
278
+ want to have your own version, that is fine but bump version in a
279
+ commit by itself I can ignore when I pull)
280
+ * Send me a pull request. Bonus points for topic branches.
281
+
282
+ # Further Information
283
+
284
+ Refer to the Agent API Documentation at http://newrelic.github.com/rpm
285
+
286
+ See the support site faqs at http://support.newrelic.com/faqs for additional
287
+ tips and documentation.
288
+
289
+ Contact support@newrelic.com for help.
290
+
291
+ ### Copyright
292
+
293
+ Copyright (c) 2009-2010 New Relic. See LICENSE for details.
data/Rakefile ADDED
@@ -0,0 +1,79 @@
1
+ require 'rubygems'
2
+ require "bundler/setup"
3
+ require 'rake'
4
+ # See http://www.rubygems.org/read/chapter/20
5
+
6
+ def version
7
+ @rpm_contrib_version ||= File.read("CHANGELOG")[/Version ([\d\.]+\w*)$/, 1]
8
+ end
9
+
10
+ RDOC_FILES = FileList['README*','LICENSE','CHANGELOG']
11
+ SUMMARY = "Contributed Instrumentation for New Relic RPM"
12
+ DESCRIPTION = <<-EOF
13
+ Community contributed instrumentation for various frameworks based on
14
+ the New Relic Ruby monitoring gem newrelic_rpm.
15
+ EOF
16
+
17
+ begin
18
+ require 'jeweler'
19
+ Jeweler::Tasks.new do |gem|
20
+ gem.name = "seanwalbran-rpm_contrib"
21
+ gem.summary = SUMMARY
22
+ gem.description = DESCRIPTION
23
+ gem.email = "support@newrelic.com"
24
+ gem.homepage = "http://github.com/newrelic/rpm_contrib"
25
+ gem.authors = [ "Bill Kayser", "Jon Guymon" ]
26
+ gem.add_dependency 'newrelic_rpm', '>=3.1.1'
27
+ gem.version = version
28
+ gem.files = FileList['LICENSE', 'README*', 'lib/**/*.rb', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
29
+ gem.files.exclude *File.read(File.join(File.dirname(__FILE__), '.gitignore')).split
30
+ gem.rdoc_options <<
31
+ "--line-numbers" <<
32
+ "--inline-source" <<
33
+ "--title" << SUMMARY <<
34
+ "-m" << "README.md"
35
+ gem.extra_rdoc_files = RDOC_FILES
36
+ end
37
+ Jeweler::GemcutterTasks.new
38
+ rescue LoadError
39
+ puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
40
+ end
41
+
42
+ require 'rake/testtask'
43
+ Rake::TestTask.new(:test) do |test|
44
+ test.libs << 'lib' << 'test'
45
+ test.pattern = 'test/**/test_*.rb'
46
+ test.verbose = true
47
+ end
48
+
49
+ begin
50
+ require 'rcov/rcovtask'
51
+ Rcov::RcovTask.new do |test|
52
+ test.libs << 'test'
53
+ test.pattern = 'test/**/test_*.rb'
54
+ test.verbose = true
55
+ end
56
+ rescue LoadError
57
+ task :rcov do
58
+ abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
59
+ end
60
+ end
61
+
62
+ #task :test => :check_dependencies
63
+
64
+ task :default => :test
65
+
66
+ require 'rake/rdoctask'
67
+ Rake::RDocTask.new do |rdoc|
68
+ rdoc.rdoc_dir = 'rdoc'
69
+ rdoc.title = "rpm_contrib #{version}"
70
+ rdoc.main = "README.md"
71
+ rdoc.rdoc_files = FileList['lib/**/*.rb'] + RDOC_FILES
72
+ rdoc.inline_source = true
73
+ end
74
+
75
+ begin
76
+ require 'sdoc_helpers'
77
+ rescue LoadError
78
+ puts "sdoc support not enabled. Please gem install sdoc-helpers."
79
+ end
@@ -0,0 +1,14 @@
1
+ require 'new_relic/control/ruby'
2
+ # This is the framework control object for Camping apps.
3
+ # It is loaded by virtue of detecting 'camping' as the framework
4
+ # in the rpm_contrib/detection/camping.rb file. It gets loaded
5
+ # by the new_relic/control.rb file.
6
+ class NewRelic::Control #:nodoc:
7
+ class Camping < NewRelic::Control::Ruby
8
+ def init_config(options)
9
+ super
10
+ @local_env.dispatcher = 'camping'
11
+ self['app_name'] ||= 'Camping Application'
12
+ end
13
+ end
14
+ end
@@ -0,0 +1,11 @@
1
+ if NewRelic::VERSION::STRING < '3.2.0'
2
+ module DependencyDetection
3
+ def self.dependency_by_name(name)
4
+ @@items.find {|i| i.name == name }
5
+ end
6
+
7
+ class Dependent
8
+ attr_reader :name
9
+ end
10
+ end
11
+ end
@@ -0,0 +1,24 @@
1
+ module NewRelic #:nodoc:
2
+ # The class defined in the
3
+ # newrelic_rpm[http://newrelic.github.com/rpm] which can be amended
4
+ # to support new frameworks by defining modules in this namespace.
5
+ class LocalEnvironment #:nodoc:
6
+ module Camping
7
+ def discover_framework
8
+ if defined?(::Camping)
9
+ puts "framework is camping"
10
+ @framework = 'camping'
11
+ else
12
+ super
13
+ end
14
+ end
15
+ def discover_dispatcher
16
+ super
17
+ if defined?(::Camping) && @dispatcher.nil?
18
+ @dispatcher = 'camping'
19
+ end
20
+ end
21
+ end
22
+ end
23
+ end
24
+
@@ -0,0 +1,5 @@
1
+ # Currently the only framework we are detecting with an agent
2
+ # patch is camping. You need to specify the camping gem prior
3
+ # to the contrib gem and newrelic agent gem in order for this to work.
4
+ require 'rpm_contrib/detection/camping'
5
+
@@ -0,0 +1,22 @@
1
+ # ActiveMessaging Instrumentation
2
+
3
+ DependencyDetection.defer do
4
+ @name = :active_messaging
5
+
6
+ depends_on do
7
+ defined?(::ActiveMessaging::Processor) && !NewRelic::Control.instance['disable_active_messaging'] &&
8
+ !NewRelic::Control.instance['disable_active_mq']
9
+ end
10
+
11
+ executes do
12
+ NewRelic::Agent.logger.debug 'Installing ActiveMessaging instrumentation'
13
+ end
14
+
15
+ executes do
16
+ ::ActiveMessaging::Processor.class_eval do
17
+ include NewRelic::Agent::MethodTracer
18
+
19
+ add_method_tracer :on_message, 'ActiveMessaging/OnMessage'
20
+ end
21
+ end
22
+ end
@@ -0,0 +1,68 @@
1
+ # AWS Instrumentation by Brian Doll of New Relic
2
+ DependencyDetection.defer do
3
+ @name = :aws
4
+
5
+ depends_on do
6
+ defined?(::AWS::S3) && defined?(::AWS::S3::Connection) && !NewRelic::Control.instance['disable_aws-s3']
7
+ end
8
+
9
+ executes do
10
+ NewRelic::Agent.logger.debug 'Installing AWS instrumentation'
11
+ end
12
+
13
+
14
+ executes do
15
+ # Instrument connections to the AWS-S3 service
16
+ ::AWS::S3::Connection::Management::ClassMethods.module_eval do
17
+ add_method_tracer :establish_connection!, 'AWS-S3/establish_connection!'
18
+ end
19
+
20
+ # Instrument methods on Bucket
21
+ ::AWS::S3::Bucket.instance_eval do
22
+ class << self
23
+ add_method_tracer :create, 'AWS-S3/Bucket/create'
24
+ add_method_tracer :find, 'AWS-S3/Bucket/find'
25
+ add_method_tracer :objects, 'AWS-S3/Bucket/objects'
26
+ add_method_tracer :delete, 'AWS-S3/Bucket/delete'
27
+ add_method_tracer :list, 'AWS-S3/Bucket/list'
28
+ end
29
+ end
30
+
31
+ # Instrument methods on Bucket instances
32
+ ::AWS::S3::Bucket.class_eval do
33
+ add_method_tracer :[], 'AWS-S3/Bucket/#{self.name}/[]'
34
+ add_method_tracer :new_object,'AWS-S3/Bucket/#{self.name}/new_objects'
35
+ add_method_tracer :objects, 'AWS-S3/Bucket/#{self.name}/objects'
36
+ add_method_tracer :delete, 'AWS-S3/Bucket/#{self.name}/delete'
37
+ add_method_tracer :delete_all,'AWS-S3/Bucket/#{self.name}/delete_all'
38
+ add_method_tracer :update, 'AWS-S3/Bucket/#{self.name}/update'
39
+ end
40
+
41
+ # Instrument methods on S3Object
42
+ ::AWS::S3::S3Object.instance_eval do
43
+ class << self
44
+ add_method_tracer :about, 'AWS-S3/S3Object/about'
45
+ add_method_tracer :copy, 'AWS-S3/S3Object/copy'
46
+ add_method_tracer :delete, 'AWS-S3/S3Object/delete'
47
+ add_method_tracer :rename, 'AWS-S3/S3Object/rename'
48
+ add_method_tracer :store, 'AWS-S3/S3Object/store'
49
+ end
50
+ end
51
+
52
+ # Instrument methods on S3Object instances
53
+ # Metric names are aggregated across all S3Objects since having a metric for
54
+ # every single S3Object instance and method pair would be fairly useless
55
+ ::AWS::S3::S3Object.class_eval do
56
+ add_method_tracer :value, 'AWS-S3/S3Objects/value'
57
+ add_method_tracer :about, 'AWS-S3/S3Objects/about'
58
+ add_method_tracer :metadata, 'AWS-S3/S3Objects/metadata'
59
+ add_method_tracer :store, 'AWS-S3/S3Objects/store'
60
+ add_method_tracer :delete, 'AWS-S3/S3Objects/delete'
61
+ add_method_tracer :copy, 'AWS-S3/S3Objects/copy'
62
+ add_method_tracer :rename, 'AWS-S3/S3Objects/rename'
63
+ add_method_tracer :etag, 'AWS-S3/S3Objects/etag'
64
+ add_method_tracer :owner, 'AWS-S3/S3Objects/owner'
65
+ end
66
+ end
67
+ end
68
+