newrelic_mongodb 0.0.8 → 0.1.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/lib/newrelic_mongodb/instrumentation.rb +23 -17
- data/lib/newrelic_mongodb/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 0265cccf0bf07d2e3643690dc529f817d3f9a10e
|
4
|
+
data.tar.gz: 6e6ec0df1e0c1a2bbfc49dd92e097e59ef623602
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 885f137fdf365cab9dcd0fc2c7fd4ec6bd38ae00456371ad3ff8a36b83e67cfe9e4ca0a2e60371ddd72f1acabfc4436004afe75d60ca9e5f13a5875b4487178f
|
7
|
+
data.tar.gz: 47a8c7754407f8e884afda65d8a9d465e33745398ff97b1f5ae0364a4c41d9433e09534815dad7ff6376e9c16978c0e3609937a7bed023bff075f588a15e8fa3
|
@@ -27,35 +27,41 @@ module NewRelic
|
|
27
27
|
module Instrumentation
|
28
28
|
module Mongodb
|
29
29
|
def logging_with_newrelic_trace(messages, operation_id = nil)
|
30
|
-
|
30
|
+
operation_name, collection_name = determine_operation_and_collection(messages.first)
|
31
31
|
command = Proc.new { logging_without_newrelic_trace(messages, operation_id) }
|
32
|
-
res = nil
|
33
32
|
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
33
|
+
operation_type = case operation_name.to_s
|
34
|
+
when *%w(delete) then 'destroy'
|
35
|
+
when *%w(find get_more query) then 'find'
|
36
|
+
when *%w(insert update) then 'save'
|
37
|
+
else
|
38
|
+
nil
|
39
|
+
end
|
39
40
|
|
40
|
-
if
|
41
|
+
if operation_type
|
41
42
|
callback = Proc.new do |result, metric, elapsed|
|
42
|
-
NewRelic::Agent::Datastores.notice_statement(
|
43
|
+
NewRelic::Agent::Datastores.notice_statement(operation_name, elapsed)
|
43
44
|
end
|
44
45
|
|
45
|
-
|
46
|
-
|
47
|
-
res = command.call
|
46
|
+
NewRelic::Agent::Datastores.wrap('MongoDB', operation_type, collection_name, callback) do
|
47
|
+
command.call
|
48
48
|
end
|
49
49
|
else
|
50
|
-
|
50
|
+
command.call
|
51
51
|
end
|
52
|
-
|
53
|
-
res
|
54
52
|
end
|
55
53
|
|
54
|
+
private
|
56
55
|
def determine_operation_and_collection(message)
|
57
|
-
|
58
|
-
|
56
|
+
operation_name = message.payload[:command_name]
|
57
|
+
|
58
|
+
collection_name = if (namespace_name = message.namespace.split('.').last) == '$cmd'
|
59
|
+
message.selector[operation_name]
|
60
|
+
else
|
61
|
+
namespace_name
|
62
|
+
end
|
63
|
+
|
64
|
+
[operation_name, collection_name]
|
59
65
|
end
|
60
66
|
end
|
61
67
|
end
|