Module: TraceView::Inst::MopedQuery
- Includes:
- Moped
- Defined in:
- lib/traceview/inst/moped.rb
Overview
Constant Summary
Constants included
from Moped
TraceView::Inst::Moped::COLLECTION_OPS, TraceView::Inst::Moped::DB_OPS, TraceView::Inst::Moped::FLAVOR, TraceView::Inst::Moped::INDEX_OPS, TraceView::Inst::Moped::QUERY_OPS
Class Method Summary
collapse
Instance Method Summary
collapse
Methods included from Moped
#remote_host
Class Method Details
.included(klass) ⇒ Object
Instance Method Details
#count_with_traceview ⇒ Object
193
194
195
196
197
198
199
200
201
202
203
204
205
206
|
# File 'lib/traceview/inst/moped.rb', line 193
def count_with_traceview
return count_without_traceview unless TraceView.tracing?
begin
report_kvs = (:count)
report_kvs[:Query] = selector.empty? ? :all : selector.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
count_without_traceview
end
end
|
#distinct_with_traceview(key) ⇒ Object
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
|
# File 'lib/traceview/inst/moped.rb', line 242
def distinct_with_traceview(key)
return distinct_without_traceview(key) unless TraceView.tracing?
begin
report_kvs = (:distinct)
report_kvs[:Query] = selector.empty? ? :all : selector.to_json
report_kvs[:Key] = key.to_s
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
distinct_without_traceview(key)
end
end
|
#explain_with_traceview ⇒ Object
307
308
309
310
311
312
313
314
315
316
317
318
319
320
|
# File 'lib/traceview/inst/moped.rb', line 307
def explain_with_traceview
return explain_without_traceview unless TraceView.tracing?
begin
report_kvs = (:explain)
report_kvs[:Query] = selector.empty? ? :all : selector.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs, :explain) do
explain_without_traceview
end
end
|
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
|
# File 'lib/traceview/inst/moped.rb', line 177
def (op)
report_kvs = {}
report_kvs[:Flavor] = TraceView::Inst::Moped::FLAVOR
first = collection.database.session.cluster.seeds.first
report_kvs[:RemoteHost] = remote_host(first)
report_kvs[:Database] = collection.database.name
report_kvs[:Collection] = collection.name
report_kvs[:QueryOp] = op.to_s
report_kvs[:Backtrace] = TraceView::API.backtrace if TraceView::Config[:moped][:collect_backtraces]
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
ensure
return report_kvs
end
|
#limit_with_traceview(limit) ⇒ Object
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
|
# File 'lib/traceview/inst/moped.rb', line 224
def limit_with_traceview(limit)
if TraceView.tracing? && !TraceView.tracing_layer_op?(:explain)
begin
report_kvs = (:limit)
report_kvs[:Query] = selector.empty? ? :all : selector.to_json
report_kvs[:Limit] = limit.to_s
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
limit_without_traceview(limit)
end
else
limit_without_traceview(limit)
end
end
|
#modify_with_traceview(change, options = {}) ⇒ Object
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
|
# File 'lib/traceview/inst/moped.rb', line 322
def modify_with_traceview(change, options = {})
return modify_without_traceview(change, options) unless TraceView.tracing?
begin
report_kvs = (:modify)
report_kvs[:Update_Document] = selector.empty? ? :all : selector.to_json
report_kvs[:Change] = change.to_json
report_kvs[:Options] = options.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
modify_without_traceview(change, options)
end
end
|
#remove_all_with_traceview ⇒ Object
354
355
356
357
358
359
360
361
362
363
364
365
366
367
|
# File 'lib/traceview/inst/moped.rb', line 354
def remove_all_with_traceview
return remove_all_without_traceview unless TraceView.tracing?
begin
report_kvs = (:remove_all)
report_kvs[:Query] = selector.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
remove_all_without_traceview
end
end
|
#remove_with_traceview ⇒ Object
339
340
341
342
343
344
345
346
347
348
349
350
351
352
|
# File 'lib/traceview/inst/moped.rb', line 339
def remove_with_traceview
return remove_without_traceview unless TraceView.tracing?
begin
report_kvs = (:remove)
report_kvs[:Query] = selector.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
remove_without_traceview
end
end
|
#sort_with_traceview(sort) ⇒ Object
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
|
# File 'lib/traceview/inst/moped.rb', line 208
def sort_with_traceview(sort)
return sort_without_traceview(sort) unless TraceView.tracing?
begin
report_kvs = (:sort)
report_kvs[:Query] = selector.empty? ? :all : selector.to_json
report_kvs[:Order] = sort.to_s
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
sort_without_traceview(sort)
end
end
|
#update_all_with_traceview(change) ⇒ Object
276
277
278
279
280
281
282
283
284
285
286
287
288
289
|
# File 'lib/traceview/inst/moped.rb', line 276
def update_all_with_traceview(change)
return update_all_without_traceview(change) unless TraceView.tracing?
begin
report_kvs = (:update_all)
report_kvs[:Update_Document] = change.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs, :update_all) do
update_all_without_traceview(change)
end
end
|
#update_with_traceview(change, flags = nil) ⇒ Object
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
|
# File 'lib/traceview/inst/moped.rb', line 258
def update_with_traceview(change, flags = nil)
if TraceView.tracing? && !TraceView.tracing_layer_op?([:update_all, :upsert])
begin
report_kvs = (:update)
report_kvs[:Flags] = flags.to_s if flags
report_kvs[:Update_Document] = change.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs) do
update_without_traceview(change, flags)
end
else
update_without_traceview(change, flags)
end
end
|
#upsert_with_traceview(change) ⇒ Object
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
|
# File 'lib/traceview/inst/moped.rb', line 291
def upsert_with_traceview(change)
return upsert_without_traceview(change) unless TraceView.tracing?
begin
report_kvs = (:upsert)
report_kvs[:Query] = selector.to_json
report_kvs[:Update_Document] = change.to_json
rescue StandardError => e
TraceView.logger.debug "[traceview/debug] #{__method__}:#{File.basename(__FILE__)}:#{__LINE__}: #{e.message}"
end
TraceView::API.trace(:mongo, report_kvs, :upsert) do
upsert_without_traceview(change)
end
end
|