newrelic_mongo 0.0.1
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +155 -0
- data/Gemfile +8 -0
- data/LICENSE +22 -0
- data/README.md +21 -0
- data/Rakefile +79 -0
- data/lib/newrelic_mongo/instrumentation/mongo.rb +55 -0
- data/lib/newrelic_mongo/instrumentation/mongoid.rb +21 -0
- data/lib/newrelic_mongo/instrumentation.rb +11 -0
- data/lib/newrelic_mongo.rb +3 -0
- metadata +97 -0
data/CHANGELOG
ADDED
@@ -0,0 +1,155 @@
|
|
1
|
+
* Version 0.0.1
|
2
|
+
- Pulled from deprecated `rpm_contrib` repo
|
3
|
+
|
4
|
+
Below is the old rpm_contrib gem Changelog:
|
5
|
+
|
6
|
+
* Version 2.1.11
|
7
|
+
- Removed Resque instrumentation in favor of instrumentation in main agent https://github.com/newrelic/rpm (version 3.4.0)
|
8
|
+
|
9
|
+
* Version 2.1.10
|
10
|
+
- Removed Workling instrumentation in favor of https://github.com/aurorafeint/newrelic-workling
|
11
|
+
|
12
|
+
* Version 2.1.9
|
13
|
+
- Removed riak-client and ripple instrumentation in favor of
|
14
|
+
https://github.com/alinpopa/newrelic-riak
|
15
|
+
|
16
|
+
* Version 2.1.8
|
17
|
+
- Removed redis instrumenation in favor of https://github.com/evanphx/newrelic-redis
|
18
|
+
- [FIX] adding check for aws-sdk (Tom Caspy)
|
19
|
+
- Improved Mongo instrumenation from pull request #16 titanous/mongoid-instrumentation
|
20
|
+
|
21
|
+
* Version 2.1.7
|
22
|
+
|
23
|
+
Community contributed instrumentation
|
24
|
+
- ThinkingSphinx instrumentation improvement (Martin Sarsale)
|
25
|
+
- Picky search engine instrumentation (Niko Dittmann)
|
26
|
+
Community Contributed Bug Fixes
|
27
|
+
- Fix instrumentation injection for ActiveMessaging (W. Andrew Loe III)
|
28
|
+
Other
|
29
|
+
- Improvements to resque instrumentation detection of if its in a forking ruby implementation
|
30
|
+
|
31
|
+
* Version 2.1.6
|
32
|
+
|
33
|
+
Community contributed instrumentation
|
34
|
+
- ThinkingSphinx instrumentation (W. Andrew Loe III)
|
35
|
+
- Riak instrumentation (Bryce Kerley)
|
36
|
+
- KyotoTycoon instrumentation (Keisuke Kawahara)
|
37
|
+
Community Contributed Bug Fixes
|
38
|
+
- MongoDB instrumentation (Kenn Ejima)
|
39
|
+
- Yajl instrumentation (Chris Griego)
|
40
|
+
- UltraSphinx instrumentation (Jonathan Rudenberg)
|
41
|
+
- Renamed ActiveMQ instrumentation to ActiveMessaging (W. Andrew Loe III)
|
42
|
+
|
43
|
+
* Version 2.1.5
|
44
|
+
|
45
|
+
Changed the resque detection so it does not depend on the load
|
46
|
+
order of resque => rpm_contrib => newrelic_rpm. The gems can be
|
47
|
+
installed in any order.
|
48
|
+
|
49
|
+
* Version 2.1.4
|
50
|
+
|
51
|
+
Updated requirements to latest agent with some bug fixes for background jobs
|
52
|
+
Converted instrumentation to install with DependencyDetection in the latest Agent
|
53
|
+
Changed Resque instrumentation from a plugin back to method chaining
|
54
|
+
Fixed several reported bugs related to resque
|
55
|
+
|
56
|
+
* Version 2.1.3
|
57
|
+
|
58
|
+
Fixed typo in Resque instrumentation
|
59
|
+
Fixed double loading of AWS instrumentation
|
60
|
+
|
61
|
+
* Version 2.1.2
|
62
|
+
|
63
|
+
Add a manual shutdown to the Resque instrumentation to make sure data is saved and sent - thanks to Jade Rubick
|
64
|
+
|
65
|
+
* Version 2.1.1
|
66
|
+
|
67
|
+
Fix namespacing problem with Resque
|
68
|
+
Add instrumentation to Mongo::Cursor #refresh and #close - thanks to Chris Griego
|
69
|
+
|
70
|
+
* Version 2.1.0
|
71
|
+
|
72
|
+
Included instrumentation from the community:
|
73
|
+
- Alexey Palazhchenko - mongo ORM-agnostic instrumentation
|
74
|
+
- Michael Breen - Elastic Search
|
75
|
+
- Paul Ingles - Sinatra Template instrumentation
|
76
|
+
- Siddharth Dawara - Typhoeus instrumentation
|
77
|
+
- Rob Meyer - ActiveMQ instrumentation
|
78
|
+
- Greg Hazel - Curb instrumentation
|
79
|
+
- Ben Poweski - Crack and Yajl instrumentation
|
80
|
+
- Chad Ingram and Scott Fleckenstein - Workling instrumentation
|
81
|
+
- Adam Weller - UltraSphinx instrumentation
|
82
|
+
- Liron Yahdav - work on the Resque instrumentation
|
83
|
+
|
84
|
+
* Version 2.0.1
|
85
|
+
|
86
|
+
Fixed an error with Bundler and RubyGems 1.8.2 which caused the gem to always fail to load
|
87
|
+
|
88
|
+
* Version 2.0.0
|
89
|
+
|
90
|
+
Updated to use the latest version of the Ruby Agent
|
91
|
+
|
92
|
+
* Version 1.0.13
|
93
|
+
|
94
|
+
Removed use of 'metaclass' - no longer available from ActiveSupport as of Rails 3
|
95
|
+
Contributed by Chris Griego
|
96
|
+
|
97
|
+
* Version 1.0.12
|
98
|
+
|
99
|
+
Better support for initialization within a Rails 3 application
|
100
|
+
rpm_contrib now depends on newrelic_rpm >= 2.13.1
|
101
|
+
|
102
|
+
* Version 1.0.11
|
103
|
+
|
104
|
+
AWS/S3 instrumentation contributed by Brian Doll
|
105
|
+
Cassandra instrumentation contributed by Ashley Martens
|
106
|
+
Updated Redis instrumentation for 1.x and 2.x contributed by Karl Baum
|
107
|
+
|
108
|
+
* Version 1.0.10
|
109
|
+
|
110
|
+
Mongoid support contributed by Karl Baum
|
111
|
+
|
112
|
+
* Version 1.0.9
|
113
|
+
|
114
|
+
Fixed dependency specification on newrelic_rpm
|
115
|
+
|
116
|
+
* Version 1.0.8
|
117
|
+
|
118
|
+
Redis instrumentation contributed by Ashley Martens
|
119
|
+
Authlogic moved into RPM Ruby Agent
|
120
|
+
|
121
|
+
* Version 1.0.7
|
122
|
+
|
123
|
+
Resque instrumentation now supports the resque-multi-job-forks plugin
|
124
|
+
|
125
|
+
* Version 1.0.6
|
126
|
+
|
127
|
+
Update newrelic dependency: depends on 2.11.1
|
128
|
+
|
129
|
+
* Version 1.0.5
|
130
|
+
|
131
|
+
Clear stats in forked resque jobs
|
132
|
+
|
133
|
+
* Version 1.0.4
|
134
|
+
|
135
|
+
Resque support
|
136
|
+
|
137
|
+
* Version 1.0.3
|
138
|
+
|
139
|
+
MongoDB instrumentation contributed by John Nunemaker
|
140
|
+
|
141
|
+
* Version 1.0.2
|
142
|
+
|
143
|
+
Improved Camping support
|
144
|
+
|
145
|
+
* Version 1.0.1
|
146
|
+
|
147
|
+
Removed DelayedJob, put back in core agent
|
148
|
+
|
149
|
+
* Version 1.0.0
|
150
|
+
|
151
|
+
Initial Release:
|
152
|
+
- Camping
|
153
|
+
- Authlogic
|
154
|
+
- DelayedJob
|
155
|
+
- Paperclip
|
data/Gemfile
ADDED
data/LICENSE
ADDED
@@ -0,0 +1,22 @@
|
|
1
|
+
Copyright (c) 2013-Present Raphael Crawford-Marks
|
2
|
+
|
3
|
+
MIT License
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining
|
6
|
+
a copy of this software and associated documentation files (the
|
7
|
+
"Software"), to deal in the Software without restriction, including
|
8
|
+
without limitation the rights to use, copy, modify, merge, publish,
|
9
|
+
distribute, sublicense, and/or sell copies of the Software, and to
|
10
|
+
permit persons to whom the Software is furnished to do so, subject to
|
11
|
+
the following conditions:
|
12
|
+
|
13
|
+
The above copyright notice and this permission notice shall be
|
14
|
+
included in all copies or substantial portions of the Software.
|
15
|
+
|
16
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
|
17
|
+
EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
18
|
+
MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
|
19
|
+
NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
|
20
|
+
LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
|
21
|
+
OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
22
|
+
WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
data/README.md
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# The newrelic_mongo gem
|
2
|
+
|
3
|
+
The `newrelic_mongo` gem contains NewRelic RPM instrumentation for the
|
4
|
+
mongo-ruby-driver gem, contributed by the community of RPM users. It requires
|
5
|
+
the RPM Agent to run.
|
6
|
+
|
7
|
+
The gem was forked from the deprecated `rpm_contrib` gem and is maintained by
|
8
|
+
Raphael Crawford-Marks.
|
9
|
+
|
10
|
+
If you are using Mongoid 3 and/or Moped, please use the `newrelic_moped` gem:
|
11
|
+
|
12
|
+
https://github.com/stevebartholomew/newrelic_moped
|
13
|
+
|
14
|
+
## Getting Started
|
15
|
+
|
16
|
+
TODO
|
17
|
+
|
18
|
+
## Contributing
|
19
|
+
|
20
|
+
I welcome bug fixes and new features. Fork the repo, make your changes, and then
|
21
|
+
submit a pull request. Be sure to add tests. Thanks in advance!
|
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 = "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,55 @@
|
|
1
|
+
# Mongo Instrumentation originally contributed by Alexey Palazhchenko
|
2
|
+
DependencyDetection.defer do
|
3
|
+
@name = :mongodb
|
4
|
+
|
5
|
+
depends_on do
|
6
|
+
defined?(::Mongo) and not NewRelic::Control.instance['disable_mongodb']
|
7
|
+
end
|
8
|
+
|
9
|
+
executes do
|
10
|
+
NewRelic::Agent.logger.debug 'Installing mongo-ruby-driver instrumentation'
|
11
|
+
end
|
12
|
+
|
13
|
+
executes do
|
14
|
+
::Mongo::Logging.class_eval do
|
15
|
+
include NewRelic::Agent::MethodTracer
|
16
|
+
|
17
|
+
def instrument_with_newrelic_trace(name, payload = {}, &blk)
|
18
|
+
payload = {} if payload.nil?
|
19
|
+
collection = payload[:collection]
|
20
|
+
if collection == '$cmd'
|
21
|
+
f = payload[:selector].first
|
22
|
+
name, collection = f if f
|
23
|
+
end
|
24
|
+
|
25
|
+
trace_execution_scoped("Database/#{collection}/#{name}") do
|
26
|
+
t0 = Time.now
|
27
|
+
res = instrument_without_newrelic_trace(name, payload, &blk)
|
28
|
+
NewRelic::Agent.instance.transaction_sampler.notice_sql(payload.inspect, nil, (Time.now - t0).to_f)
|
29
|
+
res
|
30
|
+
end
|
31
|
+
end
|
32
|
+
|
33
|
+
alias_method :instrument_without_newrelic_trace, :instrument
|
34
|
+
alias_method :instrument, :instrument_with_newrelic_trace
|
35
|
+
end
|
36
|
+
class Mongo::Collection; include Mongo::Logging; end
|
37
|
+
class Mongo::Connection; include Mongo::Logging; end
|
38
|
+
class Mongo::Cursor; include Mongo::Logging; end
|
39
|
+
|
40
|
+
# cursor refresh is not currently instrumented in mongo driver, so not picked up by above - have to add our own here
|
41
|
+
::Mongo::Cursor.class_eval do
|
42
|
+
include NewRelic::Agent::MethodTracer
|
43
|
+
|
44
|
+
def send_get_more_with_newrelic_trace
|
45
|
+
trace_execution_scoped("Database/#{collection.name}/refresh") do
|
46
|
+
send_get_more_without_newrelic_trace
|
47
|
+
end
|
48
|
+
end
|
49
|
+
alias_method :send_get_more_without_newrelic_trace, :send_get_more
|
50
|
+
alias_method :send_get_more, :send_get_more_with_newrelic_trace
|
51
|
+
add_method_tracer :close, 'Database/#{collection.name}/close'
|
52
|
+
end
|
53
|
+
end
|
54
|
+
|
55
|
+
end
|
@@ -0,0 +1,21 @@
|
|
1
|
+
DependencyDetection.defer do
|
2
|
+
@name = :mongoid
|
3
|
+
|
4
|
+
depends_on do
|
5
|
+
defined?(::Mongoid) and not NewRelic::Control.instance['disable_mongoid']
|
6
|
+
end
|
7
|
+
|
8
|
+
executes do
|
9
|
+
NewRelic::Agent.logger.debug 'Installing Mongoid 2.x instrumentation'
|
10
|
+
end
|
11
|
+
|
12
|
+
executes do
|
13
|
+
Mongoid::Collection.class_eval do
|
14
|
+
include NewRelic::Agent::MethodTracer
|
15
|
+
|
16
|
+
(Mongoid::Collections::Operations::ALL - [:<<, :[]]).each do |method|
|
17
|
+
add_method_tracer method, "ActiveRecord/\#{@klass}/#{method}"
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
@@ -0,0 +1,11 @@
|
|
1
|
+
require 'newrelic_rpm'
|
2
|
+
|
3
|
+
pattern = File.expand_path "../instrumentation/**/*.rb", __FILE__
|
4
|
+
Dir.glob pattern do |file|
|
5
|
+
begin
|
6
|
+
require file.to_s
|
7
|
+
rescue Exception => e
|
8
|
+
NewRelic::Agent.logger.error "Skipping instrumentation file '#{file}': #{e}"
|
9
|
+
NewRelic::Agent.logger.debug e.backtrace.join("\n")
|
10
|
+
end
|
11
|
+
end
|
metadata
ADDED
@@ -0,0 +1,97 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: newrelic_mongo
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.0.1
|
5
|
+
prerelease:
|
6
|
+
platform: ruby
|
7
|
+
authors:
|
8
|
+
- Raphael Crawford-Marks
|
9
|
+
autorequire:
|
10
|
+
bindir: bin
|
11
|
+
cert_chain: []
|
12
|
+
date: 2013-04-05 00:00:00.000000000 Z
|
13
|
+
dependencies:
|
14
|
+
- !ruby/object:Gem::Dependency
|
15
|
+
name: newrelic_rpm
|
16
|
+
requirement: !ruby/object:Gem::Requirement
|
17
|
+
none: false
|
18
|
+
requirements:
|
19
|
+
- - ~>
|
20
|
+
- !ruby/object:Gem::Version
|
21
|
+
version: 3.6.0
|
22
|
+
type: :runtime
|
23
|
+
prerelease: false
|
24
|
+
version_requirements: !ruby/object:Gem::Requirement
|
25
|
+
none: false
|
26
|
+
requirements:
|
27
|
+
- - ~>
|
28
|
+
- !ruby/object:Gem::Version
|
29
|
+
version: 3.6.0
|
30
|
+
- !ruby/object:Gem::Dependency
|
31
|
+
name: mongo
|
32
|
+
requirement: !ruby/object:Gem::Requirement
|
33
|
+
none: false
|
34
|
+
requirements:
|
35
|
+
- - ! '>='
|
36
|
+
- !ruby/object:Gem::Version
|
37
|
+
version: '0'
|
38
|
+
type: :runtime
|
39
|
+
prerelease: false
|
40
|
+
version_requirements: !ruby/object:Gem::Requirement
|
41
|
+
none: false
|
42
|
+
requirements:
|
43
|
+
- - ! '>='
|
44
|
+
- !ruby/object:Gem::Version
|
45
|
+
version: '0'
|
46
|
+
description: ! 'Community-contributed instrumentation for Mongo gem and Mongoid 2.x
|
47
|
+
for NewRelic.
|
48
|
+
|
49
|
+
'
|
50
|
+
email: raphael.crawfordmarks@gmail.com
|
51
|
+
executables: []
|
52
|
+
extensions: []
|
53
|
+
extra_rdoc_files:
|
54
|
+
- CHANGELOG
|
55
|
+
- LICENSE
|
56
|
+
- README.md
|
57
|
+
files:
|
58
|
+
- CHANGELOG
|
59
|
+
- Gemfile
|
60
|
+
- LICENSE
|
61
|
+
- README.md
|
62
|
+
- Rakefile
|
63
|
+
- lib/newrelic_mongo.rb
|
64
|
+
- lib/newrelic_mongo/instrumentation.rb
|
65
|
+
- lib/newrelic_mongo/instrumentation/mongo.rb
|
66
|
+
- lib/newrelic_mongo/instrumentation/mongoid.rb
|
67
|
+
homepage: http://github.com/raphaelcm/newrelic_mongo
|
68
|
+
licenses: []
|
69
|
+
post_install_message:
|
70
|
+
rdoc_options:
|
71
|
+
- --line-numbers
|
72
|
+
- --inline-source
|
73
|
+
- --title
|
74
|
+
- Contributed Instrumentation for New Relic RPM
|
75
|
+
- -m
|
76
|
+
- README.md
|
77
|
+
require_paths:
|
78
|
+
- lib
|
79
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
80
|
+
none: false
|
81
|
+
requirements:
|
82
|
+
- - ! '>='
|
83
|
+
- !ruby/object:Gem::Version
|
84
|
+
version: '0'
|
85
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
86
|
+
none: false
|
87
|
+
requirements:
|
88
|
+
- - ! '>='
|
89
|
+
- !ruby/object:Gem::Version
|
90
|
+
version: '0'
|
91
|
+
requirements: []
|
92
|
+
rubyforge_project:
|
93
|
+
rubygems_version: 1.8.24
|
94
|
+
signing_key:
|
95
|
+
specification_version: 3
|
96
|
+
summary: Mongo Gem and Mongoid 2.x instrumentation for NewRelic
|
97
|
+
test_files: []
|