newrelic_mongodb 0.0.8 → 0.1.0

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 CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA1:
3
- metadata.gz: b3a17754978a3401c8f1cf852100f50cda3d33cc
4
- data.tar.gz: ce7ee16b780d502fe686ad012a046f655a9b588d
3
+ metadata.gz: 0265cccf0bf07d2e3643690dc529f817d3f9a10e
4
+ data.tar.gz: 6e6ec0df1e0c1a2bbfc49dd92e097e59ef623602
5
5
  SHA512:
6
- metadata.gz: f781e2dad3973c5d6f3c28a641616db6cc36a6a1833d6e6d671aeb05cf34e7e457a38e3d11e9f550e84f5cfc7cc08a81190096f64cff05cb6ffa5912dddb2c1a
7
- data.tar.gz: 6ced51cfaedfd998a46d4defe0f4125d1f04d245e7c69f416e6c85515a4392792ae874cdcde0874da0290e9b4624cce5c5d7c3d02cffa5be1b2a6170dc8402e6
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
- log_statement, operation_name, collection_name = determine_operation_and_collection(messages.first)
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
- 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
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 op
41
+ if operation_type
41
42
  callback = Proc.new do |result, metric, elapsed|
42
- NewRelic::Agent::Datastores.notice_statement(log_statement, elapsed)
43
+ NewRelic::Agent::Datastores.notice_statement(operation_name, elapsed)
43
44
  end
44
45
 
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
46
+ NewRelic::Agent::Datastores.wrap('MongoDB', operation_type, collection_name, callback) do
47
+ command.call
48
48
  end
49
49
  else
50
- res = command.call
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
- # TODO figure out how to get the collection name correct
58
- [message.namespace, message.payload[:command_name], message.namespace.split('.').last]
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
@@ -1,3 +1,3 @@
1
1
  module NewrelicMongodb
2
- VERSION = '0.0.8'
2
+ VERSION = '0.1.0'
3
3
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_mongodb
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.0.8
4
+ version: 0.1.0
5
5
  platform: ruby
6
6
  authors:
7
7
  - William Li