oboe 2.2.6 → 2.3.2

Sign up to get free protection for your applications and to get access to all the features.
Files changed (84) hide show
  1. data/.gitignore +6 -1
  2. data/Appraisals +20 -0
  3. data/Gemfile +16 -20
  4. data/README.md +280 -10
  5. data/Rakefile +63 -7
  6. data/ext/oboe_metal/extconf.rb +2 -1
  7. data/ext/oboe_metal/tests/test.rb +4 -0
  8. data/gemfiles/rails2.3.gemfile +18 -0
  9. data/gemfiles/rails2.3.gemfile.lock +95 -0
  10. data/gemfiles/rails3.0.gemfile +18 -0
  11. data/gemfiles/rails3.0.gemfile.lock +142 -0
  12. data/gemfiles/rails3.1.gemfile +18 -0
  13. data/gemfiles/rails3.1.gemfile.lock +152 -0
  14. data/gemfiles/rails3.2.gemfile +18 -0
  15. data/gemfiles/rails3.2.gemfile.lock +150 -0
  16. data/init.rb +1 -1
  17. data/lib/joboe_metal.rb +52 -34
  18. data/lib/method_profiling.rb +1 -1
  19. data/lib/oboe.rb +6 -5
  20. data/lib/oboe/api.rb +1 -1
  21. data/lib/oboe/api/layerinit.rb +3 -0
  22. data/lib/oboe/api/logging.rb +1 -1
  23. data/lib/oboe/api/memcache.rb +2 -2
  24. data/lib/oboe/api/profiling.rb +6 -4
  25. data/lib/oboe/api/tracing.rb +1 -1
  26. data/lib/oboe/api/util.rb +1 -1
  27. data/lib/oboe/config.rb +29 -10
  28. data/lib/oboe/frameworks/rails.rb +6 -7
  29. data/lib/oboe/frameworks/rails/inst/action_controller.rb +1 -1
  30. data/lib/oboe/frameworks/rails/inst/action_view.rb +3 -3
  31. data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +3 -3
  32. data/lib/oboe/frameworks/rails/inst/action_view_30.rb +3 -3
  33. data/lib/oboe/frameworks/rails/inst/active_record.rb +1 -1
  34. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +1 -1
  35. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +1 -1
  36. data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +1 -1
  37. data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +1 -1
  38. data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +2 -2
  39. data/lib/oboe/inst/cassandra.rb +2 -2
  40. data/lib/oboe/inst/dalli.rb +8 -4
  41. data/lib/oboe/inst/http.rb +38 -34
  42. data/lib/oboe/inst/memcache.rb +12 -3
  43. data/lib/oboe/inst/memcached.rb +10 -5
  44. data/lib/oboe/inst/mongo.rb +19 -15
  45. data/lib/oboe/inst/moped.rb +120 -51
  46. data/lib/oboe/inst/rack.rb +14 -7
  47. data/lib/oboe/inst/resque.rb +2 -2
  48. data/lib/oboe/instrumentation.rb +3 -0
  49. data/lib/oboe/loading.rb +2 -6
  50. data/lib/oboe/logger.rb +3 -1
  51. data/lib/oboe/ruby.rb +3 -0
  52. data/lib/oboe/util.rb +2 -0
  53. data/lib/oboe/version.rb +5 -2
  54. data/lib/oboe_fu.rb +2 -0
  55. data/lib/oboe_metal.rb +23 -10
  56. data/lib/rails/generators/oboe/install_generator.rb +5 -3
  57. data/lib/rails/generators/oboe/templates/oboe_initializer.rb +24 -2
  58. data/oboe.gemspec +20 -14
  59. data/test/instrumentation/cassandra_test.rb +331 -0
  60. data/test/instrumentation/dalli_test.rb +157 -0
  61. data/test/instrumentation/http_test.rb +74 -0
  62. data/test/instrumentation/memcache_test.rb +251 -0
  63. data/test/instrumentation/memcached_test.rb +218 -0
  64. data/test/instrumentation/mongo_test.rb +406 -0
  65. data/test/instrumentation/moped_test.rb +468 -0
  66. data/test/instrumentation/rack_test.rb +55 -0
  67. data/test/instrumentation/resque_test.rb +62 -0
  68. data/test/minitest_helper.rb +113 -0
  69. data/test/support/config_test.rb +41 -0
  70. metadata +56 -35
  71. data/Gemfile.lock +0 -103
  72. data/Guardfile +0 -24
  73. data/install.rb +0 -1
  74. data/spec/instrumentation/cassandra_spec.rb +0 -18
  75. data/spec/instrumentation/dalli_spec.rb +0 -14
  76. data/spec/instrumentation/http_spec.rb +0 -14
  77. data/spec/instrumentation/memcache_spec.rb +0 -19
  78. data/spec/instrumentation/memcached_spec.rb +0 -22
  79. data/spec/instrumentation/mongo_spec.rb +0 -29
  80. data/spec/instrumentation/moped_spec.rb +0 -41
  81. data/spec/instrumentation/resque_spec.rb +0 -18
  82. data/spec/spec_helper.rb +0 -15
  83. data/spec/support/config_spec.rb +0 -27
  84. data/spec/support/oboe_spec.rb +0 -4
@@ -0,0 +1,468 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Oboe::Inst::Moped do
4
+ before do
5
+ clear_all_traces
6
+ @session = Moped::Session.new([ "127.0.0.1:27017" ])
7
+ @session.use :moped_test
8
+ @users = @session[:users]
9
+ @users.insert({ name: "Syd", city: "Boston" })
10
+
11
+ # These are standard entry/exit KVs that are passed up with all moped operations
12
+ @entry_kvs = {
13
+ 'Layer' => 'mongo',
14
+ 'Label' => 'entry',
15
+ 'Flavor' => 'mongodb',
16
+ 'Database' => 'moped_test',
17
+ 'RemoteHost' => '127.0.0.1',
18
+ 'RemotePort' => '27017' }
19
+
20
+ @exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
21
+ @collect_backtraces = Oboe::Config[:moped][:collect_backtraces]
22
+ end
23
+
24
+ after do
25
+ Oboe::Config[:moped][:collect_backtraces] = @collect_backtraces
26
+ end
27
+
28
+ it 'Stock Moped should be loaded, defined and ready' do
29
+ defined?(::Moped).wont_match nil
30
+ defined?(::Moped::Database).wont_match nil
31
+ defined?(::Moped::Indexes).wont_match nil
32
+ defined?(::Moped::Query).wont_match nil
33
+ defined?(::Moped::Collection).wont_match nil
34
+ end
35
+
36
+ it 'Moped should have oboe methods defined' do
37
+ #::Moped::Database
38
+ Oboe::Inst::Moped::DB_OPS.each do |m|
39
+ ::Moped::Database.method_defined?("#{m}_with_oboe").must_equal true
40
+ end
41
+ ::Moped::Database.method_defined?(:extract_trace_details).must_equal true
42
+ ::Moped::Database.method_defined?(:command_with_oboe).must_equal true
43
+ ::Moped::Database.method_defined?(:drop_with_oboe).must_equal true
44
+
45
+ #::Moped::Indexes
46
+ Oboe::Inst::Moped::INDEX_OPS.each do |m|
47
+ ::Moped::Indexes.method_defined?("#{m}_with_oboe").must_equal true
48
+ end
49
+ ::Moped::Indexes.method_defined?(:extract_trace_details).must_equal true
50
+ ::Moped::Indexes.method_defined?(:create_with_oboe).must_equal true
51
+ ::Moped::Indexes.method_defined?(:drop_with_oboe).must_equal true
52
+
53
+ #::Moped::Query
54
+ Oboe::Inst::Moped::QUERY_OPS.each do |m|
55
+ ::Moped::Query.method_defined?("#{m}_with_oboe").must_equal true
56
+ end
57
+ ::Moped::Query.method_defined?(:extract_trace_details).must_equal true
58
+
59
+ #::Moped::Collection
60
+ Oboe::Inst::Moped::COLLECTION_OPS.each do |m|
61
+ ::Moped::Collection.method_defined?("#{m}_with_oboe").must_equal true
62
+ end
63
+ ::Moped::Collection.method_defined?(:extract_trace_details).must_equal true
64
+ end
65
+
66
+ it 'should trace command' do
67
+ Oboe::API.start_trace('moped_test', '', {}) do
68
+ command = {}
69
+ command[:mapreduce] = "users"
70
+ command[:map] = "function() { emit(this.name, 1); }"
71
+ command[:reduce] = "function(k, vals) { var sum = 0;" +
72
+ " for(var i in vals) sum += vals[i]; return sum; }"
73
+ command[:out] = "inline: 1"
74
+ @session.command(command)
75
+ end
76
+
77
+ traces = get_all_traces
78
+
79
+ traces.count.must_equal 4
80
+ validate_outer_layers(traces, 'moped_test')
81
+
82
+ validate_event_keys(traces[1], @entry_kvs)
83
+ traces[1]['QueryOp'].must_equal "map_reduce"
84
+ traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
85
+ traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0;" +
86
+ " for(var i in vals) sum += vals[i]; return sum; }"
87
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
88
+ validate_event_keys(traces[2], @exit_kvs)
89
+ end
90
+
91
+ it 'should trace drop_collection' do
92
+ Oboe::API.start_trace('moped_test', '', {}) do
93
+ @users.drop
94
+ @session.drop
95
+ end
96
+
97
+ traces = get_all_traces
98
+
99
+ traces.count.must_equal 6
100
+ validate_outer_layers(traces, 'moped_test')
101
+
102
+ validate_event_keys(traces[1], @entry_kvs)
103
+ traces[1]['QueryOp'].must_equal "drop_collection"
104
+ traces[1]['Collection'].must_equal "users"
105
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
106
+ validate_event_keys(traces[2], @exit_kvs)
107
+
108
+ validate_event_keys(traces[3], @entry_kvs)
109
+ traces[3]['QueryOp'].must_equal "drop_database"
110
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
111
+ validate_event_keys(traces[4], @exit_kvs)
112
+ end
113
+
114
+ it 'should trace create_index, indexes and drop_indexes' do
115
+ Oboe::API.start_trace('moped_test', '', {}) do
116
+ @users.indexes.create({name: 1}, {unique: true})
117
+ @users.indexes.drop
118
+ end
119
+
120
+ traces = get_all_traces
121
+
122
+ traces.count.must_equal 10
123
+ validate_outer_layers(traces, 'moped_test')
124
+
125
+ validate_event_keys(traces[1], @entry_kvs)
126
+ traces[1]['QueryOp'].must_equal "indexes"
127
+ traces[1]['Collection'].must_equal "users"
128
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
129
+ validate_event_keys(traces[2], @exit_kvs)
130
+
131
+ validate_event_keys(traces[3], @entry_kvs)
132
+ traces[3]['QueryOp'].must_equal "create_index"
133
+ traces[3]['Key'].must_equal "{\"name\":1}"
134
+ traces[3]['Options'].must_equal "{\"unique\":true}"
135
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
136
+ validate_event_keys(traces[4], @exit_kvs)
137
+
138
+ validate_event_keys(traces[5], @entry_kvs)
139
+ traces[5]['QueryOp'].must_equal "indexes"
140
+ traces[5]['Collection'].must_equal "users"
141
+ traces[5].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
142
+ validate_event_keys(traces[6], @exit_kvs)
143
+
144
+ validate_event_keys(traces[7], @entry_kvs)
145
+ traces[7]['QueryOp'].must_equal "drop_indexes"
146
+ traces[7]['Key'].must_equal "all"
147
+ traces[7].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
148
+ validate_event_keys(traces[8], @exit_kvs)
149
+ end
150
+
151
+ it 'should trace find and count' do
152
+ Oboe::API.start_trace('moped_test', '', {}) do
153
+ @users.find.count
154
+ end
155
+
156
+ traces = get_all_traces
157
+
158
+ traces.count.must_equal 6
159
+ validate_outer_layers(traces, 'moped_test')
160
+
161
+ validate_event_keys(traces[1], @entry_kvs)
162
+ traces[1]['QueryOp'].must_equal "find"
163
+ traces[1]['Collection'].must_equal "users"
164
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
165
+ validate_event_keys(traces[2], @exit_kvs)
166
+
167
+ validate_event_keys(traces[3], @entry_kvs)
168
+ traces[3]['QueryOp'].must_equal "count"
169
+ traces[3]['Query'].must_equal "all"
170
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
171
+ validate_event_keys(traces[4], @exit_kvs)
172
+ end
173
+
174
+ it 'should trace find and sort' do
175
+ Oboe::API.start_trace('moped_test', '', {}) do
176
+ @users.find(name: "Mary").sort(city: 1, created_at: -1)
177
+ end
178
+
179
+ traces = get_all_traces
180
+
181
+ traces.count.must_equal 6
182
+ validate_outer_layers(traces, 'moped_test')
183
+
184
+ validate_event_keys(traces[1], @entry_kvs)
185
+ traces[1]['QueryOp'].must_equal "find"
186
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
187
+ traces[1]['Collection'].must_equal "users"
188
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
189
+ validate_event_keys(traces[2], @exit_kvs)
190
+
191
+ validate_event_keys(traces[3], @entry_kvs)
192
+ traces[3]['QueryOp'].must_equal "sort"
193
+ traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
194
+ traces[3]['Order'].must_equal "{:city=>1, :created_at=>-1}"
195
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
196
+ validate_event_keys(traces[4], @exit_kvs)
197
+ end
198
+
199
+ it 'should trace find with limit' do
200
+ Oboe::API.start_trace('moped_test', '', {}) do
201
+ @users.find(name: "Mary").limit(1)
202
+ end
203
+
204
+ traces = get_all_traces
205
+
206
+ traces.count.must_equal 6
207
+ validate_outer_layers(traces, 'moped_test')
208
+
209
+ validate_event_keys(traces[1], @entry_kvs)
210
+ traces[1]['QueryOp'].must_equal "find"
211
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
212
+ traces[1]['Collection'].must_equal "users"
213
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
214
+ validate_event_keys(traces[2], @exit_kvs)
215
+
216
+ validate_event_keys(traces[3], @entry_kvs)
217
+ traces[3]['QueryOp'].must_equal "limit"
218
+ traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
219
+ traces[3]['Limit'].must_equal "1"
220
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
221
+ validate_event_keys(traces[4], @exit_kvs)
222
+ end
223
+
224
+ it 'should trace find with distinct' do
225
+ Oboe::API.start_trace('moped_test', '', {}) do
226
+ @users.find(name: "Mary").distinct(:city)
227
+ end
228
+
229
+ traces = get_all_traces
230
+
231
+ traces.count.must_equal 6
232
+ validate_outer_layers(traces, 'moped_test')
233
+
234
+ validate_event_keys(traces[1], @entry_kvs)
235
+ traces[1]['QueryOp'].must_equal "find"
236
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
237
+ traces[1]['Collection'].must_equal "users"
238
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
239
+ validate_event_keys(traces[2], @exit_kvs)
240
+
241
+ validate_event_keys(traces[3], @entry_kvs)
242
+ traces[3]['QueryOp'].must_equal "distinct"
243
+ traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
244
+ traces[3]['Key'].must_equal "city"
245
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
246
+ validate_event_keys(traces[4], @exit_kvs)
247
+ end
248
+
249
+ it 'should trace find and update' do
250
+ Oboe::API.start_trace('moped_test', '', {}) do
251
+ @users.find(name: "Mary").update({name: "Tool"}, [:multi])
252
+ end
253
+
254
+ traces = get_all_traces
255
+
256
+ traces.count.must_equal 6
257
+ validate_outer_layers(traces, 'moped_test')
258
+
259
+ validate_event_keys(traces[1], @entry_kvs)
260
+ traces[1]['QueryOp'].must_equal "find"
261
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
262
+ traces[1]['Collection'].must_equal "users"
263
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
264
+ validate_event_keys(traces[2], @exit_kvs)
265
+
266
+ validate_event_keys(traces[3], @entry_kvs)
267
+ traces[3]['QueryOp'].must_equal "update"
268
+ traces[3]['Update_Document'].must_equal "{\"name\":\"Tool\"}"
269
+ traces[3]['Flags'].must_equal "[:multi]"
270
+ traces[3]['Collection'].must_equal "users"
271
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
272
+ validate_event_keys(traces[4], @exit_kvs)
273
+ end
274
+
275
+ it 'should trace find and update_all' do
276
+ Oboe::API.start_trace('moped_test', '', {}) do
277
+ @users.find(name: "Mary").update_all({name: "Tool"})
278
+ end
279
+
280
+ traces = get_all_traces
281
+
282
+ traces.count.must_equal 6
283
+ validate_outer_layers(traces, 'moped_test')
284
+
285
+ validate_event_keys(traces[1], @entry_kvs)
286
+ traces[1]['QueryOp'].must_equal "find"
287
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
288
+ traces[1]['Collection'].must_equal "users"
289
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
290
+ validate_event_keys(traces[2], @exit_kvs)
291
+
292
+ validate_event_keys(traces[3], @entry_kvs)
293
+ traces[3]['QueryOp'].must_equal "update_all"
294
+ traces[3]['Update_Document'].must_equal "{\"name\":\"Tool\"}"
295
+ traces[3]['Collection'].must_equal "users"
296
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
297
+ validate_event_keys(traces[4], @exit_kvs)
298
+ end
299
+
300
+ it 'should trace find and upsert' do
301
+ Oboe::API.start_trace('moped_test', '', {}) do
302
+ @users.find(name: "Tool").upsert({name: "Mary"})
303
+ end
304
+
305
+ traces = get_all_traces
306
+
307
+ traces.count.must_equal 6
308
+ validate_outer_layers(traces, 'moped_test')
309
+
310
+ validate_event_keys(traces[1], @entry_kvs)
311
+ traces[1]['QueryOp'].must_equal "find"
312
+ traces[1]['Query'].must_equal "{\"name\":\"Tool\"}"
313
+ traces[1]['Collection'].must_equal "users"
314
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
315
+ validate_event_keys(traces[2], @exit_kvs)
316
+
317
+ validate_event_keys(traces[3], @entry_kvs)
318
+ traces[3]['QueryOp'].must_equal "upsert"
319
+ traces[3]['Query'].must_equal "{\"name\":\"Tool\"}"
320
+ traces[3]['Update_Document'].must_equal "{\"name\":\"Mary\"}"
321
+ traces[3]['Collection'].must_equal "users"
322
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
323
+ validate_event_keys(traces[4], @exit_kvs)
324
+ end
325
+
326
+ it 'should trace find and explain' do
327
+ Oboe::API.start_trace('moped_test', '', {}) do
328
+ @users.find(name: "Mary").explain
329
+ end
330
+
331
+ traces = get_all_traces
332
+
333
+ traces.count.must_equal 6
334
+ validate_outer_layers(traces, 'moped_test')
335
+
336
+ validate_event_keys(traces[1], @entry_kvs)
337
+ traces[1]['QueryOp'].must_equal "find"
338
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
339
+ traces[1]['Collection'].must_equal "users"
340
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
341
+ validate_event_keys(traces[2], @exit_kvs)
342
+
343
+ validate_event_keys(traces[3], @entry_kvs)
344
+ traces[3]['QueryOp'].must_equal "explain"
345
+ traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
346
+ traces[3]['Collection'].must_equal "users"
347
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
348
+ validate_event_keys(traces[4], @exit_kvs)
349
+ end
350
+
351
+ it 'should trace 3 types of find and modify calls' do
352
+ Oboe::API.start_trace('moped_test', '', {}) do
353
+ @users.find.modify({}, upsert: true, new: true)
354
+ @users.find.modify({ "$inc" => { likes: 1 }}, new: true)
355
+ @users.find.modify({}, remove: true)
356
+ end
357
+
358
+ traces = get_all_traces
359
+
360
+ traces.count.must_equal 14
361
+ validate_outer_layers(traces, 'moped_test')
362
+
363
+ validate_event_keys(traces[1], @entry_kvs)
364
+ traces[1]['QueryOp'].must_equal "find"
365
+ traces[1]['Query'].must_equal "all"
366
+ traces[1]['Collection'].must_equal "users"
367
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
368
+ validate_event_keys(traces[2], @exit_kvs)
369
+
370
+ validate_event_keys(traces[3], @entry_kvs)
371
+ traces[3]['QueryOp'].must_equal "modify"
372
+ traces[3]['Update_Document'].must_equal "all"
373
+ traces[3]['Collection'].must_equal "users"
374
+ traces[3]['Options'].must_equal "{\"upsert\":true,\"new\":true}"
375
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
376
+ validate_event_keys(traces[4], @exit_kvs)
377
+
378
+ validate_event_keys(traces[7], @entry_kvs)
379
+ traces[7]['QueryOp'].must_equal "modify"
380
+ traces[7]['Update_Document'].must_equal "all"
381
+ traces[7]['Collection'].must_equal "users"
382
+ traces[7]['Options'].must_equal "{\"new\":true}"
383
+ traces[7]['Change'].must_equal "{\"$inc\":{\"likes\":1}}"
384
+ traces[7].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
385
+ validate_event_keys(traces[8], @exit_kvs)
386
+
387
+ validate_event_keys(traces[11], @entry_kvs)
388
+ traces[11]['Collection'].must_equal "users"
389
+ traces[11]['QueryOp'].must_equal "modify"
390
+ traces[11]['Update_Document'].must_equal "all"
391
+ traces[11]['Change'].must_equal "{}"
392
+ traces[11]['Options'].must_equal "{\"remove\":true}"
393
+ traces[11].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
394
+ validate_event_keys(traces[12], @exit_kvs)
395
+ end
396
+
397
+ it 'should trace remove' do
398
+ Oboe::API.start_trace('moped_test', '', {}) do
399
+ @users.find(name: "Tool").remove
400
+ end
401
+
402
+ traces = get_all_traces
403
+
404
+ traces.count.must_equal 6
405
+ validate_outer_layers(traces, 'moped_test')
406
+
407
+ validate_event_keys(traces[1], @entry_kvs)
408
+ traces[1]['QueryOp'].must_equal "find"
409
+ traces[1]['Query'].must_equal "{\"name\":\"Tool\"}"
410
+ traces[1]['Collection'].must_equal "users"
411
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
412
+ validate_event_keys(traces[2], @exit_kvs)
413
+
414
+ validate_event_keys(traces[3], @entry_kvs)
415
+ traces[3]['QueryOp'].must_equal "remove"
416
+ traces[3]['Query'].must_equal "{\"name\":\"Tool\"}"
417
+ traces[3]['Collection'].must_equal "users"
418
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
419
+ validate_event_keys(traces[4], @exit_kvs)
420
+ end
421
+
422
+ it 'should trace remove_all' do
423
+ Oboe::API.start_trace('moped_test', '', {}) do
424
+ @users.find(name: "Mary").remove_all
425
+ end
426
+
427
+ traces = get_all_traces
428
+
429
+ traces.count.must_equal 6
430
+ validate_outer_layers(traces, 'moped_test')
431
+
432
+ validate_event_keys(traces[1], @entry_kvs)
433
+ traces[1]['QueryOp'].must_equal "find"
434
+ traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
435
+ traces[1]['Collection'].must_equal "users"
436
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
437
+ validate_event_keys(traces[2], @exit_kvs)
438
+
439
+ validate_event_keys(traces[3], @entry_kvs)
440
+ traces[3]['QueryOp'].must_equal "remove_all"
441
+ traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
442
+ traces[3]['Collection'].must_equal "users"
443
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:moped][:collect_backtraces]
444
+ validate_event_keys(traces[4], @exit_kvs)
445
+ end
446
+
447
+ it "should obey :collect_backtraces setting when true" do
448
+ Oboe::Config[:moped][:collect_backtraces] = true
449
+
450
+ Oboe::API.start_trace('moped_test', '', {}) do
451
+ @users.find(name: "Mary").limit(1)
452
+ end
453
+
454
+ traces = get_all_traces
455
+ layer_has_key(traces, 'mongo', 'Backtrace')
456
+ end
457
+
458
+ it "should obey :collect_backtraces setting when false" do
459
+ Oboe::Config[:moped][:collect_backtraces] = false
460
+
461
+ Oboe::API.start_trace('moped_test', '', {}) do
462
+ @users.find(name: "Mary").limit(1)
463
+ end
464
+
465
+ traces = get_all_traces
466
+ layer_doesnt_have_key(traces, 'mongo', 'Backtrace')
467
+ end
468
+ end