newrelic_mongodb 0.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.
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 24b3e41a2f8f39011885972e33fcc620085007ac
4
+ data.tar.gz: 03e02a671b41f1b231243fdcad6565ac63ec277f
5
+ SHA512:
6
+ metadata.gz: a1c8b2dcd0a25bc7430079deee59d89984cf4311e810cc4aca93c5483c7dad6aff35788b92cf9a2a6bb844202cb5c6164ece25e8eff25c7abc72a7e381f6e567
7
+ data.tar.gz: 51b173a7e40331cddd15433f0178a9cf1fd76c9d9529f5665e30a53f76b1926fa74cb90e3edff8d8ed63ec02c1462836d81f708307233c84877d6daac33fe617
data/CHANGELOG.md ADDED
File without changes
data/LICENSE ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2015 William Li
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,34 @@
1
+ # New Relic Mongodb [![Build Status](https://travis-ci.org/weeyum/newrelic_mongodb.svg)](https://travis-ci.org/weeyum/newrelic_mongodb)
2
+
3
+ New Relic instrumentation for Mongo (2.10) / Mongoid (5.x)
4
+
5
+ ## Important
6
+
7
+ This gem is compatible only with __newrelic_rpm__ >= 3.11
8
+
9
+ ## Installation
10
+
11
+ Add this line to your application's Gemfile:
12
+
13
+ gem 'newrelic_mongodb'
14
+
15
+ And then execute:
16
+
17
+ $ bundle
18
+
19
+ Or install it yourself as:
20
+
21
+ $ gem install newrelic_mongodb
22
+
23
+ ### Configuration
24
+
25
+ This gem does not require any specific configuration. Please follow general newrelic_rpm gem configuration:
26
+ https://github.com/newrelic/rpm/blob/master/newrelic.yml
27
+
28
+ ## Contributing
29
+
30
+ 1. Fork it
31
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
32
+ 3. Commit your changes (`git commit -am 'Added some feature'`)
33
+ 4. Push to the branch (`git push origin my-new-feature`)
34
+ 5. Create new Pull Request
@@ -0,0 +1,2 @@
1
+ require "newrelic_mongodb/instrumentation"
2
+ require "newrelic_mongodb/version"
@@ -0,0 +1,63 @@
1
+ require 'new_relic/agent/method_tracer'
2
+ require 'new_relic/agent/datastores'
3
+
4
+ DependencyDetection.defer do
5
+ @name = :mongodb
6
+
7
+ depends_on do
8
+ defined?(::Mongo) && defined?(::Mongo::Server::Connection)
9
+ end
10
+
11
+ executes do
12
+ NewRelic::Agent.logger.info 'Installing Mongodb instrumentation'
13
+ end
14
+
15
+ executes do
16
+ Mongo::Server::Connection.class_eval do
17
+ include NewRelic::Agent::Instrumentation::Mongodb
18
+
19
+ alias_method :logging_without_newrelic_trace, :dispatch
20
+ alias_method :dispatch, :logging_with_newrelic_trace
21
+ end
22
+ end
23
+ end
24
+
25
+ module NewRelic
26
+ module Agent
27
+ module Instrumentation
28
+ module Mongodb
29
+ def logging_with_newrelic_trace(messages, operation_id = nil)
30
+ log_statement, operation_name, collection_name = determine_operation_and_collection(messages.first)
31
+ command = Proc.new { logging_without_newrelic_trace(messages, operation_id) }
32
+ res = nil
33
+
34
+ op = case operation_name.to_s
35
+ when *%w(delete) then 'destroy'
36
+ when *%w(find get_more query) then 'find'
37
+ when *%w(insert update) then 'save'
38
+ end
39
+
40
+ if op
41
+ callback = Proc.new do |result, metric, elapsed|
42
+ NewRelic::Agent::Datastores.notice_statement(log_statement, elapsed)
43
+ end
44
+
45
+ # TODO add use of collection name here once it is figured out
46
+ NewRelic::Agent::Datastores.wrap('MongoDB', op, nil, callback) do
47
+ res = command.call
48
+ end
49
+ else
50
+ res = command.call
51
+ end
52
+
53
+ res
54
+ end
55
+
56
+ def determine_operation_and_collection(message)
57
+ # TODO figure out how to get the collection name correct
58
+ [message.namespace, message.payload[:command_name], message.namespace.split('.').last]
59
+ end
60
+ end
61
+ end
62
+ end
63
+ end
@@ -0,0 +1,3 @@
1
+ module NewrelicMongodb
2
+ VERSION = '0.0.7'
3
+ end
metadata ADDED
@@ -0,0 +1,107 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: newrelic_mongodb
3
+ version: !ruby/object:Gem::Version
4
+ version: 0.0.7
5
+ platform: ruby
6
+ authors:
7
+ - William Li
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2015-07-25 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: newrelic_rpm
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - "~>"
18
+ - !ruby/object:Gem::Version
19
+ version: '3.11'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - "~>"
25
+ - !ruby/object:Gem::Version
26
+ version: '3.11'
27
+ - !ruby/object:Gem::Dependency
28
+ name: mongo
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - '='
32
+ - !ruby/object:Gem::Version
33
+ version: 2.1.0.beta
34
+ type: :runtime
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - '='
39
+ - !ruby/object:Gem::Version
40
+ version: 2.1.0.beta
41
+ - !ruby/object:Gem::Dependency
42
+ name: rake
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: test-unit
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: New Relic instrumentation for Mongo Ruby Driver(2.x) / Mongoid (5.x)
70
+ email:
71
+ - weeyum@gmail.com
72
+ executables: []
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - CHANGELOG.md
77
+ - LICENSE
78
+ - README.md
79
+ - lib/newrelic_mongodb.rb
80
+ - lib/newrelic_mongodb/instrumentation.rb
81
+ - lib/newrelic_mongodb/version.rb
82
+ homepage: https://github.com/weeyum/newrelic_mongodb
83
+ licenses:
84
+ - MIT
85
+ metadata: {}
86
+ post_install_message:
87
+ rdoc_options: []
88
+ require_paths:
89
+ - lib
90
+ required_ruby_version: !ruby/object:Gem::Requirement
91
+ requirements:
92
+ - - ">="
93
+ - !ruby/object:Gem::Version
94
+ version: '0'
95
+ required_rubygems_version: !ruby/object:Gem::Requirement
96
+ requirements:
97
+ - - ">="
98
+ - !ruby/object:Gem::Version
99
+ version: '0'
100
+ requirements: []
101
+ rubyforge_project:
102
+ rubygems_version: 2.4.5
103
+ signing_key:
104
+ specification_version: 4
105
+ summary: New Relic instrumentation for Mongo Ruby Driver(2.x) / Mongoid (5.x)
106
+ test_files: []
107
+ has_rdoc: