rpm_contrib 1.0.7 → 1.0.8
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 +5 -0
- data/{README.rdoc → README.md} +66 -63
- data/Rakefile +18 -10
- data/lib/new_relic/control/camping.rb +7 -5
- data/lib/rpm_contrib/detection/camping.rb +5 -4
- data/lib/rpm_contrib/instrumentation/redis.rb +26 -0
- data/lib/rpm_contrib/instrumentation/resque.rb +5 -5
- metadata +17 -7
- data/lib/rpm_contrib/instrumentation/authlogic.rb +0 -8
data/CHANGELOG
CHANGED
data/{README.rdoc → README.md}
RENAMED
@@ -1,75 +1,74 @@
|
|
1
|
-
|
1
|
+
# The RPM Contrib Gem
|
2
2
|
|
3
|
-
The `rpm_contrib` gem contains instrumentation for the New Relic RPM
|
4
|
-
|
5
|
-
Agent to run.
|
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.
|
6
5
|
|
7
|
-
To use the contrib gem, install the `rpm_contrib` gem from gemcutter.
|
8
|
-
|
9
|
-
|
6
|
+
To use the contrib gem, install the `rpm_contrib` gem from gemcutter. It will
|
7
|
+
also install the required version of the `newrelic_rpm` gem if it's not already
|
8
|
+
installed.
|
10
9
|
|
11
|
-
For Rails 2.1 and later, add this dependency to your in your
|
12
|
-
environment.rb:
|
10
|
+
For Rails 2.1 and later, add this dependency to your in your environment.rb:
|
13
11
|
|
14
12
|
config.gem 'rpm_contrib'
|
15
13
|
|
16
|
-
For other frameworks, make sure you load rubygems if it isn't already,
|
17
|
-
|
14
|
+
For other frameworks, make sure you load rubygems if it isn't already, then just
|
15
|
+
require the contrib gem:
|
18
16
|
|
19
17
|
require 'rubygems'
|
20
18
|
require 'rpm_contrib'
|
21
19
|
|
22
20
|
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
|
-
`
|
25
|
-
`newrelic_rpm` gem initializes.
|
21
|
+
initialized. No need for a separate require statement for `newrelic_rpm`. The
|
22
|
+
`rpm_contrib` gem must be loaded before the `newrelic_rpm` gem initializes.
|
26
23
|
|
27
|
-
|
24
|
+
# Supported Frameworks
|
28
25
|
|
29
|
-
A number of frameworks are supported in the contrib gem. They are all
|
30
|
-
|
31
|
-
disable any of them.
|
26
|
+
A number of frameworks are supported in the contrib gem. They are all turned on
|
27
|
+
by default but you can add settings to your newrelic.yml to disable any of them.
|
32
28
|
|
33
|
-
|
29
|
+
### Camping
|
34
30
|
|
35
31
|
The gem will detect a Camping app but you need to manually add the
|
36
32
|
instrumentation to your configuration file. See RPMContrib::Instrumentation::Camping
|
37
33
|
for more information.
|
38
34
|
|
39
|
-
|
35
|
+
### Paperclip
|
40
36
|
|
41
37
|
No special configuration required for Paperclip visibility. You can disable
|
42
38
|
it by setting `disable_paperclip` to true in the newrelic.yml file.
|
43
39
|
|
44
|
-
|
45
|
-
|
46
|
-
No special configuration required for Authlogic visibility. You can disable
|
47
|
-
it by setting `disable_authlogic` to true in the newrelic.yml file.
|
48
|
-
|
49
|
-
=== MongoDB
|
40
|
+
### MongoDB
|
50
41
|
|
51
42
|
No special configuration required for MongoDB visibility. You can disable
|
52
43
|
it by setting `disable_mongodb` to true in the newrelic.yml file.
|
53
44
|
|
54
|
-
|
45
|
+
### Resque
|
55
46
|
|
56
47
|
To disable resque, add this to your newrelic.yml:
|
57
48
|
|
58
49
|
disable_resque: true
|
59
50
|
|
51
|
+
### Redis
|
52
|
+
|
53
|
+
Redis instrumentation will record operations as well as `allWeb` and `allOther`
|
54
|
+
summary metrics under the `Database/Redis` metric namespace.
|
55
|
+
|
56
|
+
To disable Redis instrumentation, add this to your newrelic.yml:
|
57
|
+
|
58
|
+
disable_redis: true
|
60
59
|
|
61
|
-
|
60
|
+
# How to Add Custom Instrumentation
|
62
61
|
|
63
|
-
We encourage contributions to this project and will provide whatever
|
64
|
-
|
65
|
-
|
62
|
+
We encourage contributions to this project and will provide whatever assistance
|
63
|
+
we can to those wishing to develop instrumentation for other open source Ruby
|
64
|
+
libraries.
|
66
65
|
|
67
|
-
When adding instrumentation to this gem, be sure and get familiar with the
|
68
|
-
|
69
|
-
|
66
|
+
When adding instrumentation to this gem, be sure and get familiar with the [RPM
|
67
|
+
Agent API](http://newrelic.github.com/rpm/classes/NewRelic/Agent.html) and
|
68
|
+
contact support@newrelic.com with any questions.
|
70
69
|
|
71
|
-
There are several extension points in the agent you can take advantage of
|
72
|
-
|
70
|
+
There are several extension points in the agent you can take advantage of with
|
71
|
+
this gem.
|
73
72
|
|
74
73
|
* Custom tracers which measure methods and give visibility to
|
75
74
|
otherwise unmeasured libraries.
|
@@ -79,49 +78,53 @@ with this gem.
|
|
79
78
|
web dispatcher, or be [started manually](http://support.newrelic.com/faqs/general/manual-start).
|
80
79
|
* Framework support, for alternatives to Rails like Camping or Ramaze
|
81
80
|
|
82
|
-
|
81
|
+
## Custom Tracers
|
83
82
|
|
84
83
|
Custom tracers for frameworks should be added to the `lib/rpm_contrib/instrumentation`
|
85
84
|
directory. These files are loaded at the time the Agent starts. **They will not
|
86
85
|
be loaded if the Agent does not start up.**
|
87
86
|
|
88
|
-
It is important that you wrap any instrumentation with the checks necessary
|
89
|
-
|
87
|
+
It is important that you wrap any instrumentation with the checks necessary to
|
88
|
+
determine if the code being instrumented is loaded. You can't add code to the
|
90
89
|
contrib gem that will break when run in any other context besides yours.
|
91
90
|
|
92
91
|
|
93
|
-
For details on how to define custom tracers, refer to the [support documentation
|
94
|
-
|
95
|
-
|
96
|
-
[Agent method tracing
|
97
|
-
|
92
|
+
For details on how to define custom tracers, refer to the [support documentation
|
93
|
+
on adding custom
|
94
|
+
tracers](http://support.newrelic.com/faqs/docs/custom-metric-collection). You
|
95
|
+
can also get detailed information on the API from the [Agent method tracing
|
96
|
+
rdocs](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer.html),
|
97
|
+
especially the
|
98
|
+
[add_method_tracer](http://newrelic.github.com/rpm/classes/NewRelic/Agent/MethodTracer/ClassMethods.html)
|
98
99
|
docs.
|
99
100
|
|
100
101
|
A good example can be found in `lib/rpm_contrib/instrumentation/paperclip.rb`.
|
101
102
|
|
102
|
-
|
103
|
+
## Samplers
|
103
104
|
|
104
|
-
You can add samplers which will record metrics approximately once a minute.
|
105
|
-
are useful for capturing generic instrumentation for display in
|
106
|
-
|
105
|
+
You can add samplers which will record metrics approximately once a minute.
|
106
|
+
Samplers are useful for capturing generic instrumentation for display in [custom
|
107
|
+
views](http://support.newrelic.com/faqs/docs/custom-dashboard-specification).
|
107
108
|
|
108
|
-
Samplers should extend the
|
109
|
+
Samplers should extend the
|
110
|
+
[`NewRelic::Agent::Sampler`](http://newrelic.github.com/rpm/classes/NewRelic/Agent/Sampler.html)
|
109
111
|
class. They should be placed in the `samplers` directory.
|
110
112
|
|
111
113
|
Refer to examples in the RPM agent to see how to get started.
|
112
114
|
|
113
|
-
|
115
|
+
## Supporting New Dispatchers
|
114
116
|
|
115
|
-
If you want to add support for a new dispatcher which is not being recognized by
|
116
|
-
by the RPM agent, add code to the `rpm_contrib/detection` directory.
|
117
|
-
to define a module in the `NewRelic::LocalEnvironment` class.
|
118
|
-
accessed at the time environment detection takes place, when
|
117
|
+
If you want to add support for a new dispatcher which is not being recognized by
|
118
|
+
default by the RPM agent, add code to the `rpm_contrib/detection` directory.
|
119
|
+
This code needs to define a module in the `NewRelic::LocalEnvironment` class.
|
120
|
+
This module will be accessed at the time environment detection takes place, when
|
121
|
+
the agent is initialized.
|
119
122
|
|
120
|
-
This module should define the method `discover_dispatcher` and return the name
|
121
|
-
dispatcher if detected, or defer to super. See
|
122
|
-
for a good example.
|
123
|
+
This module should define the method `discover_dispatcher` and return the name
|
124
|
+
of the dispatcher if detected, or defer to super. See
|
125
|
+
`rpm_contrib/detection/camping.rb` for a good example.
|
123
126
|
|
124
|
-
|
127
|
+
## Supporting New Frameworks
|
125
128
|
|
126
129
|
Supporting new frameworks can be pretty involved and generally involves both
|
127
130
|
adding custom instrumentation as well as framework and dispatcher detection.
|
@@ -134,7 +137,7 @@ Refer to the camping example in this gem to see how this is done in general.
|
|
134
137
|
If you decide to tackle any new frameworks, contact support@newrelic.com and
|
135
138
|
we'll be happy to help you work through it.
|
136
139
|
|
137
|
-
|
140
|
+
# Note on Patches/Pull Requests
|
138
141
|
|
139
142
|
* Fork the http://www.github.com/newrelic/rpm_contrib project.
|
140
143
|
* Add instrumentation files to `lib/rpm_contrib/instrumentation`. These
|
@@ -147,15 +150,15 @@ we'll be happy to help you work through it.
|
|
147
150
|
commit by itself I can ignore when I pull)
|
148
151
|
* Send me a pull request. Bonus points for topic branches.
|
149
152
|
|
150
|
-
|
153
|
+
# Further Information
|
151
154
|
|
152
155
|
Refer to the Agent API Documentation at http://newrelic.github.com/rpm
|
153
156
|
|
154
|
-
See the support site faqs at http://support.newrelic.com/faqs for
|
155
|
-
|
157
|
+
See the support site faqs at http://support.newrelic.com/faqs for additional
|
158
|
+
tips and documentation.
|
156
159
|
|
157
160
|
Contact support@newrelic.com for help.
|
158
161
|
|
159
|
-
|
162
|
+
### Copyright
|
160
163
|
|
161
164
|
Copyright (c) 2009-2010 New Relic. See LICENSE for details.
|
data/Rakefile
CHANGED
@@ -6,21 +6,31 @@ def version
|
|
6
6
|
@rpm_contrib_version ||= File.read("CHANGELOG")[/Version ([\d\.]+)$/, 1]
|
7
7
|
end
|
8
8
|
|
9
|
+
RDOC_FILES = FileList['README*','LICENSE','CHANGELOG']
|
10
|
+
SUMMARY = "Contributed Instrumentation for New Relic RPM"
|
11
|
+
DESCRIPTION = <<-EOF
|
12
|
+
Community contributed instrumentation for various frameworks based on
|
13
|
+
the New Relic Ruby monitoring gem newrelic_rpm.
|
14
|
+
EOF
|
15
|
+
|
9
16
|
begin
|
10
17
|
require 'jeweler'
|
11
18
|
Jeweler::Tasks.new do |gem|
|
12
19
|
gem.name = "rpm_contrib"
|
13
|
-
gem.summary =
|
14
|
-
gem.description =
|
15
|
-
Community contributed instrumentation for various frameworks based on
|
16
|
-
the New Relic Ruby monitoring gem newrelic_rpm.
|
17
|
-
EOF
|
20
|
+
gem.summary = SUMMARY
|
21
|
+
gem.description = DESCRIPTION
|
18
22
|
gem.email = "support@newrelic.com"
|
19
23
|
gem.homepage = "http://github.com/newrelic/rpm_contrib"
|
20
24
|
gem.author = "Bill Kayser"
|
21
25
|
gem.add_dependency 'newrelic_rpm', '2.11.1'
|
22
26
|
gem.version = version
|
23
27
|
gem.files = FileList['LICENSE', 'README*', 'lib/**/*.rb', 'bin/*', '[A-Z]*', 'test/**/*'].to_a
|
28
|
+
gem.rdoc_options <<
|
29
|
+
"--line-numbers" <<
|
30
|
+
"--inline-source" <<
|
31
|
+
"--title" << SUMMARY <<
|
32
|
+
"-m" << "README.md"
|
33
|
+
gem.extra_rdoc_files = RDOC_FILES
|
24
34
|
end
|
25
35
|
Jeweler::GemcutterTasks.new
|
26
36
|
rescue LoadError
|
@@ -55,11 +65,9 @@ require 'rake/rdoctask'
|
|
55
65
|
Rake::RDocTask.new do |rdoc|
|
56
66
|
rdoc.rdoc_dir = 'rdoc'
|
57
67
|
rdoc.title = "rpm_contrib #{version}"
|
58
|
-
rdoc.main = "README.
|
59
|
-
rdoc.rdoc_files
|
60
|
-
rdoc.
|
61
|
-
rdoc.rdoc_files.include('CHANGELOG')
|
62
|
-
rdoc.rdoc_files.include('lib/**/*.rb')
|
68
|
+
rdoc.main = "README.md"
|
69
|
+
rdoc.rdoc_files = FileList['lib/**/*.rb'] + RDOC_FILES
|
70
|
+
rdoc.inline_source = true
|
63
71
|
end
|
64
72
|
|
65
73
|
begin
|
@@ -3,10 +3,12 @@ require 'new_relic/control/ruby'
|
|
3
3
|
# It is loaded by virtue of detecting 'camping' as the framework
|
4
4
|
# in the rpm_contrib/detection/camping.rb file. It gets loaded
|
5
5
|
# by the new_relic/control.rb file.
|
6
|
-
class NewRelic::Control
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
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
|
11
13
|
end
|
12
14
|
end
|
@@ -1,7 +1,8 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
|
4
|
-
|
1
|
+
module NewRelic #:nodoc:
|
2
|
+
# The class defined in the
|
3
|
+
# newrelic_rpm[http://newrelic.github.com/rpm] which can be ammended
|
4
|
+
# to support new frameworks by defining modules in this namespace.
|
5
|
+
class LocalEnvironment #:nodoc:
|
5
6
|
module Camping
|
6
7
|
def discover_framework
|
7
8
|
if defined?(::Camping)
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# Redis instrumentation contributed by Ashley Martens of ngmoco
|
2
|
+
#
|
3
|
+
|
4
|
+
if defined?(::Redis) and not NewRelic::Control.instance['disable_redis']
|
5
|
+
|
6
|
+
::Redis.class_eval do
|
7
|
+
|
8
|
+
include NewRelic::Agent::MethodTracer
|
9
|
+
|
10
|
+
def raw_call_command_with_newrelic_trace *args
|
11
|
+
method_name = args[0].is_a?(Array) ? args[0][0] : args[0]
|
12
|
+
metrics = ["Database/Redis/#{method_name}",
|
13
|
+
(NewRelic::Agent::Instrumentation::MetricFrame.recording_web_transaction? ? 'Database/Redis/allWeb' : 'Database/Redis/allOther')]
|
14
|
+
self.class.trace_execution_scoped(metrics) do
|
15
|
+
# NewRelic::Control.instance.log.debug("Instrumenting Redis Call[#{method_name}]: #{args[0].inspect}")
|
16
|
+
raw_call_command_without_newrelic_trace(*args)
|
17
|
+
end
|
18
|
+
end
|
19
|
+
|
20
|
+
# alias_method_chain :raw_call_command, :newrelic_trace
|
21
|
+
alias raw_call_command_without_newrelic_trace raw_call_command
|
22
|
+
alias raw_call_command raw_call_command_with_newrelic_trace
|
23
|
+
|
24
|
+
end
|
25
|
+
|
26
|
+
end
|
@@ -1,11 +1,11 @@
|
|
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
1
|
|
7
2
|
module RPMContrib
|
8
3
|
module Instrumentation
|
4
|
+
# == Resque Instrumentation
|
5
|
+
#
|
6
|
+
# Installs a hook to ensure the agent starts manually when the worker
|
7
|
+
# starts and also adds the tracer to the process method which executes
|
8
|
+
# in the forked task.
|
9
9
|
module ResqueInstrumentation
|
10
10
|
::Resque::Job.class_eval do
|
11
11
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
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
|
+
- 8
|
9
|
+
version: 1.0.8
|
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-04
|
17
|
+
date: 2010-05-04 00:00:00 -07:00
|
18
18
|
default_executable:
|
19
19
|
dependencies:
|
20
20
|
- !ruby/object:Gem::Dependency
|
@@ -31,28 +31,32 @@ dependencies:
|
|
31
31
|
version: 2.11.1
|
32
32
|
type: :runtime
|
33
33
|
version_requirements: *id001
|
34
|
-
description:
|
34
|
+
description: |
|
35
|
+
Community contributed instrumentation for various frameworks based on
|
36
|
+
the New Relic Ruby monitoring gem newrelic_rpm.
|
37
|
+
|
35
38
|
email: support@newrelic.com
|
36
39
|
executables: []
|
37
40
|
|
38
41
|
extensions: []
|
39
42
|
|
40
43
|
extra_rdoc_files:
|
44
|
+
- CHANGELOG
|
41
45
|
- LICENSE
|
42
|
-
- README.
|
46
|
+
- README.md
|
43
47
|
files:
|
44
48
|
- CHANGELOG
|
45
49
|
- LICENSE
|
46
|
-
- README.
|
50
|
+
- README.md
|
47
51
|
- Rakefile
|
48
52
|
- lib/new_relic/control/camping.rb
|
49
53
|
- lib/rpm_contrib.rb
|
50
54
|
- lib/rpm_contrib/detection/camping.rb
|
51
55
|
- lib/rpm_contrib/detection/resque.rb
|
52
|
-
- lib/rpm_contrib/instrumentation/authlogic.rb
|
53
56
|
- lib/rpm_contrib/instrumentation/camping.rb
|
54
57
|
- lib/rpm_contrib/instrumentation/mongodb.rb
|
55
58
|
- lib/rpm_contrib/instrumentation/paperclip.rb
|
59
|
+
- lib/rpm_contrib/instrumentation/redis.rb
|
56
60
|
- lib/rpm_contrib/instrumentation/resque.rb
|
57
61
|
- test/helper.rb
|
58
62
|
- test/schema.rb
|
@@ -64,6 +68,12 @@ licenses: []
|
|
64
68
|
post_install_message:
|
65
69
|
rdoc_options:
|
66
70
|
- --charset=UTF-8
|
71
|
+
- --line-numbers
|
72
|
+
- --inline-source
|
73
|
+
- --title
|
74
|
+
- Contributed Instrumentation for New Relic RPM
|
75
|
+
- -m
|
76
|
+
- README.md
|
67
77
|
require_paths:
|
68
78
|
- lib
|
69
79
|
required_ruby_version: !ruby/object:Gem::Requirement
|