appoptics_apm 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile_test +6 -7
  3. data/README.md +3 -3
  4. data/Rakefile +3 -2
  5. data/appoptics_apm.gemspec +2 -2
  6. data/docker-compose.yml +0 -22
  7. data/ext/oboe_metal/extconf.rb +4 -0
  8. data/lib/appoptics_apm/config.rb +11 -6
  9. data/lib/appoptics_apm/version.rb +1 -1
  10. metadata +3 -202
  11. data/gemfiles/delayed_job.gemfile +0 -36
  12. data/gemfiles/frameworks.gemfile +0 -44
  13. data/gemfiles/instrumentation_mocked.gemfile +0 -29
  14. data/gemfiles/libraries.gemfile +0 -85
  15. data/gemfiles/noop.gemfile +0 -17
  16. data/gemfiles/rails23.gemfile +0 -39
  17. data/gemfiles/rails30.gemfile +0 -42
  18. data/gemfiles/rails31.gemfile +0 -44
  19. data/gemfiles/rails32.gemfile +0 -54
  20. data/gemfiles/rails40.gemfile +0 -27
  21. data/gemfiles/rails41.gemfile +0 -27
  22. data/gemfiles/rails42.gemfile +0 -35
  23. data/gemfiles/rails50.gemfile +0 -44
  24. data/gemfiles/rails51.gemfile +0 -44
  25. data/test/benchmark/README.md +0 -65
  26. data/test/benchmark/logging_bench.rb +0 -54
  27. data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
  28. data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
  29. data/test/frameworks/apps/grape_nested.rb +0 -33
  30. data/test/frameworks/apps/grape_simple.rb +0 -80
  31. data/test/frameworks/apps/padrino_simple.rb +0 -80
  32. data/test/frameworks/apps/sinatra_simple.rb +0 -55
  33. data/test/frameworks/grape_test.rb +0 -286
  34. data/test/frameworks/padrino_test.rb +0 -222
  35. data/test/frameworks/rails3x_test.rb +0 -554
  36. data/test/frameworks/rails4x_test.rb +0 -570
  37. data/test/frameworks/rails5x_api_test.rb +0 -210
  38. data/test/frameworks/rails5x_test.rb +0 -376
  39. data/test/frameworks/rails_shared_tests.rb +0 -172
  40. data/test/frameworks/sinatra_test.rb +0 -140
  41. data/test/instrumentation/bunny_client_test.rb +0 -276
  42. data/test/instrumentation/bunny_consumer_test.rb +0 -204
  43. data/test/instrumentation/curb_test.rb +0 -398
  44. data/test/instrumentation/dalli_test.rb +0 -177
  45. data/test/instrumentation/em_http_request_test.rb +0 -89
  46. data/test/instrumentation/excon_test.rb +0 -231
  47. data/test/instrumentation/faraday_test.rb +0 -228
  48. data/test/instrumentation/http_test.rb +0 -143
  49. data/test/instrumentation/httpclient_test.rb +0 -304
  50. data/test/instrumentation/memcache_test.rb +0 -260
  51. data/test/instrumentation/memcached_test.rb +0 -229
  52. data/test/instrumentation/mongo_v1_test.rb +0 -479
  53. data/test/instrumentation/mongo_v2_index_test.rb +0 -124
  54. data/test/instrumentation/mongo_v2_test.rb +0 -584
  55. data/test/instrumentation/mongo_v2_view_test.rb +0 -435
  56. data/test/instrumentation/moped_test.rb +0 -517
  57. data/test/instrumentation/rack_test.rb +0 -165
  58. data/test/instrumentation/redis_hashes_test.rb +0 -268
  59. data/test/instrumentation/redis_keys_test.rb +0 -321
  60. data/test/instrumentation/redis_lists_test.rb +0 -310
  61. data/test/instrumentation/redis_misc_test.rb +0 -163
  62. data/test/instrumentation/redis_sets_test.rb +0 -296
  63. data/test/instrumentation/redis_sortedsets_test.rb +0 -328
  64. data/test/instrumentation/redis_strings_test.rb +0 -349
  65. data/test/instrumentation/resque_test.rb +0 -185
  66. data/test/instrumentation/rest-client_test.rb +0 -288
  67. data/test/instrumentation/sequel_mysql2_test.rb +0 -353
  68. data/test/instrumentation/sequel_mysql_test.rb +0 -334
  69. data/test/instrumentation/sequel_pg_test.rb +0 -336
  70. data/test/instrumentation/sidekiq-client_test.rb +0 -159
  71. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  72. data/test/instrumentation/twitter-cassandra_test.rb +0 -424
  73. data/test/instrumentation/typhoeus_test.rb +0 -284
  74. data/test/jobs/delayed_job/db_worker_job.rb +0 -29
  75. data/test/jobs/delayed_job/error_worker_job.rb +0 -10
  76. data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
  77. data/test/jobs/resque/db_worker_job.rb +0 -29
  78. data/test/jobs/resque/error_worker_job.rb +0 -10
  79. data/test/jobs/resque/remote_call_worker_job.rb +0 -20
  80. data/test/jobs/sidekiq/db_worker_job.rb +0 -29
  81. data/test/jobs/sidekiq/error_worker_job.rb +0 -10
  82. data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
  83. data/test/minitest_helper.rb +0 -277
  84. data/test/mocked/curb_mocked_test.rb +0 -324
  85. data/test/mocked/excon_mocked_test.rb +0 -174
  86. data/test/mocked/faraday_mocked_test.rb +0 -97
  87. data/test/mocked/http_mocked_test.rb +0 -135
  88. data/test/mocked/httpclient_mocked_test.rb +0 -258
  89. data/test/mocked/rest_client_mocked_test.rb +0 -109
  90. data/test/mocked/typhoeus_mocked_test.rb +0 -207
  91. data/test/models/widget.rb +0 -36
  92. data/test/noop/noop_test.rb +0 -145
  93. data/test/profiling/legacy_method_profiling_test.rb +0 -201
  94. data/test/profiling/method_profiling_test.rb +0 -631
  95. data/test/queues/delayed_job-client_test.rb +0 -95
  96. data/test/queues/delayed_job-worker_test.rb +0 -91
  97. data/test/reporter/reporter_test.rb +0 -14
  98. data/test/servers/delayed_job.rb +0 -107
  99. data/test/servers/rackapp_8101.rb +0 -29
  100. data/test/servers/rails3x_8140.rb +0 -96
  101. data/test/servers/rails4x_8140.rb +0 -96
  102. data/test/servers/rails5x_8140.rb +0 -95
  103. data/test/servers/rails5x_api_8150.rb +0 -78
  104. data/test/servers/sidekiq.rb +0 -29
  105. data/test/servers/sidekiq.yml +0 -7
  106. data/test/servers/sidekiq_initializer.rb +0 -25
  107. data/test/settings +0 -0
  108. data/test/support/auto_tracing_test.rb +0 -50
  109. data/test/support/backcompat_test.rb +0 -276
  110. data/test/support/config_test.rb +0 -149
  111. data/test/support/dnt_test.rb +0 -98
  112. data/test/support/init_report_test.rb +0 -25
  113. data/test/support/liboboe_settings_test.rb +0 -110
  114. data/test/support/logging_test.rb +0 -130
  115. data/test/support/sql_sanitize_test.rb +0 -55
  116. data/test/support/tracing_mode_test.rb +0 -33
  117. data/test/support/tvalias_test.rb +0 -15
  118. data/test/support/xtrace_test.rb +0 -41
@@ -1,479 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- require 'minitest_helper'
5
-
6
- unless ENV['APPOPTICS_MONGO_SERVER']
7
- ENV['APPOPTICS_MONGO_SERVER'] = "127.0.0.1:27017"
8
- end
9
-
10
- if Gem.loaded_specs['mongo'].version.to_s < '2.0.0'
11
- describe "Mongo" do
12
- before do
13
- clear_all_traces
14
-
15
- @mongo_server = ENV['APPOPTICS_MONGO_SERVER'].split(':')[0]
16
- @mongo_port = ENV['APPOPTICS_MONGO_SERVER'].split(':')[1]
17
-
18
- @connection = Mongo::Connection.new(@mongo_server, @mongo_port, :slave_ok => true)
19
- @db = @connection.db("test-#{ENV['RACK_ENV']}")
20
-
21
- @collections = @db.collection_names
22
- @db.create_collection("testCollection") unless @collections.include? "testCollection"
23
-
24
- # These are standard entry/exit KVs that are passed up with all mongo operations
25
- @entry_kvs = {
26
- 'Layer' => 'mongo',
27
- 'Label' => 'entry',
28
- 'Flavor' => 'mongodb',
29
- 'Database' => 'test-test',
30
- 'RemoteHost' => @mongo_server,
31
- 'RemotePort' => @mongo_port }
32
-
33
- @exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
34
- @collect_backtraces = AppOpticsAPM::Config[:mongo][:collect_backtraces]
35
- end
36
-
37
- after do
38
- AppOpticsAPM::Config[:mongo][:collect_backtraces] = @collect_backtraces
39
- end
40
-
41
- it 'Stock Mongo should be loaded, defined and ready' do
42
- defined?(::Mongo).wont_match nil
43
- defined?(::Mongo::DB).wont_match nil
44
- defined?(::Mongo::Cursor).wont_match nil
45
- defined?(::Mongo::Collection).wont_match nil
46
- end
47
-
48
- it 'reports mongo gem version in init' do
49
- init_kvs = ::AppOpticsAPM::Util.build_init_report
50
- assert init_kvs.key?('Ruby.mongo.Version')
51
- assert_equal Gem.loaded_specs['mongo'].version.to_s, init_kvs['Ruby.mongo.Version']
52
- end
53
-
54
- it 'Mongo should have appoptics_apm methods defined' do
55
- AppOpticsAPM::Inst::Mongo::DB_OPS.each do |m|
56
- ::Mongo::DB.method_defined?("#{m}_with_appoptics").must_equal true
57
- end
58
- AppOpticsAPM::Inst::Mongo::CURSOR_OPS.each do |m|
59
- ::Mongo::Cursor.method_defined?("#{m}_with_appoptics").must_equal true
60
- end
61
- AppOpticsAPM::Inst::Mongo::COLL_WRITE_OPS.each do |m|
62
- ::Mongo::Collection.method_defined?("#{m}_with_appoptics").must_equal true
63
- end
64
- AppOpticsAPM::Inst::Mongo::COLL_QUERY_OPS.each do |m|
65
- ::Mongo::Collection.method_defined?("#{m}_with_appoptics").must_equal true
66
- end
67
- AppOpticsAPM::Inst::Mongo::COLL_INDEX_OPS.each do |m|
68
- ::Mongo::Collection.method_defined?("#{m}_with_appoptics").must_equal true
69
- end
70
- ::Mongo::Collection.method_defined?(:appoptics_collect).must_equal true
71
- end
72
-
73
- it "should trace create_collection" do
74
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
75
- @db.create_collection("create_and_drop_collection_test")
76
- end
77
-
78
- traces = get_all_traces
79
- traces.count.must_equal 4
80
-
81
- validate_outer_layers(traces, 'mongo_test')
82
- validate_event_keys(traces[1], @entry_kvs)
83
- validate_event_keys(traces[2], @exit_kvs)
84
-
85
- traces[1]['QueryOp'].must_equal "create_collection"
86
- traces[1]['New_Collection_Name'].must_equal "create_and_drop_collection_test"
87
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
88
- end
89
-
90
- it "should trace drop_collection" do
91
- # Create a collection so we have one to drop
92
- @db.create_collection("create_and_drop_collection_test")
93
-
94
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
95
- @db.drop_collection("create_and_drop_collection_test")
96
- end
97
-
98
- traces = get_all_traces
99
- traces.count.must_equal 4
100
-
101
- validate_outer_layers(traces, 'mongo_test')
102
- validate_event_keys(traces[1], @entry_kvs)
103
- validate_event_keys(traces[2], @exit_kvs)
104
-
105
- traces[1]['QueryOp'].must_equal "drop_collection"
106
- traces[1]['Collection'].must_equal "create_and_drop_collection_test"
107
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
108
- end
109
-
110
- it "should trace count" do
111
- coll = @db.collection("testCollection")
112
-
113
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
114
- coll.count(:query => {:name => "MyName"})
115
- end
116
-
117
- traces = get_all_traces
118
- traces.count.must_equal 6
119
-
120
- validate_outer_layers(traces, 'mongo_test')
121
- validate_event_keys(traces[1], @entry_kvs)
122
- validate_event_keys(traces[2], @exit_kvs)
123
-
124
- traces[3]['QueryOp'].must_equal "count"
125
- end
126
-
127
- it "should trace find_and_modify" do
128
- coll = @db.collection("testCollection")
129
-
130
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
131
- coll.find_and_modify({ :query => { :name => "MyName" }, :update => { :count => 203 }})
132
- end
133
-
134
- traces = get_all_traces
135
- traces.count.must_equal 4
136
-
137
- validate_outer_layers(traces, 'mongo_test')
138
- validate_event_keys(traces[1], @entry_kvs)
139
- validate_event_keys(traces[2], @exit_kvs)
140
-
141
- traces[1]['Collection'].must_equal "testCollection"
142
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
143
- traces[1]['QueryOp'].must_equal "find_and_modify"
144
- traces[1]['Update_Document'].must_equal "{:count=>203}"
145
- end
146
-
147
- it "should trace insert" do
148
- coll = @db.collection("testCollection")
149
-
150
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
151
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
152
- coll.insert(doc)
153
- end
154
-
155
- traces = get_all_traces
156
- traces.count.must_equal 4
157
-
158
- validate_outer_layers(traces, 'mongo_test')
159
- validate_event_keys(traces[1], @entry_kvs)
160
- validate_event_keys(traces[2], @exit_kvs)
161
-
162
- traces[1]['Collection'].must_equal "testCollection"
163
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
164
- traces[1]['QueryOp'].must_equal "insert"
165
- # Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+
166
- traces[1].has_key?('Query').must_equal true
167
- end
168
-
169
- it "should trace map_reduce" do
170
- coll = @db.collection("testCollection")
171
-
172
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
173
- map = "function() { emit(this.name, 1); }"
174
- reduce = "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
175
- coll.map_reduce(map, reduce, { :out => "mr_results", :limit => 100, :read => :primary })
176
- end
177
-
178
- traces = get_all_traces
179
- traces.count.must_equal 4
180
-
181
- validate_outer_layers(traces, 'mongo_test')
182
- validate_event_keys(traces[1], @entry_kvs)
183
- validate_event_keys(traces[2], @exit_kvs)
184
-
185
- traces[1]['Collection'].must_equal "testCollection"
186
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
187
- traces[1]['QueryOp'].must_equal "map_reduce"
188
- traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
189
- traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
190
- traces[1]['Limit'].must_equal 100
191
- end
192
-
193
- it "should trace remove" do
194
- coll = @db.collection("testCollection")
195
-
196
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
197
- coll.remove(:name => "SaveOp")
198
- end
199
-
200
- traces = get_all_traces
201
- traces.count.must_equal 4
202
-
203
- validate_outer_layers(traces, 'mongo_test')
204
- validate_event_keys(traces[1], @entry_kvs)
205
- validate_event_keys(traces[2], @exit_kvs)
206
-
207
- traces[1]['Collection'].must_equal "testCollection"
208
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
209
- traces[1]['QueryOp'].must_equal "remove"
210
- traces[1]['Query'].must_equal "{\"name\":\"SaveOp\"}"
211
- end
212
-
213
- it "should trace rename" do
214
- coll = @db.collection("testCollection")
215
- new_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
216
-
217
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
218
- coll.rename(new_name)
219
- end
220
-
221
- traces = get_all_traces
222
- traces.count.must_equal 4
223
-
224
- validate_outer_layers(traces, 'mongo_test')
225
- validate_event_keys(traces[1], @entry_kvs)
226
- validate_event_keys(traces[2], @exit_kvs)
227
-
228
- traces[1]['Collection'].must_equal "testCollection"
229
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
230
- traces[1]['QueryOp'].must_equal "rename"
231
- traces[1]['New_Collection_Name'].must_equal new_name
232
-
233
- # Clean up after test and set collection name back to original
234
- coll.rename("testCollection")
235
- end
236
-
237
- it "should trace update" do
238
- coll = @db.collection("testCollection")
239
-
240
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
241
- # Two types of update calls
242
- coll.update({"_id" => 1}, { "$set" => {"name" => "MongoDB Ruby"}}, :multi => true)
243
-
244
- doc = {"name" => "MyOtherName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
245
- coll.update({"_id" => 1}, doc)
246
- end
247
-
248
- traces = get_all_traces
249
- traces.count.must_equal 6
250
-
251
- validate_outer_layers(traces, 'mongo_test')
252
- validate_event_keys(traces[1], @entry_kvs)
253
- validate_event_keys(traces[2], @exit_kvs)
254
-
255
- traces[1]['Collection'].must_equal "testCollection"
256
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
257
- traces[1]['QueryOp'].must_equal "update"
258
- traces[1]['Query'].must_equal "{\"_id\":1}"
259
-
260
- validate_event_keys(traces[3], @entry_kvs)
261
- validate_event_keys(traces[4], @exit_kvs)
262
-
263
- traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
264
- traces[3]['QueryOp'].must_equal "update"
265
- traces[3]['Query'].must_equal "{\"_id\":1}"
266
- end
267
-
268
- it "should trace distinct" do
269
- coll = @db.collection("testCollection")
270
-
271
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
272
- coll.distinct("count")
273
- end
274
-
275
- traces = get_all_traces
276
- traces.count.must_equal 4
277
-
278
- validate_outer_layers(traces, 'mongo_test')
279
- validate_event_keys(traces[1], @entry_kvs)
280
- validate_event_keys(traces[2], @exit_kvs)
281
-
282
- traces[1]['Collection'].must_equal "testCollection"
283
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
284
- traces[1]['QueryOp'].must_equal "distinct"
285
- end
286
-
287
- it "should trace find" do
288
- coll = @db.collection("testCollection")
289
- result = nil
290
-
291
- # Insert a doc to assure we get a result
292
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
293
- coll.insert(doc)
294
-
295
- # If given an optional block +find+ will yield a Cursor to that block,
296
- # close the cursor, and then return nil. This guarantees that partially
297
- # evaluated cursors will be closed. If given no block +find+ returns a
298
- # cursor.
299
- # https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
300
-
301
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
302
- result = coll.find(:name => "MyName", :limit => 1)
303
- end
304
-
305
- traces = get_all_traces
306
- traces.count.must_equal 4
307
-
308
- validate_outer_layers(traces, 'mongo_test')
309
- validate_event_keys(traces[1], @entry_kvs)
310
- validate_event_keys(traces[2], @exit_kvs)
311
-
312
- result.wont_match nil
313
- result.is_a?(Mongo::Cursor).must_equal true
314
- traces[1]['Collection'].must_equal "testCollection"
315
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
316
- traces[1]['QueryOp'].must_equal "find"
317
- traces[1].has_key?('Query').must_equal true
318
- traces[1]['Limit'].must_equal 1
319
- end
320
-
321
- it "should trace find (with block)" do
322
- coll = @db.collection("testCollection")
323
- result = []
324
-
325
- # Insert a doc to assure we get a result
326
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
327
- coll.insert(doc)
328
-
329
- # If given an optional block +find+ will yield a Cursor to that block,
330
- # close the cursor, and then return nil. This guarantees that partially
331
- # evaluated cursors will be closed. If given no block +find+ returns a
332
- # cursor.
333
- # https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
334
-
335
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
336
- blk = lambda { |x| x }
337
- result = coll.find(:name => "MyName", :limit => 10, &blk)
338
- end
339
-
340
- traces = get_all_traces
341
- traces.count.must_equal 4
342
-
343
- validate_outer_layers(traces, 'mongo_test')
344
- validate_event_keys(traces[1], @entry_kvs)
345
- validate_event_keys(traces[2], @exit_kvs)
346
-
347
- result.must_be_nil
348
- traces[1]['Collection'].must_equal "testCollection"
349
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
350
- traces[1]['QueryOp'].must_equal "find"
351
- traces[1].has_key?('Query').must_equal true
352
- end
353
-
354
- it "should trace group" do
355
- coll = @db.collection("testCollection")
356
-
357
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
358
- coll.group( :key => :type,
359
- :cond => { :count => 1 },
360
- :initial => { :count => 0 },
361
- :reduce => 'function(obj,prev) { prev.count += obj.c; }')
362
- end
363
-
364
- traces = get_all_traces
365
- traces.count.must_equal 4
366
-
367
- validate_outer_layers(traces, 'mongo_test')
368
- validate_event_keys(traces[1], @entry_kvs)
369
- validate_event_keys(traces[2], @exit_kvs)
370
-
371
- traces[1]['Collection'].must_equal "testCollection"
372
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
373
- traces[1]['QueryOp'].must_equal "group"
374
- # Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+
375
- traces[1].has_key?('Query').must_equal true
376
- end
377
-
378
- it "should trace create, ensure and drop index" do
379
- coll = @db.collection("testCollection")
380
-
381
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
382
- coll.create_index("i")
383
- coll.ensure_index("i")
384
- coll.drop_index("i_1")
385
- end
386
-
387
- traces = get_all_traces
388
- traces.count.must_equal 8
389
-
390
- validate_outer_layers(traces, 'mongo_test')
391
- validate_event_keys(traces[1], @entry_kvs)
392
- validate_event_keys(traces[2], @exit_kvs)
393
-
394
- traces[1]['Collection'].must_equal "testCollection"
395
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
396
- traces[1]['QueryOp'].must_equal "create_index"
397
-
398
- validate_event_keys(traces[3], @entry_kvs)
399
- validate_event_keys(traces[4], @exit_kvs)
400
-
401
- traces[3]['Collection'].must_equal "testCollection"
402
- traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
403
- traces[3]['QueryOp'].must_equal "ensure_index"
404
-
405
- validate_event_keys(traces[5], @entry_kvs)
406
- validate_event_keys(traces[6], @exit_kvs)
407
-
408
- traces[5]['Collection'].must_equal "testCollection"
409
- traces[5].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
410
- traces[5]['QueryOp'].must_equal "drop_index"
411
- end
412
-
413
- it "should trace drop_indexes" do
414
- coll = @db.collection("testCollection")
415
-
416
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
417
- coll.drop_indexes
418
- end
419
-
420
- traces = get_all_traces
421
- traces.count.must_equal 4
422
-
423
- validate_outer_layers(traces, 'mongo_test')
424
- validate_event_keys(traces[1], @entry_kvs)
425
- validate_event_keys(traces[2], @exit_kvs)
426
-
427
- traces[1]['Collection'].must_equal "testCollection"
428
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
429
- traces[1]['QueryOp'].must_equal "drop_indexes"
430
- end
431
-
432
- it "should trace index_information" do
433
- coll = @db.collection("testCollection")
434
-
435
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
436
- coll.index_information
437
- end
438
-
439
- traces = get_all_traces
440
- traces.count.must_equal 4
441
-
442
- validate_outer_layers(traces, 'mongo_test')
443
- validate_event_keys(traces[1], @entry_kvs)
444
- validate_event_keys(traces[2], @exit_kvs)
445
-
446
- traces[1]['Collection'].must_equal "testCollection"
447
- traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
448
- traces[1]['QueryOp'].must_equal "index_information"
449
- end
450
-
451
- it "should obey :collect_backtraces setting when true" do
452
- AppOpticsAPM::Config[:mongo][:collect_backtraces] = true
453
-
454
- coll = @db.collection("testCollection")
455
-
456
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
457
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
458
- coll.insert(doc)
459
- end
460
-
461
- traces = get_all_traces
462
- layer_has_key(traces, 'mongo', 'Backtrace')
463
- end
464
-
465
- it "should obey :collect_backtraces setting when false" do
466
- AppOpticsAPM::Config[:mongo][:collect_backtraces] = false
467
-
468
- coll = @db.collection("testCollection")
469
-
470
- AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
471
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
472
- coll.insert(doc)
473
- end
474
-
475
- traces = get_all_traces
476
- layer_doesnt_have_key(traces, 'mongo', 'Backtrace')
477
- end
478
- end
479
- end