rpm_contrib 1.0.3 → 1.0.4
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 +4 -0
- data/README.md +34 -13
- data/Rakefile +1 -1
- data/lib/rpm_contrib.rb +15 -6
- data/lib/rpm_contrib/detection/resque.rb +15 -0
- data/lib/rpm_contrib/instrumentation/resque.rb +39 -0
- metadata +10 -7
data/CHANGELOG
CHANGED
data/README.md
CHANGED
@@ -1,28 +1,49 @@
|
|
1
1
|
# The RPM Contrib Gem
|
2
2
|
|
3
|
-
The `rpm_contrib` gem contains instrumentation for the New Relic RPM
|
4
|
-
contributed by the community of RPM users. It requires the RPM
|
5
|
-
to run.
|
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
6
|
|
7
|
-
To use the contrib gem, install the `rpm_contrib` gem
|
8
|
-
also install the required version of the `newrelic_rpm` gem if
|
9
|
-
already installed.
|
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
10
|
|
11
|
-
For Rails 2.1 and later, add
|
11
|
+
For Rails 2.1 and later, add this dependency to your in your
|
12
|
+
environment.rb:
|
12
13
|
|
13
14
|
config.gem 'rpm_contrib'
|
14
15
|
|
15
|
-
For other frameworks, make sure you load rubygems if it isn't already,
|
16
|
-
just require the contrib gem:
|
16
|
+
For other frameworks, make sure you load rubygems if it isn't already,
|
17
|
+
then just require the contrib gem:
|
17
18
|
|
18
19
|
require 'rubygems'
|
19
20
|
require 'rpm_contrib'
|
20
21
|
|
21
|
-
When you load the rpm_contrib gem, the `newrelic_rpm` gem will also be
|
22
|
-
No need for a separate require statement for
|
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
|
23
46
|
|
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
47
|
|
27
48
|
# How to Add Custom Instrumentation
|
28
49
|
|
data/Rakefile
CHANGED
@@ -18,7 +18,7 @@ begin
|
|
18
18
|
gem.email = "support@newrelic.com"
|
19
19
|
gem.homepage = "http://github.com/newrelic/rpm_contrib"
|
20
20
|
gem.author = "Bill Kayser"
|
21
|
-
gem.add_dependency 'newrelic_rpm', '
|
21
|
+
gem.add_dependency 'newrelic_rpm', '2.11.0.beta'
|
22
22
|
gem.version = version
|
23
23
|
gem.files = FileList['LICENSE', 'README*', 'lib/**/*.rb', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
|
24
24
|
end
|
data/lib/rpm_contrib.rb
CHANGED
@@ -5,7 +5,6 @@ module RPMContrib
|
|
5
5
|
VERSION = File.read(RPM_CONTRIB_LIB+"/../CHANGELOG")[/Version ([\d\.]+)$/, 1]
|
6
6
|
end
|
7
7
|
|
8
|
-
|
9
8
|
# Perform any framework/dispatcher detection before loading the rpm
|
10
9
|
# gem.
|
11
10
|
|
@@ -15,11 +14,21 @@ Dir.glob(RPM_CONTRIB_LIB + "/rpm_contrib/detection/**/*.rb") { |file| require fi
|
|
15
14
|
|
16
15
|
require 'newrelic_rpm'
|
17
16
|
|
18
|
-
|
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
|
19
27
|
|
20
|
-
|
28
|
+
if defined?(Rails.configuration)
|
29
|
+
Rails.configuration.after_initialize &init_sequence
|
30
|
+
else
|
31
|
+
init_sequence.call
|
32
|
+
end
|
21
33
|
|
22
|
-
# Load all the Sampler class definitions. These will register
|
23
|
-
# automatically with the agent.
|
24
|
-
Dir.glob(RPM_CONTRIB_LIB + "/rpm_contrib/samplers/**/*.rb") { |file| require file }
|
25
34
|
|
@@ -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,39 @@
|
|
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
|
+
|
11
|
+
::Resque::Worker.class_eval do
|
12
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
13
|
+
old_process_method = instance_method(:process)
|
14
|
+
define_method(:process) do | *args |
|
15
|
+
if args[0]
|
16
|
+
class_name = args[0].payload_class.name
|
17
|
+
else
|
18
|
+
class_name = 'Resque::Job'
|
19
|
+
end
|
20
|
+
name = 'process'
|
21
|
+
perform_action_with_newrelic_trace(:name => name, :class_name => class_name,
|
22
|
+
:category => 'OtherTransaction/ResqueJob') do
|
23
|
+
old_process_method.bind(self).call(*args)
|
24
|
+
end
|
25
|
+
NewRelic::Agent.shutdown
|
26
|
+
end
|
27
|
+
|
28
|
+
old_work_method = instance_method(:work)
|
29
|
+
|
30
|
+
define_method(:work) do | *args |
|
31
|
+
RAILS_DEFAULT_LOGGER.info "Sarting Resque monitoring"
|
32
|
+
old_work_method.bind(self).call(*args)
|
33
|
+
end
|
34
|
+
end
|
35
|
+
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end if defined?(::Resque::Worker) and not NewRelic::Control.instance['disable_resque']
|
39
|
+
|
metadata
CHANGED
@@ -5,8 +5,8 @@ version: !ruby/object:Gem::Version
|
|
5
5
|
segments:
|
6
6
|
- 1
|
7
7
|
- 0
|
8
|
-
-
|
9
|
-
version: 1.0.
|
8
|
+
- 4
|
9
|
+
version: 1.0.4
|
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-
|
17
|
+
date: 2010-03-26 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -22,13 +22,14 @@ dependencies:
|
|
22
22
|
prerelease: false
|
23
23
|
requirement: &id001 !ruby/object:Gem::Requirement
|
24
24
|
requirements:
|
25
|
-
- - "
|
25
|
+
- - "="
|
26
26
|
- !ruby/object:Gem::Version
|
27
27
|
segments:
|
28
28
|
- 2
|
29
|
-
-
|
30
|
-
-
|
31
|
-
|
29
|
+
- 11
|
30
|
+
- 0
|
31
|
+
- beta
|
32
|
+
version: 2.11.0.beta
|
32
33
|
type: :runtime
|
33
34
|
version_requirements: *id001
|
34
35
|
description: " Community contributed instrumentation for various frameworks based on\n the New Relic Ruby monitoring gem newrelic_rpm.\n"
|
@@ -48,10 +49,12 @@ files:
|
|
48
49
|
- lib/new_relic/control/camping.rb
|
49
50
|
- lib/rpm_contrib.rb
|
50
51
|
- lib/rpm_contrib/detection/camping.rb
|
52
|
+
- lib/rpm_contrib/detection/resque.rb
|
51
53
|
- lib/rpm_contrib/instrumentation/authlogic.rb
|
52
54
|
- lib/rpm_contrib/instrumentation/camping.rb
|
53
55
|
- lib/rpm_contrib/instrumentation/mongodb.rb
|
54
56
|
- lib/rpm_contrib/instrumentation/paperclip.rb
|
57
|
+
- lib/rpm_contrib/instrumentation/resque.rb
|
55
58
|
- test/helper.rb
|
56
59
|
- test/schema.rb
|
57
60
|
- test/test_rpm_contrib.rb
|