staugaard-rpm_contrib 1.0.7
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/CHANGELOG +35 -0
- data/LICENSE +20 -0
- data/README.md +147 -0
- data/Rakefile +62 -0
- data/lib/new_relic/control/camping.rb +12 -0
- data/lib/rpm_contrib.rb +34 -0
- data/lib/rpm_contrib/detection/camping.rb +23 -0
- data/lib/rpm_contrib/detection/resque.rb +15 -0
- data/lib/rpm_contrib/instrumentation/authlogic.rb +8 -0
- data/lib/rpm_contrib/instrumentation/camping.rb +53 -0
- data/lib/rpm_contrib/instrumentation/mongodb.rb +40 -0
- data/lib/rpm_contrib/instrumentation/paperclip.rb +22 -0
- data/lib/rpm_contrib/instrumentation/resque.rb +34 -0
- data/test/helper.rb +12 -0
- data/test/schema.rb +19 -0
- data/test/test_rpm_contrib.rb +7 -0
- metadata +93 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
* Version 1.0.7
|
2
|
+
|
3
|
+
Resque instrumentation now supports the resque-multi-job-forks plugin
|
4
|
+
|
5
|
+
* Version 1.0.6
|
6
|
+
|
7
|
+
Update newrelic dependency: depends on 2.11.1
|
8
|
+
|
9
|
+
* Version 1.0.5
|
10
|
+
|
11
|
+
Clear stats in forked resque jobs
|
12
|
+
|
13
|
+
* Version 1.0.4
|
14
|
+
|
15
|
+
Resque support
|
16
|
+
|
17
|
+
* Version 1.0.3
|
18
|
+
|
19
|
+
MongoDB instrumentation contributed by John Nunemaker
|
20
|
+
|
21
|
+
* Version 1.0.2
|
22
|
+
|
23
|
+
Improved Camping support
|
24
|
+
|
25
|
+
* Version 1.0.1
|
26
|
+
|
27
|
+
Removed DelayedJob, put back in core agent
|
28
|
+
|
29
|
+
* Version 1.0.0
|
30
|
+
|
31
|
+
Initial Release:
|
32
|
+
- Camping
|
33
|
+
- Authlogic
|
34
|
+
- DelayedJob
|
35
|
+
- Paperclip
|
data/LICENSE
ADDED
@@ -0,0 +1,20 @@
|
|
1
|
+
Copyright (c) 2009 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,147 @@
|
|
1
|
+
# The RPM Contrib Gem
|
2
|
+
|
3
|
+
The `rpm_contrib` gem contains instrumentation for the New Relic RPM
|
4
|
+
agent contributed by the community of RPM users. It requires the RPM
|
5
|
+
Agent to run.
|
6
|
+
|
7
|
+
To use the contrib gem, install the `rpm_contrib` gem from gemcutter.
|
8
|
+
It will also install the required version of the `newrelic_rpm` gem if
|
9
|
+
it's not already installed.
|
10
|
+
|
11
|
+
For Rails 2.1 and later, add this dependency to your in your
|
12
|
+
environment.rb:
|
13
|
+
|
14
|
+
config.gem 'rpm_contrib'
|
15
|
+
|
16
|
+
For other frameworks, make sure you load rubygems if it isn't already,
|
17
|
+
then just require the contrib gem:
|
18
|
+
|
19
|
+
require 'rubygems'
|
20
|
+
require 'rpm_contrib'
|
21
|
+
|
22
|
+
When you load the rpm_contrib gem, the `newrelic_rpm` gem will also be
|
23
|
+
initialized. No need for a separate require statement for
|
24
|
+
`newrelic_rpm`. The `rpm_contrib` gem must be loaded before the
|
25
|
+
`newrelic_rpm` gem initializes.
|
26
|
+
|
27
|
+
# Supported Frameworks
|
28
|
+
|
29
|
+
A number of frameworks are supported in the contrib gem. They are all
|
30
|
+
turned on by default but you can add settings to your newrelic.yml to
|
31
|
+
disable any of them.
|
32
|
+
|
33
|
+
### Camping
|
34
|
+
|
35
|
+
### Paperclip
|
36
|
+
|
37
|
+
### Authlogic
|
38
|
+
|
39
|
+
### MongoDB
|
40
|
+
|
41
|
+
### Resque
|
42
|
+
|
43
|
+
To disable resque, add this to your newrelic.yml:
|
44
|
+
|
45
|
+
disable_resque: true
|
46
|
+
|
47
|
+
|
48
|
+
# How to Add Custom Instrumentation
|
49
|
+
|
50
|
+
We encourage contributions to this project and will provide whatever
|
51
|
+
assistance we can to those wishing to develop instrumentation for
|
52
|
+
other open source Ruby libraries.
|
53
|
+
|
54
|
+
When adding instrumentation to this gem, be sure and get familiar with the
|
55
|
+
[RPM Agent API](http://newrelic.github.com/rpm/classes/NewRelic/Agent.html)
|
56
|
+
and contact support@newrelic.com with any questions.
|
57
|
+
|
58
|
+
There are several extension points in the agent you can take advantage of
|
59
|
+
with this gem.
|
60
|
+
|
61
|
+
* Custom tracers which measure methods and give visibility to
|
62
|
+
otherwise unmeasured libraries.
|
63
|
+
* Samplers which sample some value about once a minute.
|
64
|
+
* Dispatcher support for web request handlers which would otherwise be undetected.
|
65
|
+
In order for the agent to turn on in 'auto' mode it needs to discover a
|
66
|
+
web dispatcher, or be [started manually](http://support.newrelic.com/faqs/general/manual-start).
|
67
|
+
* Framework support, for alternatives to Rails like Camping or Ramaze
|
68
|
+
|
69
|
+
## Custom Tracers
|
70
|
+
|
71
|
+
Custom tracers for frameworks should be added to the `lib/rpm_contrib/instrumentation`
|
72
|
+
directory. These files are loaded at the time the Agent starts. **They will not
|
73
|
+
be loaded if the Agent does not start up.**
|
74
|
+
|
75
|
+
It is important that you wrap any instrumentation with the checks necessary
|
76
|
+
to determine if the code being instrumented is loaded. You can't add code to the
|
77
|
+
contrib gem that will break when run in any other context besides yours.
|
78
|
+
|
79
|
+
|
80
|
+
For details on how to define custom tracers, refer to the [support documentation on adding
|
81
|
+
custom tracers](http://support.newrelic.com/faqs/docs/custom-metric-collection). You
|
82
|
+
can also get detailed information on the API from the
|
83
|
+
[Agent method tracing rdocs](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer.html),
|
84
|
+
especially the [add_method_tracer](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer/ClassMethods.html)
|
85
|
+
docs.
|
86
|
+
|
87
|
+
A good example can be found in `lib/rpm_contrib/instrumentation/paperclip.rb`.
|
88
|
+
|
89
|
+
## Samplers
|
90
|
+
|
91
|
+
You can add samplers which will record metrics approximately once a minute. Samplers
|
92
|
+
are useful for capturing generic instrumentation for display in
|
93
|
+
[custom views](http://support.newrelic.com/faqs/docs/custom-dashboard-specification).
|
94
|
+
|
95
|
+
Samplers should extend the [`NewRelic::Agent::Sampler`](http://newrelic.github.com/rpm/classes/NewRelic/Agent/Sampler.html)
|
96
|
+
class. They should be placed in the `samplers` directory.
|
97
|
+
|
98
|
+
Refer to examples in the RPM agent to see how to get started.
|
99
|
+
|
100
|
+
## Supporting New Dispatchers
|
101
|
+
|
102
|
+
If you want to add support for a new dispatcher which is not being recognized by default
|
103
|
+
by the RPM agent, add code to the `rpm_contrib/detection` directory. This code needs
|
104
|
+
to define a module in the `NewRelic::LocalEnvironment` class. This module will be
|
105
|
+
accessed at the time environment detection takes place, when the agent is initialized.
|
106
|
+
|
107
|
+
This module should define the method `discover_dispatcher` and return the name of the
|
108
|
+
dispatcher if detected, or defer to super. See `rpm_contrib/detection/camping.rb`
|
109
|
+
for a good example.
|
110
|
+
|
111
|
+
## Supporting New Frameworks
|
112
|
+
|
113
|
+
Supporting new frameworks can be pretty involved and generally involves both
|
114
|
+
adding custom instrumentation as well as framework and dispatcher detection.
|
115
|
+
|
116
|
+
In addition it will be necessary to define a new control class with the same
|
117
|
+
name as the framework. This control class must go in `new_relic/control`.
|
118
|
+
|
119
|
+
Refer to the camping example in this gem to see how this is done in general.
|
120
|
+
|
121
|
+
If you decide to tackle any new frameworks, contact support@newrelic.com and
|
122
|
+
we'll be happy to help you work through it.
|
123
|
+
|
124
|
+
# Note on Patches/Pull Requests
|
125
|
+
|
126
|
+
* Fork the http://www.github.com/newrelic/rpm_contrib project.
|
127
|
+
* Add instrumentation files to `lib/rpm_contrib/instrumentation`. These
|
128
|
+
files will be loaded when the RPM agent is initialized.
|
129
|
+
* Add samplers to `lib/rpm_contrib/samplers`. These classes are
|
130
|
+
installed automatically when the RPM agent is initialized.
|
131
|
+
* Add tests.
|
132
|
+
* Commit, do not mess with the Rakefile, version, or history. (if you
|
133
|
+
want to have your own version, that is fine but bump version in a
|
134
|
+
commit by itself I can ignore when I pull)
|
135
|
+
* Send me a pull request. Bonus points for topic branches.
|
136
|
+
|
137
|
+
# Further Information
|
138
|
+
|
139
|
+
Refer to the [Agent API Documentation](http://newrelic.github.com/rpm).
|
140
|
+
|
141
|
+
See [the support site](http://support.newrelic.com/faqs) for additional tips and documentation.
|
142
|
+
|
143
|
+
Contact support@newrelic.com for help.
|
144
|
+
|
145
|
+
### Copyright
|
146
|
+
|
147
|
+
Copyright (c) 2010 New Relic. See LICENSE for details.
|
data/Rakefile
ADDED
@@ -0,0 +1,62 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'rake'
|
3
|
+
# See http://www.rubygems.org/read/chapter/20
|
4
|
+
|
5
|
+
def version
|
6
|
+
@rpm_contrib_version ||= File.read("CHANGELOG")[/Version ([\d\.]+)$/, 1]
|
7
|
+
end
|
8
|
+
|
9
|
+
begin
|
10
|
+
require 'jeweler'
|
11
|
+
Jeweler::Tasks.new do |gem|
|
12
|
+
gem.name = "staugaard-rpm_contrib"
|
13
|
+
gem.summary = %Q{Contributed Instrumentation for New Relic RPM}
|
14
|
+
gem.description = <<-EOF
|
15
|
+
Community contributed instrumentation for various frameworks based on
|
16
|
+
the New Relic Ruby monitoring gem newrelic_rpm.
|
17
|
+
EOF
|
18
|
+
gem.email = "support@newrelic.com"
|
19
|
+
gem.homepage = "http://github.com/newrelic/rpm_contrib"
|
20
|
+
gem.author = "Bill Kayser"
|
21
|
+
gem.add_dependency 'newrelic_rpm', '2.11.1'
|
22
|
+
gem.version = version
|
23
|
+
gem.files = FileList['LICENSE', 'README*', 'lib/**/*.rb', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
|
24
|
+
end
|
25
|
+
Jeweler::GemcutterTasks.new
|
26
|
+
rescue LoadError
|
27
|
+
puts "Jeweler (or a dependency) not available. Install it with: gem install jeweler"
|
28
|
+
end
|
29
|
+
|
30
|
+
require 'rake/testtask'
|
31
|
+
Rake::TestTask.new(:test) do |test|
|
32
|
+
test.libs << 'lib' << 'test'
|
33
|
+
test.pattern = 'test/**/test_*.rb'
|
34
|
+
test.verbose = true
|
35
|
+
end
|
36
|
+
|
37
|
+
begin
|
38
|
+
require 'rcov/rcovtask'
|
39
|
+
Rcov::RcovTask.new do |test|
|
40
|
+
test.libs << 'test'
|
41
|
+
test.pattern = 'test/**/test_*.rb'
|
42
|
+
test.verbose = true
|
43
|
+
end
|
44
|
+
rescue LoadError
|
45
|
+
task :rcov do
|
46
|
+
abort "RCov is not available. In order to run rcov, you must: sudo gem install spicycode-rcov"
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
task :test => :check_dependencies
|
51
|
+
|
52
|
+
task :default => :test
|
53
|
+
|
54
|
+
require 'rake/rdoctask'
|
55
|
+
Rake::RDocTask.new do |rdoc|
|
56
|
+
rdoc.rdoc_dir = 'rdoc'
|
57
|
+
rdoc.title = "rpm_contrib #{version}"
|
58
|
+
rdoc.rdoc_files.include('README*')
|
59
|
+
rdoc.rdoc_files.include('LICENSE')
|
60
|
+
rdoc.rdoc_files.include('CHANGELOG')
|
61
|
+
rdoc.rdoc_files.include('lib/**/*.rb')
|
62
|
+
end
|
@@ -0,0 +1,12 @@
|
|
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::Camping < NewRelic::Control::Ruby
|
7
|
+
def init_config(options)
|
8
|
+
super
|
9
|
+
@local_env.dispatcher = 'camping'
|
10
|
+
self['app_name'] ||= 'Camping Application'
|
11
|
+
end
|
12
|
+
end
|
data/lib/rpm_contrib.rb
ADDED
@@ -0,0 +1,34 @@
|
|
1
|
+
|
2
|
+
RPM_CONTRIB_LIB = File.dirname(__FILE__)
|
3
|
+
|
4
|
+
module RPMContrib
|
5
|
+
VERSION = File.read(RPM_CONTRIB_LIB+"/../CHANGELOG")[/Version ([\d\.]+)$/, 1]
|
6
|
+
end
|
7
|
+
|
8
|
+
# Perform any framework/dispatcher detection before loading the rpm
|
9
|
+
# gem.
|
10
|
+
|
11
|
+
raise "The rpm_contrib gem must be loaded before the newrelic_rpm gem." if defined?(::NewRelic)
|
12
|
+
|
13
|
+
Dir.glob(RPM_CONTRIB_LIB + "/rpm_contrib/detection/**/*.rb") { |file| require file }
|
14
|
+
|
15
|
+
require 'newrelic_rpm'
|
16
|
+
|
17
|
+
init_sequence = Proc.new do
|
18
|
+
|
19
|
+
# Tell the agent to load all the files in the
|
20
|
+
# rpm_contrib/instrumentation directory.
|
21
|
+
NewRelic::Agent.add_instrumentation(RPM_CONTRIB_LIB+"/rpm_contrib/instrumentation/**/*.rb")
|
22
|
+
|
23
|
+
# Load all the Sampler class definitions. These will register
|
24
|
+
# automatically with the agent.
|
25
|
+
Dir.glob(RPM_CONTRIB_LIB + "/rpm_contrib/samplers/**/*.rb") { |file| require file }
|
26
|
+
end
|
27
|
+
|
28
|
+
if defined?(Rails.configuration)
|
29
|
+
Rails.configuration.after_initialize &init_sequence
|
30
|
+
else
|
31
|
+
init_sequence.call
|
32
|
+
end
|
33
|
+
|
34
|
+
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# Detect when running under camping and set the framework and dispatcher.
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
class LocalEnvironment
|
5
|
+
module Camping
|
6
|
+
def discover_framework
|
7
|
+
if defined?(::Camping)
|
8
|
+
puts "framework is camping"
|
9
|
+
@framework = 'camping'
|
10
|
+
else
|
11
|
+
super
|
12
|
+
end
|
13
|
+
end
|
14
|
+
def discover_dispatcher
|
15
|
+
super
|
16
|
+
if defined?(::Camping) && @dispatcher.nil?
|
17
|
+
@dispatcher = 'camping'
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# Detect when running under camping and set the framework and dispatcher.
|
2
|
+
|
3
|
+
module NewRelic
|
4
|
+
class LocalEnvironment
|
5
|
+
module Resque
|
6
|
+
def discover_dispatcher
|
7
|
+
super
|
8
|
+
if defined?(::Resque::Worker) && @dispatcher.nil?
|
9
|
+
@dispatcher = 'resque'
|
10
|
+
end
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
@@ -0,0 +1,53 @@
|
|
1
|
+
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
2
|
+
|
3
|
+
module RPMContrib
|
4
|
+
module Instrumentation
|
5
|
+
# == Instrumentation for Camping
|
6
|
+
# To instrument all controllers do the following:
|
7
|
+
# 1. Add require 'rpm_contrib' after loading camping.
|
8
|
+
# 2. Add an include at the end of your main Camping app module
|
9
|
+
# 3. Run the following command to get the NewRelic license key to use: heroku config -all
|
10
|
+
# 4. Create a newrelic.yml under the /config folder with the following content:
|
11
|
+
#
|
12
|
+
# common: &default_settings
|
13
|
+
# license_key: 'PASTE THE VALUE OF NEW_RELIC_LICENSE_KEY HERE'
|
14
|
+
# app_name: PASTE THE NAME OF YOUR CAMPING APP HERE
|
15
|
+
# monitor_mode: true
|
16
|
+
#
|
17
|
+
# production:
|
18
|
+
# <<: *default_settings
|
19
|
+
#
|
20
|
+
# Camping code example:
|
21
|
+
# -------------------------------------------------------------------------------------
|
22
|
+
#
|
23
|
+
# require "newrelic_rpm"
|
24
|
+
#
|
25
|
+
# Camping.goes :NewRelicCampingTest
|
26
|
+
#
|
27
|
+
# module NewRelicCampingTest
|
28
|
+
# # your code
|
29
|
+
#
|
30
|
+
# include NewRelic::Agent::Instrumentation::Camping
|
31
|
+
#
|
32
|
+
# end
|
33
|
+
#
|
34
|
+
#
|
35
|
+
|
36
|
+
module Camping
|
37
|
+
|
38
|
+
def self.included(mod)
|
39
|
+
|
40
|
+
# Since the Camping::Base module is essentially copied
|
41
|
+
# into the main module (the mod passed in) of a Camping app
|
42
|
+
# using the Camping.goes :NewRelicCampingTest syntax
|
43
|
+
# we need to evaluate "weld" the NewRelic plugin in the context of the new Base
|
44
|
+
|
45
|
+
(Kernel.const_get(mod.name)::Base).module_eval do
|
46
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
47
|
+
add_transaction_tracer :service
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
end #RPMContrib::Instrumentation::Camping
|
52
|
+
end
|
53
|
+
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
|
@@ -0,0 +1,22 @@
|
|
1
|
+
# Paperclip Instrumentation.
|
2
|
+
|
3
|
+
if defined? ::Paperclip
|
4
|
+
|
5
|
+
::Paperclip::Attachment.class_eval do
|
6
|
+
add_method_tracer :save, 'Paperclip/#{name}/save'
|
7
|
+
add_method_tracer :assign, 'Paperclip/#{name}/assign'
|
8
|
+
add_method_tracer :post_process, 'Paperclip/#{name}/post_process'
|
9
|
+
end
|
10
|
+
|
11
|
+
::Paperclip::Storage::Filesystem.class_eval do
|
12
|
+
add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
|
13
|
+
add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
|
14
|
+
end
|
15
|
+
|
16
|
+
::Paperclip::Storage::S3.class_eval do
|
17
|
+
add_method_tracer :flush_deletes, 'Paperclip/Storage/flush_deletes'
|
18
|
+
add_method_tracer :flush_writes, 'Paperclip/Storage/flush_writes'
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# == Resque Instrumentation
|
2
|
+
#
|
3
|
+
# Installs a hook to ensure the agent starts manually when the worker
|
4
|
+
# starts and also adds the tracer to the process method which executes
|
5
|
+
# in the forked task.
|
6
|
+
|
7
|
+
module RPMContrib
|
8
|
+
module Instrumentation
|
9
|
+
module ResqueInstrumentation
|
10
|
+
::Resque::Job.class_eval do
|
11
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
12
|
+
|
13
|
+
old_perform_method = instance_method(:perform)
|
14
|
+
|
15
|
+
define_method(:perform) do
|
16
|
+
class_name = (payload_class ||self.class).name
|
17
|
+
NewRelic::Agent.reset_stats if NewRelic::Agent.respond_to? :reset_stats
|
18
|
+
perform_action_with_newrelic_trace(:name => 'perform', :class_name => class_name,
|
19
|
+
:category => 'OtherTransaction/ResqueJob') do
|
20
|
+
old_perform_method.bind(self).call
|
21
|
+
end
|
22
|
+
|
23
|
+
NewRelic::Agent.shutdown unless defined?(::Resque.before_child_exit)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
if defined?(::Resque.before_child_exit)
|
28
|
+
::Resque.before_child_exit do |worker|
|
29
|
+
NewRelic::Agent.shutdown
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end if defined?(::Resque::Job) and not NewRelic::Control.instance['disable_resque']
|
data/test/helper.rb
ADDED
@@ -0,0 +1,12 @@
|
|
1
|
+
require 'rubygems'
|
2
|
+
require 'test/unit'
|
3
|
+
|
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'
|
8
|
+
|
9
|
+
class Test::Unit::TestCase
|
10
|
+
end
|
11
|
+
|
12
|
+
require 'schema.rb'
|
data/test/schema.rb
ADDED
@@ -0,0 +1,19 @@
|
|
1
|
+
# Use this file to add tables you need to do testing
|
2
|
+
# These are created in a sqllite memory DB
|
3
|
+
|
4
|
+
begin
|
5
|
+
require 'sqlite3'
|
6
|
+
require 'active_record'
|
7
|
+
|
8
|
+
ActiveRecord::Base.establish_connection(:adapter => 'sqlite3', :database => ':memory:')
|
9
|
+
ActiveRecord::Migration.verbose = false
|
10
|
+
|
11
|
+
ActiveRecord::Schema.define do
|
12
|
+
|
13
|
+
create_table :stories, :force => true do |table|
|
14
|
+
table.string :text
|
15
|
+
end
|
16
|
+
end
|
17
|
+
rescue LoadError
|
18
|
+
# Skip AR tests
|
19
|
+
end
|
metadata
ADDED
@@ -0,0 +1,93 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: staugaard-rpm_contrib
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
prerelease: false
|
5
|
+
segments:
|
6
|
+
- 1
|
7
|
+
- 0
|
8
|
+
- 7
|
9
|
+
version: 1.0.7
|
10
|
+
platform: ruby
|
11
|
+
authors:
|
12
|
+
- Bill Kayser
|
13
|
+
autorequire:
|
14
|
+
bindir: bin
|
15
|
+
cert_chain: []
|
16
|
+
|
17
|
+
date: 2010-04-06 00:00:00 -07:00
|
18
|
+
default_executable:
|
19
|
+
dependencies:
|
20
|
+
- !ruby/object:Gem::Dependency
|
21
|
+
name: newrelic_rpm
|
22
|
+
prerelease: false
|
23
|
+
requirement: &id001 !ruby/object:Gem::Requirement
|
24
|
+
requirements:
|
25
|
+
- - "="
|
26
|
+
- !ruby/object:Gem::Version
|
27
|
+
segments:
|
28
|
+
- 2
|
29
|
+
- 11
|
30
|
+
- 1
|
31
|
+
version: 2.11.1
|
32
|
+
type: :runtime
|
33
|
+
version_requirements: *id001
|
34
|
+
description: " Community contributed instrumentation for various frameworks based on\n the New Relic Ruby monitoring gem newrelic_rpm.\n"
|
35
|
+
email: support@newrelic.com
|
36
|
+
executables: []
|
37
|
+
|
38
|
+
extensions: []
|
39
|
+
|
40
|
+
extra_rdoc_files:
|
41
|
+
- LICENSE
|
42
|
+
- README.md
|
43
|
+
files:
|
44
|
+
- CHANGELOG
|
45
|
+
- LICENSE
|
46
|
+
- README.md
|
47
|
+
- Rakefile
|
48
|
+
- lib/new_relic/control/camping.rb
|
49
|
+
- lib/rpm_contrib.rb
|
50
|
+
- lib/rpm_contrib/detection/camping.rb
|
51
|
+
- lib/rpm_contrib/detection/resque.rb
|
52
|
+
- lib/rpm_contrib/instrumentation/authlogic.rb
|
53
|
+
- lib/rpm_contrib/instrumentation/camping.rb
|
54
|
+
- lib/rpm_contrib/instrumentation/mongodb.rb
|
55
|
+
- lib/rpm_contrib/instrumentation/paperclip.rb
|
56
|
+
- lib/rpm_contrib/instrumentation/resque.rb
|
57
|
+
- test/helper.rb
|
58
|
+
- test/schema.rb
|
59
|
+
- test/test_rpm_contrib.rb
|
60
|
+
has_rdoc: true
|
61
|
+
homepage: http://github.com/newrelic/rpm_contrib
|
62
|
+
licenses: []
|
63
|
+
|
64
|
+
post_install_message:
|
65
|
+
rdoc_options:
|
66
|
+
- --charset=UTF-8
|
67
|
+
require_paths:
|
68
|
+
- lib
|
69
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
70
|
+
requirements:
|
71
|
+
- - ">="
|
72
|
+
- !ruby/object:Gem::Version
|
73
|
+
segments:
|
74
|
+
- 0
|
75
|
+
version: "0"
|
76
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
77
|
+
requirements:
|
78
|
+
- - ">="
|
79
|
+
- !ruby/object:Gem::Version
|
80
|
+
segments:
|
81
|
+
- 0
|
82
|
+
version: "0"
|
83
|
+
requirements: []
|
84
|
+
|
85
|
+
rubyforge_project:
|
86
|
+
rubygems_version: 1.3.6
|
87
|
+
signing_key:
|
88
|
+
specification_version: 3
|
89
|
+
summary: Contributed Instrumentation for New Relic RPM
|
90
|
+
test_files:
|
91
|
+
- test/helper.rb
|
92
|
+
- test/schema.rb
|
93
|
+
- test/test_rpm_contrib.rb
|