oboe 2.3.4.1 → 2.4.0.1

Sign up to get free protection for your applications and to get access to all the features.
@@ -24,13 +24,9 @@ module Oboe
24
24
 
25
25
  def perform_with_oboe(*all_args, &blk)
26
26
  op, key, *args = *all_args
27
-
27
+
28
28
  if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
29
- opts = {}
30
- opts[:KVOp] = op
31
- opts[:KVKey] = key
32
-
33
- Oboe::API.trace('memcache', opts || {}) do
29
+ Oboe::API.trace('memcache', { :KVOp => op, :KVKey => key }) do
34
30
  result = perform_without_oboe(*all_args, &blk)
35
31
 
36
32
  info_kvs = {}
@@ -46,32 +42,26 @@ module Oboe
46
42
  end
47
43
 
48
44
  def get_multi_with_oboe(*keys)
49
- if Oboe.tracing?
50
- layer_kvs = {}
51
- layer_kvs[:KVOp] = :get_multi
45
+ return get_multi_without_oboe(keys) unless Oboe.tracing?
46
+
47
+ info_kvs = {}
48
+
49
+ begin
50
+ info_kvs[:KVKeyCount] = keys.flatten.length
51
+ info_kvs[:KVKeyCount] = (info_kvs[:KVKeyCount] - 1) if keys.last.is_a?(Hash) || keys.last.nil?
52
+ rescue
53
+ Oboe.logger.debug "[oboe/debug] Error collecting info keys: #{e.message}"
54
+ Oboe.logger.debug e.backtrace
55
+ end
52
56
 
53
- Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
54
- begin
55
- info_kvs = {}
56
-
57
- if keys.last.is_a?(Hash) || keys.last.nil?
58
- info_kvs[:KVKeyCount] = keys.flatten.length - 1
59
- else
60
- info_kvs[:KVKeyCount] = keys.flatten.length
61
- end
57
+ Oboe::API.trace('memcache', { :KVOp => :get_multi }, :get_multi) do
58
+ values = get_multi_without_oboe(keys)
59
+
60
+ info_kvs[:KVHitCount] = values.length
61
+ info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:dalli][:collect_backtraces]
62
+ Oboe::API.log('memcache', 'info', info_kvs)
62
63
 
63
- values = get_multi_without_oboe(keys)
64
-
65
- info_kvs[:KVHitCount] = values.length
66
- info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:dalli][:collect_backtraces]
67
- Oboe::API.log('memcache', 'info', info_kvs)
68
- rescue
69
- values = get_multi_without_oboe(keys)
70
- end
71
- values
72
- end
73
- else
74
- get_multi_without_oboe(keys)
64
+ values
75
65
  end
76
66
  end
77
67
  end
@@ -29,72 +29,58 @@ module Oboe
29
29
  class_eval "alias #{m}_without_oboe #{m}"
30
30
  class_eval "alias #{m} #{m}_with_oboe"
31
31
  end
32
-
33
- if ::MemCache.method_defined? :request_setup
34
- alias request_setup_without_oboe request_setup
35
- alias request_setup request_setup_with_oboe
36
- elsif Oboe::Config[:verbose]
37
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
38
- end
39
-
40
- if ::MemCache.method_defined? :cache_get
41
- alias cache_get_without_oboe cache_get
42
- alias cache_get cache_get_with_oboe
43
- elsif Oboe::Config[:verbose]
44
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
45
- end
32
+ end
46
33
 
47
- if ::MemCache.method_defined? :get_multi
48
- alias get_multi_without_oboe get_multi
49
- alias get_multi get_multi_with_oboe
34
+ [:request_setup, :cache_get, :get_multi].each do |m|
35
+ if ::MemCache.method_defined? :request_setup
36
+ cls.class_eval "alias #{m}_without_oboe #{m}"
37
+ cls.class_eval "alias #{m} #{m}_with_oboe"
50
38
  elsif Oboe::Config[:verbose]
51
- Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache. Partial traces may occur."
39
+ Oboe.logger.warn "[oboe/loading] Couldn't properly instrument Memcache: #{m}"
52
40
  end
53
41
  end
54
42
  end
55
43
 
56
44
  def get_multi_with_oboe(*args)
57
- if Oboe.tracing?
58
- layer_kvs = {}
59
- layer_kvs[:KVOp] = :get_multi
60
-
61
- Oboe::API.trace('memcache', layer_kvs || {}, :get_multi) do
62
- begin
63
- info_kvs = {}
64
- info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
65
-
66
- if args.last.is_a?(Hash) || args.last.nil?
67
- info_kvs[:KVKeyCount] = args.flatten.length - 1
68
- else
69
- info_kvs[:KVKeyCount] = args.flatten.length
70
- end
71
-
72
- values = get_multi_without_oboe(args)
73
-
74
- info_kvs[:KVHitCount] = values.length
75
- Oboe::API.log('memcache', 'info', info_kvs)
76
- rescue
77
- values = get_multi_without_oboe(args)
78
- end
79
- values
45
+ return get_multi_without_oboe(args) unless Oboe.tracing?
46
+
47
+ info_kvs = {}
48
+
49
+ begin
50
+ info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
51
+
52
+ if args.last.is_a?(Hash) || args.last.nil?
53
+ info_kvs[:KVKeyCount] = args.flatten.length - 1
54
+ else
55
+ info_kvs[:KVKeyCount] = args.flatten.length
80
56
  end
81
- else
82
- get_multi_without_oboe(args)
57
+ rescue StandardError => e
58
+ Oboe.logger.debug "[oboe/debug] Error collecting info keys: #{e.message}"
59
+ Oboe.logger.debug e.backtrace
60
+ end
61
+
62
+ Oboe::API.trace('memcache', {:KVOp => :get_multi}, :get_multi) do
63
+ values = get_multi_without_oboe(args)
64
+
65
+ info_kvs[:KVHitCount] = values.length
66
+ Oboe::API.log('memcache', 'info', info_kvs)
67
+
68
+ values
83
69
  end
84
70
  end
85
71
 
86
72
  def request_setup_with_oboe(*args)
87
73
  if Oboe.tracing? and not Oboe::Context.tracing_layer_op?(:get_multi)
88
74
  server, cache_key = request_setup_without_oboe(*args)
89
-
75
+
90
76
  info_kvs = { :KVKey => cache_key, :RemoteHost => server.host }
91
77
  info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
92
-
93
78
  Oboe::API.log('memcache', 'info', info_kvs)
79
+
80
+ [server, cache_key]
94
81
  else
95
- server, cache_key = request_setup_without_oboe(*args)
82
+ request_setup_without_oboe(*args)
96
83
  end
97
- return [server, cache_key]
98
84
  end
99
85
 
100
86
  def cache_get_with_oboe(server, cache_key)
@@ -103,6 +89,7 @@ module Oboe
103
89
  info_kvs = { :KVHit => memcache_hit?(result) }
104
90
  info_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:memcache][:collect_backtraces]
105
91
  Oboe::API.log('memcache', 'info', info_kvs)
92
+
106
93
  result
107
94
  end
108
95
 
@@ -1,6 +1,8 @@
1
1
  # Copyright (c) 2013 AppNeta, Inc.
2
2
  # All rights reserved.
3
3
 
4
+ require 'json'
5
+
4
6
  module Oboe
5
7
  module Inst
6
8
  module Mongo
@@ -81,7 +83,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
81
83
  report_kvs[:QueryOp] = m
82
84
  if m == :count
83
85
  unless @selector.empty?
84
- report_kvs[:Query] = @selector.try(:to_json)
86
+ report_kvs[:Query] = @selector.to_json
85
87
  else
86
88
  report_kvs[:Query] = 'all'
87
89
  end
@@ -148,7 +150,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
148
150
 
149
151
  if m == :update
150
152
  if args_length >= 3
151
- report_kvs[:Update_Document] = args[1].try(:to_json)
153
+ report_kvs[:Update_Document] = args[1].to_json
152
154
  report_kvs[:Multi] = args[2][:multi] if args[2] and args[2].has_key?(:multi)
153
155
  end
154
156
  end
@@ -173,7 +175,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
173
175
 
174
176
  if m == :distinct and args_length >= 2
175
177
  report_kvs[:Key] = args[0]
176
- report_kvs[:Query] = args[1].try(:to_json) if args[1] and args[1].class == Hash
178
+ report_kvs[:Query] = args[1].to_json if args[1] and args[1].class == Hash
177
179
  end
178
180
 
179
181
  if m == :find and args_length > 0
@@ -183,9 +185,9 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
183
185
  if m == :group
184
186
  unless args.empty?
185
187
  if args[0].is_a?(Hash)
186
- report_kvs[:Group_Key] = args[0][:key].try(:to_json) if args[0].has_key?(:key)
187
- report_kvs[:Group_Condition] = args[0][:cond].try(:to_json) if args[0].has_key?(:cond)
188
- report_kvs[:Group_Initial] = args[0][:initial].try(:to_json) if args[0].has_key?(:initial)
188
+ report_kvs[:Group_Key] = args[0][:key].to_json if args[0].has_key?(:key)
189
+ report_kvs[:Group_Condition] = args[0][:cond].to_json if args[0].has_key?(:cond)
190
+ report_kvs[:Group_Initial] = args[0][:initial].to_json if args[0].has_key?(:initial)
189
191
  report_kvs[:Group_Reduce] = args[0][:reduce] if args[0].has_key?(:reduce)
190
192
  end
191
193
  end
@@ -210,7 +212,7 @@ if defined?(::Mongo) and Oboe::Config[:mongo][:enabled]
210
212
 
211
213
  begin
212
214
  if [:create_index, :ensure_index, :drop_index].include? m and not _args.empty?
213
- report_kvs[:Index] = _args[0].try(:to_json)
215
+ report_kvs[:Index] = _args[0].to_json
214
216
  end
215
217
  rescue
216
218
  end
@@ -41,7 +41,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
41
41
  report_kvs[:Database] = name
42
42
  report_kvs[:QueryOp] = op.to_s
43
43
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
44
- rescue Exception => e
44
+ rescue StandardError => e
45
45
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
46
46
  end
47
47
  report_kvs
@@ -53,7 +53,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
53
53
  report_kvs = extract_trace_details(:map_reduce)
54
54
  report_kvs[:Map_Function] = command[:map]
55
55
  report_kvs[:Reduce_Function] = command[:reduce]
56
- rescue Exception => e
56
+ rescue StandardError => e
57
57
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
58
58
  end
59
59
 
@@ -66,13 +66,11 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
66
66
  end
67
67
 
68
68
  def drop_with_oboe
69
- if Oboe.tracing?
70
- report_kvs = extract_trace_details(:drop_database)
69
+ return drop_without_oboe unless Oboe.tracing?
71
70
 
72
- Oboe::API.trace('mongo', report_kvs) do
73
- drop_without_oboe
74
- end
75
- else
71
+ report_kvs = extract_trace_details(:drop_database)
72
+
73
+ Oboe::API.trace('mongo', report_kvs) do
76
74
  drop_without_oboe
77
75
  end
78
76
  end
@@ -102,47 +100,43 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
102
100
  report_kvs[:Database] = database.name
103
101
  report_kvs[:QueryOp] = op.to_s
104
102
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
105
- rescue Exception => e
103
+ rescue StandardError => e
106
104
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
107
105
  end
108
106
  report_kvs
109
107
  end
110
108
 
111
109
  def create_with_oboe(key, options = {})
112
- if Oboe.tracing?
113
- begin
114
- # We report :create_index here to be consistent
115
- # with other mongo implementations
116
- report_kvs = extract_trace_details(:create_index)
117
- report_kvs[:Key] = key.to_json
118
- report_kvs[:Options] = options.to_json
119
- rescue Exception => e
120
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
121
- end
110
+ return create_without_oboe(key, options = {}) unless Oboe.tracing?
122
111
 
123
- Oboe::API.trace('mongo', report_kvs, :create_index) do
124
- create_without_oboe(key, options = {})
125
- end
126
- else
112
+ begin
113
+ # We report :create_index here to be consistent
114
+ # with other mongo implementations
115
+ report_kvs = extract_trace_details(:create_index)
116
+ report_kvs[:Key] = key.to_json
117
+ report_kvs[:Options] = options.to_json
118
+ rescue StandardError => e
119
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
120
+ end
121
+
122
+ Oboe::API.trace('mongo', report_kvs, :create_index) do
127
123
  create_without_oboe(key, options = {})
128
124
  end
129
125
  end
130
126
 
131
127
  def drop_with_oboe(key = nil)
132
- if Oboe.tracing?
133
- begin
134
- # We report :drop_indexes here to be consistent
135
- # with other mongo implementations
136
- report_kvs = extract_trace_details(:drop_indexes)
137
- report_kvs[:Key] = key.nil? ? "all" : key.to_json
138
- rescue Exception => e
139
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
140
- end
128
+ return drop_without_oboe(key = nil) unless Oboe.tracing?
129
+
130
+ begin
131
+ # We report :drop_indexes here to be consistent
132
+ # with other mongo implementations
133
+ report_kvs = extract_trace_details(:drop_indexes)
134
+ report_kvs[:Key] = key.nil? ? "all" : key.to_json
135
+ rescue StandardError => e
136
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
137
+ end
141
138
 
142
- Oboe::API.trace('mongo', report_kvs) do
143
- drop_without_oboe(key = nil)
144
- end
145
- else
139
+ Oboe::API.trace('mongo', report_kvs) do
146
140
  drop_without_oboe(key = nil)
147
141
  end
148
142
  end
@@ -173,43 +167,39 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
173
167
  report_kvs[:Collection] = collection.name
174
168
  report_kvs[:QueryOp] = op.to_s
175
169
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
176
- rescue Exception => e
170
+ rescue StandardError => e
177
171
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
178
172
  end
179
173
  report_kvs
180
174
  end
181
175
 
182
176
  def count_with_oboe
183
- if Oboe.tracing?
184
- begin
185
- report_kvs = extract_trace_details(:count)
186
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
187
- rescue Exception => e
188
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
189
- end
177
+ return count_without_oboe unless Oboe.tracing?
178
+
179
+ begin
180
+ report_kvs = extract_trace_details(:count)
181
+ report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
182
+ rescue StandardError => e
183
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
184
+ end
190
185
 
191
- Oboe::API.trace('mongo', report_kvs) do
192
- count_without_oboe
193
- end
194
- else
186
+ Oboe::API.trace('mongo', report_kvs) do
195
187
  count_without_oboe
196
188
  end
197
189
  end
198
190
 
199
191
  def sort_with_oboe(sort)
200
- if Oboe.tracing?
201
- begin
202
- report_kvs = extract_trace_details(:sort)
203
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
204
- report_kvs[:Order] = sort.to_s
205
- rescue Exception => e
206
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
207
- end
192
+ return sort_without_oboe(sort) unless Oboe.tracing?
193
+
194
+ begin
195
+ report_kvs = extract_trace_details(:sort)
196
+ report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
197
+ report_kvs[:Order] = sort.to_s
198
+ rescue StandardError => e
199
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
200
+ end
208
201
 
209
- Oboe::API.trace('mongo', report_kvs) do
210
- sort_without_oboe(sort)
211
- end
212
- else
202
+ Oboe::API.trace('mongo', report_kvs) do
213
203
  sort_without_oboe(sort)
214
204
  end
215
205
  end
@@ -220,32 +210,30 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
220
210
  report_kvs = extract_trace_details(:limit)
221
211
  report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
222
212
  report_kvs[:Limit] = limit.to_s
223
- rescue Exception => e
213
+ rescue StandardError => e
224
214
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
225
215
  end
226
216
 
227
217
  Oboe::API.trace('mongo', report_kvs) do
228
218
  limit_without_oboe(limit)
229
219
  end
230
- else
231
- limit_without_oboe(limit)
220
+ else
221
+ limit_without_oboe(limit)
232
222
  end
233
223
  end
234
224
 
235
225
  def distinct_with_oboe(key)
236
- if Oboe.tracing?
237
- begin
238
- report_kvs = extract_trace_details(:distinct)
239
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
240
- report_kvs[:Key] = key.to_s
241
- rescue Exception => e
242
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
243
- end
226
+ return distinct_without_oboe(key) unless Oboe.tracing?
244
227
 
245
- Oboe::API.trace('mongo', report_kvs) do
246
- distinct_without_oboe(key)
247
- end
248
- else
228
+ begin
229
+ report_kvs = extract_trace_details(:distinct)
230
+ report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
231
+ report_kvs[:Key] = key.to_s
232
+ rescue StandardError => e
233
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
234
+ end
235
+
236
+ Oboe::API.trace('mongo', report_kvs) do
249
237
  distinct_without_oboe(key)
250
238
  end
251
239
  end
@@ -256,7 +244,7 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
256
244
  report_kvs = extract_trace_details(:update)
257
245
  report_kvs[:Flags] = flags.to_s if flags
258
246
  report_kvs[:Update_Document] = change.to_json
259
- rescue Exception => e
247
+ rescue StandardError => e
260
248
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
261
249
  end
262
250
 
@@ -269,106 +257,94 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
269
257
  end
270
258
 
271
259
  def update_all_with_oboe(change)
272
- if Oboe.tracing?
273
- begin
274
- report_kvs = extract_trace_details(:update_all)
275
- report_kvs[:Update_Document] = change.to_json
276
- rescue Exception => e
277
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
278
- end
260
+ return update_all_without_oboe(change) unless Oboe.tracing?
261
+
262
+ begin
263
+ report_kvs = extract_trace_details(:update_all)
264
+ report_kvs[:Update_Document] = change.to_json
265
+ rescue StandardError => e
266
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
267
+ end
279
268
 
280
- Oboe::API.trace('mongo', report_kvs, :update_all) do
281
- update_all_without_oboe(change)
282
- end
283
- else
269
+ Oboe::API.trace('mongo', report_kvs, :update_all) do
284
270
  update_all_without_oboe(change)
285
271
  end
286
272
  end
287
273
 
288
274
  def upsert_with_oboe(change)
289
- if Oboe.tracing?
290
- begin
291
- report_kvs = extract_trace_details(:upsert)
292
- report_kvs[:Query] = selector.to_json
293
- report_kvs[:Update_Document] = change.to_json
294
- rescue Exception => e
295
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
296
- end
275
+ return upsert_without_oboe(change) unless Oboe.tracing?
276
+
277
+ begin
278
+ report_kvs = extract_trace_details(:upsert)
279
+ report_kvs[:Query] = selector.to_json
280
+ report_kvs[:Update_Document] = change.to_json
281
+ rescue StandardError => e
282
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
283
+ end
297
284
 
298
- Oboe::API.trace('mongo', report_kvs, :upsert) do
299
- upsert_without_oboe(change)
300
- end
301
- else
285
+ Oboe::API.trace('mongo', report_kvs, :upsert) do
302
286
  upsert_without_oboe(change)
303
287
  end
304
288
  end
305
289
 
306
290
  def explain_with_oboe
307
- if Oboe.tracing?
308
- begin
309
- report_kvs = extract_trace_details(:explain)
310
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
311
- rescue Exception => e
312
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
313
- end
291
+ return explain_without_oboe unless Oboe.tracing?
292
+
293
+ begin
294
+ report_kvs = extract_trace_details(:explain)
295
+ report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
296
+ rescue StandardError => e
297
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
298
+ end
314
299
 
315
- Oboe::API.trace('mongo', report_kvs, :explain) do
316
- explain_without_oboe
317
- end
318
- else
300
+ Oboe::API.trace('mongo', report_kvs, :explain) do
319
301
  explain_without_oboe
320
302
  end
321
303
  end
322
304
 
323
305
  def modify_with_oboe(change, options = {})
324
- if Oboe.tracing?
325
- begin
326
- report_kvs = extract_trace_details(:modify)
327
- report_kvs[:Update_Document] = selector.empty? ? "all" : selector.to_json
328
- report_kvs[:Change] = change.to_json
329
- report_kvs[:Options] = options.to_json
330
- rescue Exception => e
331
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
332
- end
306
+ return modify_without_oboe(change, options) unless Oboe.tracing?
333
307
 
334
- Oboe::API.trace('mongo', report_kvs) do
335
- modify_without_oboe(change, options)
336
- end
337
- else
308
+ begin
309
+ report_kvs = extract_trace_details(:modify)
310
+ report_kvs[:Update_Document] = selector.empty? ? "all" : selector.to_json
311
+ report_kvs[:Change] = change.to_json
312
+ report_kvs[:Options] = options.to_json
313
+ rescue StandardError => e
314
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
315
+ end
316
+
317
+ Oboe::API.trace('mongo', report_kvs) do
338
318
  modify_without_oboe(change, options)
339
319
  end
340
320
  end
341
321
 
342
322
  def remove_with_oboe
343
- if Oboe.tracing?
344
- begin
345
- report_kvs = extract_trace_details(:remove)
346
- report_kvs[:Query] = selector.to_json
347
- rescue Exception => e
348
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
349
- end
323
+ return remove_without_oboe unless Oboe.tracing?
350
324
 
351
- Oboe::API.trace('mongo', report_kvs) do
352
- remove_without_oboe
353
- end
354
- else
325
+ begin
326
+ report_kvs = extract_trace_details(:remove)
327
+ report_kvs[:Query] = selector.to_json
328
+ rescue StandardError => e
329
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
330
+ end
331
+
332
+ Oboe::API.trace('mongo', report_kvs) do
355
333
  remove_without_oboe
356
334
  end
357
335
  end
358
336
 
359
337
  def remove_all_with_oboe
360
- if Oboe.tracing?
361
- begin
362
- report_kvs = extract_trace_details(:remove_all)
363
- report_kvs[:Query] = selector.to_json
364
- rescue Exception => e
365
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
366
- end
338
+ return remove_all_without_oboe unless Oboe.tracing?
367
339
 
368
- Oboe::API.trace('mongo', report_kvs) do
369
- remove_all_without_oboe
370
- end
371
- else
340
+ begin
341
+ report_kvs = extract_trace_details(:remove_all)
342
+ report_kvs[:Query] = selector.to_json
343
+ rescue StandardError => e
344
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
345
+ end
346
+
347
+ Oboe::API.trace('mongo', report_kvs) do
372
348
  remove_all_without_oboe
373
349
  end
374
350
  end
@@ -400,51 +376,45 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
400
376
  report_kvs[:Collection] = @name
401
377
  report_kvs[:QueryOp] = op.to_s
402
378
  report_kvs[:Backtrace] = Oboe::API.backtrace if Oboe::Config[:moped][:collect_backtraces]
403
- rescue Exception => e
379
+ rescue StandardError => e
404
380
  Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
405
381
  end
406
382
  report_kvs
407
383
  end
408
384
 
409
385
  def drop_with_oboe
410
- if Oboe.tracing?
411
- # We report :drop_collection here to be consistent
412
- # with other mongo implementations
413
- report_kvs = extract_trace_details(:drop_collection)
386
+ return drop_without_oboe unless Oboe.tracing?
387
+
388
+ # We report :drop_collection here to be consistent
389
+ # with other mongo implementations
390
+ report_kvs = extract_trace_details(:drop_collection)
414
391
 
415
- Oboe::API.trace('mongo', report_kvs) do
416
- drop_without_oboe
417
- end
418
- else
392
+ Oboe::API.trace('mongo', report_kvs) do
419
393
  drop_without_oboe
420
394
  end
421
395
  end
422
396
 
423
397
  def find_with_oboe(selector = {})
424
- if Oboe.tracing?
425
- begin
426
- report_kvs = extract_trace_details(:find)
427
- report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
428
- rescue Exception => e
429
- Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
430
- end
398
+ return find_without_oboe(selector) unless Oboe.tracing?
399
+
400
+ begin
401
+ report_kvs = extract_trace_details(:find)
402
+ report_kvs[:Query] = selector.empty? ? "all" : selector.to_json
403
+ rescue StandardError => e
404
+ Oboe.logger.debug "[oboe/debug] Moped KV collection error: #{e.inspect}"
405
+ end
431
406
 
432
- Oboe::API.trace('mongo', report_kvs) do
433
- find_without_oboe(selector)
434
- end
435
- else
407
+ Oboe::API.trace('mongo', report_kvs) do
436
408
  find_without_oboe(selector)
437
409
  end
438
410
  end
439
411
 
440
412
  def indexes_with_oboe
441
- if Oboe.tracing?
442
- report_kvs = extract_trace_details(:indexes)
413
+ return indexes_without_oboe unless Oboe.tracing?
414
+
415
+ report_kvs = extract_trace_details(:indexes)
443
416
 
444
- Oboe::API.trace('mongo', report_kvs) do
445
- indexes_without_oboe
446
- end
447
- else
417
+ Oboe::API.trace('mongo', report_kvs) do
448
418
  indexes_without_oboe
449
419
  end
450
420
  end
@@ -462,13 +432,11 @@ if defined?(::Moped) and Oboe::Config[:moped][:enabled]
462
432
  end
463
433
 
464
434
  def aggregate_with_oboe(pipeline)
465
- if Oboe.tracing?
466
- report_kvs = extract_trace_details(:aggregate)
435
+ return aggregate_without_oboe(pipeline) unless Oboe.tracing?
436
+
437
+ report_kvs = extract_trace_details(:aggregate)
467
438
 
468
- Oboe::API.trace('mongo', report_kvs) do
469
- aggregate_without_oboe(pipeline)
470
- end
471
- else
439
+ Oboe::API.trace('mongo', report_kvs) do
472
440
  aggregate_without_oboe(pipeline)
473
441
  end
474
442
  end