oboe 2.7.1.7 → 2.7.2.fuchs1

Sign up to get free protection for your applications and to get access to all the features.
Files changed (58) hide show
  1. checksums.yaml +4 -4
  2. data/.rubocop.yml +5 -0
  3. data/Gemfile +2 -0
  4. data/README.md +3 -3
  5. data/ext/oboe_metal/extconf.rb +11 -11
  6. data/lib/joboe_metal.rb +36 -42
  7. data/lib/oboe.rb +29 -26
  8. data/lib/oboe/api.rb +4 -0
  9. data/lib/oboe/api/layerinit.rb +7 -67
  10. data/lib/oboe/api/logging.rb +50 -28
  11. data/lib/oboe/api/memcache.rb +7 -5
  12. data/lib/oboe/api/profiling.rb +4 -4
  13. data/lib/oboe/api/tracing.rb +6 -5
  14. data/lib/oboe/api/util.rb +13 -9
  15. data/lib/oboe/base.rb +55 -16
  16. data/lib/oboe/config.rb +17 -15
  17. data/lib/oboe/frameworks/padrino.rb +0 -2
  18. data/lib/oboe/frameworks/padrino/templates.rb +5 -6
  19. data/lib/oboe/frameworks/rails.rb +0 -1
  20. data/lib/oboe/frameworks/rails/inst/action_controller.rb +4 -5
  21. data/lib/oboe/frameworks/rails/inst/action_view.rb +4 -4
  22. data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +4 -4
  23. data/lib/oboe/frameworks/rails/inst/action_view_30.rb +2 -2
  24. data/lib/oboe/frameworks/rails/inst/active_record.rb +5 -5
  25. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +6 -6
  26. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +3 -3
  27. data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
  28. data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +3 -3
  29. data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +18 -19
  30. data/lib/oboe/frameworks/sinatra.rb +4 -5
  31. data/lib/oboe/inst/cassandra.rb +17 -19
  32. data/lib/oboe/inst/dalli.rb +5 -5
  33. data/lib/oboe/inst/em-http-request.rb +13 -13
  34. data/lib/oboe/inst/faraday.rb +71 -0
  35. data/lib/oboe/inst/http.rb +4 -4
  36. data/lib/oboe/inst/memcache.rb +7 -10
  37. data/lib/oboe/inst/memcached.rb +7 -9
  38. data/lib/oboe/inst/mongo.rb +26 -28
  39. data/lib/oboe/inst/moped.rb +23 -24
  40. data/lib/oboe/inst/rack.rb +10 -11
  41. data/lib/oboe/inst/redis.rb +18 -20
  42. data/lib/oboe/inst/resque.rb +8 -9
  43. data/lib/oboe/instrumentation.rb +3 -0
  44. data/lib/oboe/loading.rb +19 -23
  45. data/lib/{method_profiling.rb → oboe/method_profiling.rb} +22 -8
  46. data/lib/oboe/ruby.rb +23 -3
  47. data/lib/oboe/support.rb +94 -0
  48. data/lib/oboe/thread_local.rb +9 -1
  49. data/lib/oboe/util.rb +90 -18
  50. data/lib/oboe/version.rb +5 -2
  51. data/lib/oboe/xtrace.rb +20 -24
  52. data/lib/oboe_metal.rb +16 -13
  53. data/lib/rails/generators/oboe/templates/oboe_initializer.rb +2 -0
  54. data/test/instrumentation/faraday_test.rb +142 -0
  55. data/test/instrumentation/moped_test.rb +2 -0
  56. data/test/minitest_helper.rb +0 -1
  57. data/test/support/config_test.rb +3 -1
  58. metadata +10 -5
@@ -8,10 +8,10 @@ module Oboe
8
8
  blacklisted = Oboe::API.blacklisted?(@uri)
9
9
 
10
10
  begin
11
- report_kvs["IsService"] = 1
12
- report_kvs["RemoteURL"] = @uri
13
- report_kvs["HTTPMethod"] = args[0]
14
- report_kvs["Blacklisted"] = true if blacklisted
11
+ report_kvs['IsService'] = 1
12
+ report_kvs['RemoteURL'] = @uri
13
+ report_kvs['HTTPMethod'] = args[0]
14
+ report_kvs['Blacklisted'] = true if blacklisted
15
15
 
16
16
  if Oboe::Config[:em_http_request][:collect_backtraces]
17
17
  report_kvs[:Backtrace] = Oboe::API.backtrace
@@ -20,9 +20,9 @@ module Oboe
20
20
  Oboe.logger.debug "[oboe/debug] em-http-request KV error: #{e.inspect}"
21
21
  end
22
22
 
23
- ::Oboe::API.log_entry("em-http-request", report_kvs)
23
+ ::Oboe::API.log_entry('em-http-request', report_kvs)
24
24
  client = setup_request_without_oboe(*args, &block)
25
- client.req.headers["X-Trace"] = context unless blacklisted
25
+ client.req.headers['X-Trace'] = context unless blacklisted
26
26
  client
27
27
  end
28
28
  end
@@ -47,8 +47,8 @@ module Oboe
47
47
  context = Oboe::Context.toString
48
48
  task_id = Oboe::XTrace.task_id(context)
49
49
 
50
- if headers.is_a?(Hash) && headers.has_key?("X-Trace")
51
- xtrace = headers["X-Trace"]
50
+ if headers.is_a?(Hash) && headers.key?('X-Trace')
51
+ xtrace = headers['X-Trace']
52
52
  end
53
53
 
54
54
  if Oboe::XTrace.valid?(xtrace) && Oboe.tracing?
@@ -63,16 +63,16 @@ module Oboe
63
63
 
64
64
  end
65
65
 
66
- ::Oboe::API.log_exit("em-http-request", report_kvs)
66
+ ::Oboe::API.log_exit('em-http-request', report_kvs)
67
67
  end
68
68
  end
69
69
  end
70
70
  end
71
71
  end
72
72
 
73
- if RUBY_VERSION >= "1.9"
73
+ if RUBY_VERSION >= '1.9'
74
74
  if defined?(::EventMachine::HttpConnection) && defined?(::EventMachine::HttpClient) && Oboe::Config[:em_http_request][:enabled]
75
- Oboe.logger.info "[oboe/loading] Instrumenting em-http-request" if Oboe::Config[:verbose]
75
+ Oboe.logger.info '[oboe/loading] Instrumenting em-http-request' if Oboe::Config[:verbose]
76
76
 
77
77
  class ::EventMachine::HttpConnection
78
78
  include Oboe::Inst::EventMachine::HttpConnection
@@ -81,7 +81,7 @@ if RUBY_VERSION >= "1.9"
81
81
  class_eval 'alias :setup_request_without_oboe :setup_request'
82
82
  class_eval 'alias :setup_request :setup_request_with_oboe'
83
83
  else
84
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument em-http-request (:setup_request). Partial traces may occur."
84
+ Oboe.logger.warn '[oboe/loading] Couldn\'t properly instrument em-http-request (:setup_request). Partial traces may occur.'
85
85
  end
86
86
  end
87
87
 
@@ -92,7 +92,7 @@ if RUBY_VERSION >= "1.9"
92
92
  class_eval 'alias :parse_response_header_without_oboe :parse_response_header'
93
93
  class_eval 'alias :parse_response_header :parse_response_header_with_oboe'
94
94
  else
95
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument em-http-request (:parse_response_header). Partial traces may occur."
95
+ Oboe.logger.warn '[oboe/loading] Couldn\'t properly instrument em-http-request (:parse_response_header). Partial traces may occur.'
96
96
  end
97
97
  end
98
98
  end
@@ -0,0 +1,71 @@
1
+ module Oboe
2
+ module Inst
3
+ module FaradayConnection
4
+ def self.included(klass)
5
+ ::Oboe::Util.method_alias(klass, :run_request, ::Faraday::Connection)
6
+ end
7
+
8
+ def run_request_with_oboe(method, url, body, headers)
9
+ kvs = {}
10
+ kvs['Middleware'] = @builder.handlers
11
+ kvs['Backtrace'] = Oboe::API.backtrace if Oboe::Config[:faraday][:collect_backtraces]
12
+
13
+ # Only send service KVs if we're not using the Net::HTTP adapter
14
+ # Otherwise, the Net::HTTP instrumentation will send the service KVs
15
+ handle_service = !@builder.handlers.include?(Faraday::Adapter::NetHttp)
16
+
17
+ if handle_service
18
+ blacklisted = Oboe::API.blacklisted?(@url_prefix.to_s)
19
+ context = Oboe::Context.toString
20
+ task_id = Oboe::XTrace.task_id(context)
21
+
22
+ # Avoid cross host tracing for blacklisted domains
23
+ # Conditionally add the X-Trace header to the outgoing request
24
+ @headers['X-Trace'] = context unless blacklisted
25
+
26
+ kvs['IsService'] = 1
27
+ kvs['RemoteProtocol'] = (@url_prefix.scheme == 'https') ? 'HTTPS' : 'HTTP'
28
+ kvs['RemoteHost'] = @url_prefix.host
29
+ kvs['RemotePort'] = @url_prefix.port
30
+ kvs['ServiceArg'] = url
31
+ kvs['HTTPMethod'] = method
32
+ kvs['Blacklisted'] = true if blacklisted
33
+ end
34
+
35
+ Oboe::API.log_entry('faraday', kvs)
36
+ result = run_request_without_oboe(method, url, body, headers)
37
+
38
+ # Re-attach net::http edge unless it's blacklisted or if we don't have a
39
+ # valid X-Trace header
40
+ if handle_service && !blacklisted
41
+ xtrace = result.headers['X-Trace']
42
+
43
+ if Oboe::XTrace.valid?(xtrace) && Oboe.tracing?
44
+
45
+ # Assure that we received back a valid X-Trace with the same task_id
46
+ if task_id == Oboe::XTrace.task_id(xtrace)
47
+ Oboe::Context.fromString(xtrace)
48
+ else
49
+ Oboe.logger.debug "Mismatched returned X-Trace ID: #{xtrace}"
50
+ end
51
+ end
52
+ end
53
+
54
+ Oboe::API.log('faraday', 'info', :HTTPStatus => result.status) if handle_service
55
+ result
56
+ rescue => e
57
+ Oboe::API.log_exception('faraday', e)
58
+ raise e
59
+ ensure
60
+ Oboe::API.log_exit('faraday')
61
+ end
62
+ end
63
+ end
64
+ end
65
+
66
+ if Oboe::Config[:faraday][:enabled]
67
+ if defined?(::Faraday)
68
+ Oboe.logger.info '[oboe/loading] Instrumenting faraday'
69
+ ::Oboe::Util.send_include(::Faraday::Connection, ::Oboe::Inst::FaradayConnection)
70
+ end
71
+ end
@@ -20,7 +20,7 @@ if Oboe::Config[:nethttp][:enabled]
20
20
  task_id = Oboe::XTrace.task_id(context)
21
21
 
22
22
  # Collect KVs to report in the info event
23
- if args.length and args[0]
23
+ if args.length && args[0]
24
24
  req = args[0]
25
25
 
26
26
  opts['IsService'] = 1
@@ -41,9 +41,9 @@ if Oboe::Config[:nethttp][:enabled]
41
41
  # Re-attach net::http edge unless blacklisted and is a valid X-Trace ID
42
42
  unless blacklisted
43
43
  xtrace = resp.get_fields('X-Trace')
44
- xtrace = xtrace[0] if xtrace and xtrace.is_a?(Array)
44
+ xtrace = xtrace[0] if xtrace && xtrace.is_a?(Array)
45
45
 
46
- if Oboe::XTrace.valid?(xtrace) and Oboe.tracing?
46
+ if Oboe::XTrace.valid?(xtrace) && Oboe.tracing?
47
47
 
48
48
  # Assure that we received back a valid X-Trace with the same task_id
49
49
  if task_id == Oboe::XTrace.task_id(xtrace)
@@ -67,6 +67,6 @@ if Oboe::Config[:nethttp][:enabled]
67
67
  alias request_without_oboe request
68
68
  alias request request_with_oboe
69
69
 
70
- Oboe.logger.info "[oboe/loading] Instrumenting net/http" if Oboe::Config[:verbose]
70
+ Oboe.logger.info '[oboe/loading] Instrumenting net/http' if Oboe::Config[:verbose]
71
71
  end
72
72
  end
@@ -7,10 +7,10 @@ module Oboe
7
7
  include Oboe::API::Memcache
8
8
 
9
9
  def self.included(cls)
10
- Oboe.logger.info "[oboe/loading] Instrumenting memcache" if Oboe::Config[:verbose]
10
+ Oboe.logger.info '[oboe/loading] Instrumenting memcache' if Oboe::Config[:verbose]
11
11
 
12
12
  cls.class_eval do
13
- MEMCACHE_OPS.reject { |m| not method_defined?(m) }.each do |m|
13
+ MEMCACHE_OPS.reject { |m| !method_defined?(m) }.each do |m|
14
14
 
15
15
  define_method("#{m}_with_oboe") do |*args|
16
16
  report_kvs = { :KVOp => m }
@@ -18,12 +18,11 @@ module Oboe
18
18
 
19
19
  if Oboe.tracing?
20
20
  Oboe::API.trace('memcache', report_kvs) do
21
- result = send("#{m}_without_oboe", *args)
21
+ send("#{m}_without_oboe", *args)
22
22
  end
23
23
  else
24
- result = send("#{m}_without_oboe", *args)
24
+ send("#{m}_without_oboe", *args)
25
25
  end
26
- result
27
26
  end
28
27
 
29
28
  class_eval "alias #{m}_without_oboe #{m}"
@@ -59,7 +58,7 @@ module Oboe
59
58
  Oboe.logger.debug e.backtrace
60
59
  end
61
60
 
62
- Oboe::API.trace('memcache', {:KVOp => :get_multi}, :get_multi) do
61
+ Oboe::API.trace('memcache', { :KVOp => :get_multi }, :get_multi) do
63
62
  values = get_multi_without_oboe(args)
64
63
 
65
64
  info_kvs[:KVHitCount] = values.length
@@ -70,7 +69,7 @@ module Oboe
70
69
  end
71
70
 
72
71
  def request_setup_with_oboe(*args)
73
- if Oboe.tracing? and not Oboe.tracing_layer_op?(:get_multi)
72
+ if Oboe.tracing? && !Oboe.tracing_layer_op?(:get_multi)
74
73
  server, cache_key = request_setup_without_oboe(*args)
75
74
 
76
75
  info_kvs = { :KVKey => cache_key, :RemoteHost => server.host }
@@ -92,14 +91,12 @@ module Oboe
92
91
 
93
92
  result
94
93
  end
95
-
96
94
  end # module MemCache
97
95
  end # module Inst
98
96
  end # module Oboe
99
97
 
100
- if defined?(::MemCache) and Oboe::Config[:memcache][:enabled]
98
+ if defined?(::MemCache) && Oboe::Config[:memcache][:enabled]
101
99
  ::MemCache.class_eval do
102
100
  include Oboe::Inst::MemCache
103
101
  end
104
102
  end
105
-
@@ -7,14 +7,14 @@ module Oboe
7
7
  include Oboe::API::Memcache
8
8
 
9
9
  def self.included(cls)
10
- Oboe.logger.info "[oboe/loading] Instrumenting memcached" if Oboe::Config[:verbose]
10
+ Oboe.logger.info '[oboe/loading] Instrumenting memcached' if Oboe::Config[:verbose]
11
11
 
12
12
  cls.class_eval do
13
- MEMCACHE_OPS.reject { |m| not method_defined?(m) }.each do |m|
13
+ MEMCACHE_OPS.reject { |m| !method_defined?(m) }.each do |m|
14
14
  define_method("#{m}_with_oboe") do |*args|
15
15
  opts = { :KVOp => m }
16
16
 
17
- if args.length and args[0].class != Array
17
+ if args.length && !args[0].is_a?(Array)
18
18
  opts[:KVKey] = args[0].to_s
19
19
  rhost = remote_host(args[0].to_s)
20
20
  opts[:RemoteHost] = rhost if rhost
@@ -24,7 +24,7 @@ module Oboe
24
24
  result = send("#{m}_without_oboe", *args)
25
25
 
26
26
  info_kvs = {}
27
- info_kvs[:KVHit] = memcache_hit?(result) if m == :get and args.length and args[0].class == String
27
+ info_kvs[:KVHit] = memcache_hit?(result) if m == :get && args.length && args[0].class == String
28
28
  info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcached][:collect_backtraces]
29
29
 
30
30
  Oboe::API.log('memcache', 'info', info_kvs) unless info_kvs.empty?
@@ -47,12 +47,12 @@ module Oboe
47
47
  alias get_multi_without_oboe get_multi
48
48
  alias get_multi get_multi_with_oboe
49
49
  elsif Oboe::Config[:verbose]
50
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcached. Partial traces may occur."
50
+ Oboe.logger.warn '[oboe/loading] Couldn\'t properly instrument Memcached. Partial traces may occur.'
51
51
  end
52
52
  end
53
53
  end
54
54
 
55
- def get_multi_with_oboe(keys, raw=false)
55
+ def get_multi_with_oboe(keys, raw = false)
56
56
  if Oboe.tracing?
57
57
  layer_kvs = {}
58
58
  layer_kvs[:KVOp] = :get_multi
@@ -77,12 +77,11 @@ module Oboe
77
77
  get_multi_without_oboe(keys, raw)
78
78
  end
79
79
  end
80
-
81
80
  end # module MemcachedRails
82
81
  end # module Inst
83
82
  end # module Oboe
84
83
 
85
- if defined?(::Memcached) and Oboe::Config[:memcached][:enabled]
84
+ if defined?(::Memcached) && Oboe::Config[:memcached][:enabled]
86
85
  ::Memcached.class_eval do
87
86
  include Oboe::Inst::Memcached
88
87
  end
@@ -93,4 +92,3 @@ if defined?(::Memcached) and Oboe::Config[:memcached][:enabled]
93
92
  end
94
93
  end
95
94
  end
96
-
@@ -9,21 +9,21 @@ module Oboe
9
9
  FLAVOR = 'mongodb'
10
10
 
11
11
  # Operations for Mongo::DB
12
- DB_OPS = [ :create_collection, :drop_collection ]
12
+ DB_OPS = [:create_collection, :drop_collection]
13
13
 
14
14
  # Operations for Mongo::Cursor
15
- CURSOR_OPS = [ :count ]
15
+ CURSOR_OPS = [:count]
16
16
 
17
17
  # Operations for Mongo::Collection
18
- COLL_WRITE_OPS = [ :find_and_modify, :insert, :map_reduce, :remove, :rename, :update ]
19
- COLL_QUERY_OPS = [ :distinct, :find, :group ]
20
- COLL_INDEX_OPS = [ :create_index, :drop_index, :drop_indexes, :ensure_index, :index_information ]
18
+ COLL_WRITE_OPS = [:find_and_modify, :insert, :map_reduce, :remove, :rename, :update]
19
+ COLL_QUERY_OPS = [:distinct, :find, :group]
20
+ COLL_INDEX_OPS = [:create_index, :drop_index, :drop_indexes, :ensure_index, :index_information]
21
21
  end
22
22
  end
23
23
  end
24
24
 
25
- if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
26
- Oboe.logger.info "[oboe/loading] Instrumenting mongo" if Oboe::Config[:verbose]
25
+ if defined?(::Mongo) && Oboe::Config[:mongo][:enabled]
26
+ Oboe.logger.info '[oboe/loading] Instrumenting mongo' if Oboe::Config[:verbose]
27
27
 
28
28
  if defined?(::Mongo::DB)
29
29
  module ::Mongo
@@ -31,7 +31,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
31
31
  include Oboe::Inst::Mongo
32
32
 
33
33
  # Instrument DB operations
34
- Oboe::Inst::Mongo::DB_OPS.reject { |m| not method_defined?(m) }.each do |m|
34
+ Oboe::Inst::Mongo::DB_OPS.reject { |m| !method_defined?(m) }.each do |m|
35
35
  define_method("#{m}_with_oboe") do |*args|
36
36
  report_kvs = {}
37
37
 
@@ -77,7 +77,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
77
77
  include Oboe::Inst::Mongo
78
78
 
79
79
  # Instrument DB cursor operations
80
- Oboe::Inst::Mongo::CURSOR_OPS.reject { |m| not method_defined?(m) }.each do |m|
80
+ Oboe::Inst::Mongo::CURSOR_OPS.reject { |m| !method_defined?(m) }.each do |m|
81
81
  define_method("#{m}_with_oboe") do |*args|
82
82
  report_kvs = {}
83
83
 
@@ -130,7 +130,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
130
130
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:mongo][:collect_backtraces]
131
131
 
132
132
  report_kvs[:QueryOp] = m
133
- report_kvs[:Query] = args[0].to_json if args and not args.empty? and args[0].class == Hash
133
+ report_kvs[:Query] = args[0].to_json if args && !args.empty? && args[0].class == Hash
134
134
  rescue StandardError => e
135
135
  Oboe.logger.debug "[oboe/debug] Exception in oboe_collect KV collection: #{e.inspect}"
136
136
  end
@@ -138,20 +138,20 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
138
138
  end
139
139
 
140
140
  # Instrument Collection write operations
141
- Oboe::Inst::Mongo::COLL_WRITE_OPS.reject { |m| not method_defined?(m) }.each do |m|
141
+ Oboe::Inst::Mongo::COLL_WRITE_OPS.reject { |m| !method_defined?(m) }.each do |m|
142
142
  define_method("#{m}_with_oboe") do |*args|
143
143
  report_kvs = oboe_collect(m, args)
144
144
  args_length = args.length
145
145
 
146
146
  begin
147
- if m == :find_and_modify and args[0] and args[0].has_key?(:update)
147
+ if m == :find_and_modify && args[0] && args[0].key?(:update)
148
148
  report_kvs[:Update_Document] = args[0][:update].inspect
149
149
  end
150
150
 
151
151
  if m == :map_reduce
152
152
  report_kvs[:Map_Function] = args[0]
153
153
  report_kvs[:Reduce_Function] = args[1]
154
- report_kvs[:Limit] = args[2][:limit] if args[2] and args[2].has_key?(:limit)
154
+ report_kvs[:Limit] = args[2][:limit] if args[2] && args[2].key?(:limit)
155
155
  end
156
156
 
157
157
  report_kvs[:New_Collection_Name] = args[0] if m == :rename
@@ -159,7 +159,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
159
159
  if m == :update
160
160
  if args_length >= 3
161
161
  report_kvs[:Update_Document] = args[1].to_json
162
- report_kvs[:Multi] = args[2][:multi] if args[2] and args[2].has_key?(:multi)
162
+ report_kvs[:Multi] = args[2][:multi] if args[2] && args[2].key?(:multi)
163
163
  end
164
164
  end
165
165
  rescue
@@ -175,28 +175,28 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
175
175
  end
176
176
 
177
177
  # Instrument Collection query operations
178
- Oboe::Inst::Mongo::COLL_QUERY_OPS.reject { |m| not method_defined?(m) }.each do |m|
178
+ Oboe::Inst::Mongo::COLL_QUERY_OPS.reject { |m| !method_defined?(m) }.each do |m|
179
179
  define_method("#{m}_with_oboe") do |*args, &blk|
180
180
  begin
181
181
  report_kvs = oboe_collect(m, args)
182
182
  args_length = args.length
183
183
 
184
- if m == :distinct and args_length >= 2
184
+ if m == :distinct && args_length >= 2
185
185
  report_kvs[:Key] = args[0]
186
- report_kvs[:Query] = args[1].to_json if args[1] and args[1].class == Hash
186
+ report_kvs[:Query] = args[1].to_json if args[1] && args[1].class == Hash
187
187
  end
188
188
 
189
- if m == :find and args_length > 0
190
- report_kvs[:Limit] = args[0][:limit] if !args[0].nil? and args[0].has_key?(:limit)
189
+ if m == :find && args_length > 0
190
+ report_kvs[:Limit] = args[0][:limit] if !args[0].nil? && args[0].key?(:limit)
191
191
  end
192
192
 
193
193
  if m == :group
194
194
  unless args.empty?
195
195
  if args[0].is_a?(Hash)
196
- report_kvs[:Group_Key] = args[0][:key].to_json if args[0].has_key?(:key)
197
- report_kvs[:Group_Condition] = args[0][:cond].to_json if args[0].has_key?(:cond)
198
- report_kvs[:Group_Initial] = args[0][:initial].to_json if args[0].has_key?(:initial)
199
- report_kvs[:Group_Reduce] = args[0][:reduce] if args[0].has_key?(:reduce)
196
+ report_kvs[:Group_Key] = args[0][:key].to_json if args[0].key?(:key)
197
+ report_kvs[:Group_Condition] = args[0][:cond].to_json if args[0].key?(:cond)
198
+ report_kvs[:Group_Initial] = args[0][:initial].to_json if args[0].key?(:initial)
199
+ report_kvs[:Group_Reduce] = args[0][:reduce] if args[0].key?(:reduce)
200
200
  end
201
201
  end
202
202
  end
@@ -213,14 +213,13 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
213
213
  end
214
214
 
215
215
  # Instrument Collection index operations
216
- Oboe::Inst::Mongo::COLL_INDEX_OPS.reject { |m| not method_defined?(m) }.each do |m|
216
+ Oboe::Inst::Mongo::COLL_INDEX_OPS.reject { |m| !method_defined?(m) }.each do |m|
217
217
  define_method("#{m}_with_oboe") do |*args|
218
218
  report_kvs = oboe_collect(m, args)
219
- _args = args || []
220
219
 
221
220
  begin
222
- if [:create_index, :ensure_index, :drop_index].include? m and not _args.empty?
223
- report_kvs[:Index] = _args[0].to_json
221
+ if [:create_index, :ensure_index, :drop_index].include?(m) && !args.empty?
222
+ report_kvs[:Index] = args[0].to_json
224
223
  end
225
224
  rescue
226
225
  end
@@ -237,4 +236,3 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
237
236
  end
238
237
  end
239
238
  end
240
-
@@ -9,23 +9,23 @@ module Oboe
9
9
  FLAVOR = 'mongodb'
10
10
 
11
11
  # Moped::Database
12
- DB_OPS = [ :command, :drop ]
12
+ DB_OPS = [:command, :drop]
13
13
 
14
14
  # Moped::Indexes
15
- INDEX_OPS = [ :create, :drop ]
15
+ INDEX_OPS = [:create, :drop]
16
16
 
17
17
  # Moped::Query
18
- QUERY_OPS = [ :count, :sort, :limit, :distinct, :update, :update_all, :upsert,
19
- :explain, :modify, :remove, :remove_all ]
18
+ QUERY_OPS = [:count, :sort, :limit, :distinct, :update, :update_all, :upsert,
19
+ :explain, :modify, :remove, :remove_all]
20
20
 
21
21
  # Moped::Collection
22
- COLLECTION_OPS = [ :drop, :find, :indexes, :insert, :aggregate ]
22
+ COLLECTION_OPS = [:drop, :find, :indexes, :insert, :aggregate]
23
23
  end
24
24
  end
25
25
  end
26
26
 
27
- if defined?(::Moped) and Oboe::Config[:moped][:enabled]
28
- Oboe.logger.info "[oboe/loading] Instrumenting moped" if Oboe::Config[:verbose]
27
+ if defined?(::Moped) && Oboe::Config[:moped][:enabled]
28
+ Oboe.logger.info '[oboe/loading] Instrumenting moped' if Oboe::Config[:verbose]
29
29
 
30
30
  if defined?(::Moped::Database)
31
31
  module ::Moped
@@ -37,7 +37,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
37
37
  begin
38
38
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
39
39
  # FIXME: We're only grabbing the first of potentially multiple servers here
40
- if ::Moped::VERSION < "2.0.0"
40
+ if ::Moped::VERSION < '2.0.0'
41
41
  report_kvs[:RemoteHost], report_kvs[:RemotePort] = session.cluster.seeds.first.split(':')
42
42
  else
43
43
  report_kvs[:RemoteHost] = session.cluster.seeds.first.address.host
@@ -53,7 +53,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
53
53
  end
54
54
 
55
55
  def command_with_oboe(command)
56
- if Oboe.tracing? and not Oboe.layer_op and command.has_key?(:mapreduce)
56
+ if Oboe.tracing? && !Oboe.layer_op && command.key?(:mapreduce)
57
57
  begin
58
58
  report_kvs = extract_trace_details(:map_reduce)
59
59
  report_kvs[:Map_Function] = command[:map]
@@ -101,7 +101,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
101
101
  begin
102
102
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
103
103
  # FIXME: We're only grabbing the first of potentially multiple servers here
104
- if ::Moped::VERSION < "2.0.0"
104
+ if ::Moped::VERSION < '2.0.0'
105
105
  report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
106
106
  else
107
107
  report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host
@@ -141,7 +141,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
141
141
  # We report :drop_indexes here to be consistent
142
142
  # with other mongo implementations
143
143
  report_kvs = extract_trace_details(:drop_indexes)
144
- report_kvs[:Key] = key.nil? ? "all" : key.to_json
144
+ report_kvs[:Key] = key.nil? ? 'all' : key.to_json
145
145
  rescue StandardError => e
146
146
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
147
147
  end
@@ -172,7 +172,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
172
172
  begin
173
173
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
174
174
  # FIXME: We're only grabbing the first of potentially multiple servers here
175
- if ::Moped::VERSION < "2.0.0"
175
+ if ::Moped::VERSION < '2.0.0'
176
176
  report_kvs[:RemoteHost], report_kvs[:RemotePort] = collection.database.session.cluster.seeds.first.split(':')
177
177
  else
178
178
  report_kvs[:RemoteHost] = collection.database.session.cluster.seeds.first.address.host
@@ -193,7 +193,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
193
193
 
194
194
  begin
195
195
  report_kvs = extract_trace_details(:count)
196
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
196
+ report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
197
197
  rescue StandardError => e
198
198
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
199
199
  end
@@ -208,7 +208,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
208
208
 
209
209
  begin
210
210
  report_kvs = extract_trace_details(:sort)
211
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
211
+ report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
212
212
  report_kvs[:Order] = sort.to_s
213
213
  rescue StandardError => e
214
214
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
@@ -220,10 +220,10 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
220
220
  end
221
221
 
222
222
  def limit_with_oboe(limit)
223
- if Oboe.tracing? and not Oboe.tracing_layer_op?(:explain)
223
+ if Oboe.tracing? && !Oboe.tracing_layer_op?(:explain)
224
224
  begin
225
225
  report_kvs = extract_trace_details(:limit)
226
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
226
+ report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
227
227
  report_kvs[:Limit] = limit.to_s
228
228
  rescue StandardError => e
229
229
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
@@ -242,7 +242,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
242
242
 
243
243
  begin
244
244
  report_kvs = extract_trace_details(:distinct)
245
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
245
+ report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
246
246
  report_kvs[:Key] = key.to_s
247
247
  rescue StandardError => e
248
248
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
@@ -254,7 +254,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
254
254
  end
255
255
 
256
256
  def update_with_oboe(change, flags = nil)
257
- if Oboe.tracing? and not Oboe.tracing_layer_op?([:update_all, :upsert])
257
+ if Oboe.tracing? && !Oboe.tracing_layer_op?([:update_all, :upsert])
258
258
  begin
259
259
  report_kvs = extract_trace_details(:update)
260
260
  report_kvs[:Flags] = flags.to_s if flags
@@ -307,7 +307,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
307
307
 
308
308
  begin
309
309
  report_kvs = extract_trace_details(:explain)
310
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
310
+ report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
311
311
  rescue StandardError => e
312
312
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
313
313
  end
@@ -322,7 +322,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
322
322
 
323
323
  begin
324
324
  report_kvs = extract_trace_details(:modify)
325
- report_kvs[:Update_Document] = selector.empty? ? "all" : selector.to_json
325
+ report_kvs[:Update_Document] = selector.empty? ? 'all' : selector.to_json
326
326
  report_kvs[:Change] = change.to_json
327
327
  report_kvs[:Options] = options.to_json
328
328
  rescue StandardError => e
@@ -375,7 +375,6 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
375
375
  end
376
376
  end # ::Moped::Query
377
377
 
378
-
379
378
  if defined?(::Moped::Collection)
380
379
  module ::Moped
381
380
  class Collection
@@ -386,7 +385,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
386
385
  begin
387
386
  report_kvs[:Flavor] = Oboe::Inst::Moped::FLAVOR
388
387
  # FIXME: We're only grabbing the first of potentially multiple servers here
389
- if ::Moped::VERSION < "2.0.0"
388
+ if ::Moped::VERSION < '2.0.0'
390
389
  report_kvs[:RemoteHost], report_kvs[:RemotePort] = database.session.cluster.seeds.first.split(':')
391
390
  else
392
391
  report_kvs[:RemoteHost] = database.session.cluster.seeds.first.address.host
@@ -419,7 +418,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
419
418
 
420
419
  begin
421
420
  report_kvs = extract_trace_details(:find)
422
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
421
+ report_kvs[:Query] = selector.empty? ? 'all' : selector.to_json
423
422
  rescue StandardError => e
424
423
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
425
424
  end
@@ -440,7 +439,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
440
439
  end
441
440
 
442
441
  def insert_with_oboe(documents, flags = nil)
443
- if Oboe.tracing? and not Oboe.tracing_layer_op?(:create_index)
442
+ if Oboe.tracing? && !Oboe.tracing_layer_op?(:create_index)
444
443
  report_kvs = extract_trace_details(:insert)
445
444
 
446
445
  Oboe::API.trace('mongo', report_kvs) do