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.
- checksums.yaml +4 -4
- data/Dockerfile_test +6 -7
- data/README.md +3 -3
- data/Rakefile +3 -2
- data/appoptics_apm.gemspec +2 -2
- data/docker-compose.yml +0 -22
- data/ext/oboe_metal/extconf.rb +4 -0
- data/lib/appoptics_apm/config.rb +11 -6
- data/lib/appoptics_apm/version.rb +1 -1
- metadata +3 -202
- data/gemfiles/delayed_job.gemfile +0 -36
- data/gemfiles/frameworks.gemfile +0 -44
- data/gemfiles/instrumentation_mocked.gemfile +0 -29
- data/gemfiles/libraries.gemfile +0 -85
- data/gemfiles/noop.gemfile +0 -17
- data/gemfiles/rails23.gemfile +0 -39
- data/gemfiles/rails30.gemfile +0 -42
- data/gemfiles/rails31.gemfile +0 -44
- data/gemfiles/rails32.gemfile +0 -54
- data/gemfiles/rails40.gemfile +0 -27
- data/gemfiles/rails41.gemfile +0 -27
- data/gemfiles/rails42.gemfile +0 -35
- data/gemfiles/rails50.gemfile +0 -44
- data/gemfiles/rails51.gemfile +0 -44
- data/test/benchmark/README.md +0 -65
- data/test/benchmark/logging_bench.rb +0 -54
- data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
- data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
- data/test/frameworks/apps/grape_nested.rb +0 -33
- data/test/frameworks/apps/grape_simple.rb +0 -80
- data/test/frameworks/apps/padrino_simple.rb +0 -80
- data/test/frameworks/apps/sinatra_simple.rb +0 -55
- data/test/frameworks/grape_test.rb +0 -286
- data/test/frameworks/padrino_test.rb +0 -222
- data/test/frameworks/rails3x_test.rb +0 -554
- data/test/frameworks/rails4x_test.rb +0 -570
- data/test/frameworks/rails5x_api_test.rb +0 -210
- data/test/frameworks/rails5x_test.rb +0 -376
- data/test/frameworks/rails_shared_tests.rb +0 -172
- data/test/frameworks/sinatra_test.rb +0 -140
- data/test/instrumentation/bunny_client_test.rb +0 -276
- data/test/instrumentation/bunny_consumer_test.rb +0 -204
- data/test/instrumentation/curb_test.rb +0 -398
- data/test/instrumentation/dalli_test.rb +0 -177
- data/test/instrumentation/em_http_request_test.rb +0 -89
- data/test/instrumentation/excon_test.rb +0 -231
- data/test/instrumentation/faraday_test.rb +0 -228
- data/test/instrumentation/http_test.rb +0 -143
- data/test/instrumentation/httpclient_test.rb +0 -304
- data/test/instrumentation/memcache_test.rb +0 -260
- data/test/instrumentation/memcached_test.rb +0 -229
- data/test/instrumentation/mongo_v1_test.rb +0 -479
- data/test/instrumentation/mongo_v2_index_test.rb +0 -124
- data/test/instrumentation/mongo_v2_test.rb +0 -584
- data/test/instrumentation/mongo_v2_view_test.rb +0 -435
- data/test/instrumentation/moped_test.rb +0 -517
- data/test/instrumentation/rack_test.rb +0 -165
- data/test/instrumentation/redis_hashes_test.rb +0 -268
- data/test/instrumentation/redis_keys_test.rb +0 -321
- data/test/instrumentation/redis_lists_test.rb +0 -310
- data/test/instrumentation/redis_misc_test.rb +0 -163
- data/test/instrumentation/redis_sets_test.rb +0 -296
- data/test/instrumentation/redis_sortedsets_test.rb +0 -328
- data/test/instrumentation/redis_strings_test.rb +0 -349
- data/test/instrumentation/resque_test.rb +0 -185
- data/test/instrumentation/rest-client_test.rb +0 -288
- data/test/instrumentation/sequel_mysql2_test.rb +0 -353
- data/test/instrumentation/sequel_mysql_test.rb +0 -334
- data/test/instrumentation/sequel_pg_test.rb +0 -336
- data/test/instrumentation/sidekiq-client_test.rb +0 -159
- data/test/instrumentation/sidekiq-worker_test.rb +0 -180
- data/test/instrumentation/twitter-cassandra_test.rb +0 -424
- data/test/instrumentation/typhoeus_test.rb +0 -284
- data/test/jobs/delayed_job/db_worker_job.rb +0 -29
- data/test/jobs/delayed_job/error_worker_job.rb +0 -10
- data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
- data/test/jobs/resque/db_worker_job.rb +0 -29
- data/test/jobs/resque/error_worker_job.rb +0 -10
- data/test/jobs/resque/remote_call_worker_job.rb +0 -20
- data/test/jobs/sidekiq/db_worker_job.rb +0 -29
- data/test/jobs/sidekiq/error_worker_job.rb +0 -10
- data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
- data/test/minitest_helper.rb +0 -277
- data/test/mocked/curb_mocked_test.rb +0 -324
- data/test/mocked/excon_mocked_test.rb +0 -174
- data/test/mocked/faraday_mocked_test.rb +0 -97
- data/test/mocked/http_mocked_test.rb +0 -135
- data/test/mocked/httpclient_mocked_test.rb +0 -258
- data/test/mocked/rest_client_mocked_test.rb +0 -109
- data/test/mocked/typhoeus_mocked_test.rb +0 -207
- data/test/models/widget.rb +0 -36
- data/test/noop/noop_test.rb +0 -145
- data/test/profiling/legacy_method_profiling_test.rb +0 -201
- data/test/profiling/method_profiling_test.rb +0 -631
- data/test/queues/delayed_job-client_test.rb +0 -95
- data/test/queues/delayed_job-worker_test.rb +0 -91
- data/test/reporter/reporter_test.rb +0 -14
- data/test/servers/delayed_job.rb +0 -107
- data/test/servers/rackapp_8101.rb +0 -29
- data/test/servers/rails3x_8140.rb +0 -96
- data/test/servers/rails4x_8140.rb +0 -96
- data/test/servers/rails5x_8140.rb +0 -95
- data/test/servers/rails5x_api_8150.rb +0 -78
- data/test/servers/sidekiq.rb +0 -29
- data/test/servers/sidekiq.yml +0 -7
- data/test/servers/sidekiq_initializer.rb +0 -25
- data/test/settings +0 -0
- data/test/support/auto_tracing_test.rb +0 -50
- data/test/support/backcompat_test.rb +0 -276
- data/test/support/config_test.rb +0 -149
- data/test/support/dnt_test.rb +0 -98
- data/test/support/init_report_test.rb +0 -25
- data/test/support/liboboe_settings_test.rb +0 -110
- data/test/support/logging_test.rb +0 -130
- data/test/support/sql_sanitize_test.rb +0 -55
- data/test/support/tracing_mode_test.rb +0 -33
- data/test/support/tvalias_test.rb +0 -15
- data/test/support/xtrace_test.rb +0 -41
@@ -1,435 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'minitest_helper'
|
5
|
-
|
6
|
-
|
7
|
-
ENV['APPOPTICS_MONGO_SERVER'] = "127.0.0.1:27017" unless ENV['APPOPTICS_MONGO_SERVER']
|
8
|
-
ENV['APPOPTICS_MONGO_SERVER'] += ':27017' unless ENV['APPOPTICS_MONGO_SERVER'] =~ /\:27017$/
|
9
|
-
|
10
|
-
if defined?(::Mongo::VERSION) && Mongo::VERSION >= '2.0.0'
|
11
|
-
describe "MongoCollectionView" do
|
12
|
-
before do
|
13
|
-
clear_all_traces
|
14
|
-
|
15
|
-
@client = Mongo::Client.new([ ENV['APPOPTICS_MONGO_SERVER'] ], :database => "appoptics_apm-#{ENV['RACK_ENV']}")
|
16
|
-
if Mongo::VERSION < '2.2'
|
17
|
-
Mongo::Logger.logger.level = Logger::INFO
|
18
|
-
else
|
19
|
-
@client.logger.level = Logger::INFO
|
20
|
-
end
|
21
|
-
|
22
|
-
@db = @client.database
|
23
|
-
|
24
|
-
@collections = @db.collection_names
|
25
|
-
@testCollection = @client[:test_collection]
|
26
|
-
@testCollection.create unless @collections.include? "test_collection"
|
27
|
-
|
28
|
-
# These are standard entry/exit KVs that are passed up with all mongo operations
|
29
|
-
@entry_kvs = {
|
30
|
-
'Layer' => 'mongo',
|
31
|
-
'Label' => 'entry',
|
32
|
-
'Flavor' => 'mongodb',
|
33
|
-
'Database' => 'appoptics_apm-test',
|
34
|
-
'RemoteHost' => ENV['APPOPTICS_MONGO_SERVER'] }
|
35
|
-
|
36
|
-
@exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
|
37
|
-
@collect_backtraces = AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
38
|
-
end
|
39
|
-
|
40
|
-
after do
|
41
|
-
AppOpticsAPM::Config[:mongo][:collect_backtraces] = @collect_backtraces
|
42
|
-
end
|
43
|
-
|
44
|
-
it "should trace find_one_and_delete" do
|
45
|
-
coll = @db[:test_collection]
|
46
|
-
r = nil
|
47
|
-
|
48
|
-
# Insert a doc to assure we get a result
|
49
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
50
|
-
coll.insert_one(doc)
|
51
|
-
cv = coll.find({:name => "MyName"})
|
52
|
-
|
53
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
54
|
-
r = cv.find_one_and_delete
|
55
|
-
end
|
56
|
-
|
57
|
-
traces = get_all_traces
|
58
|
-
traces.count.must_equal 4
|
59
|
-
|
60
|
-
validate_outer_layers(traces, 'mongo_test')
|
61
|
-
validate_event_keys(traces[1], @entry_kvs)
|
62
|
-
validate_event_keys(traces[2], @exit_kvs)
|
63
|
-
|
64
|
-
r.must_be_instance_of BSON::Document
|
65
|
-
|
66
|
-
traces[1]['Collection'].must_equal "test_collection"
|
67
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
68
|
-
traces[1]['QueryOp'].must_equal "find_one_and_delete"
|
69
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
70
|
-
traces[1].has_key?('Query').must_equal true
|
71
|
-
end
|
72
|
-
|
73
|
-
it "should trace find_one_and_update" do
|
74
|
-
coll = @db[:test_collection]
|
75
|
-
r = nil
|
76
|
-
|
77
|
-
# Insert a doc to assure we get a result
|
78
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
79
|
-
coll.insert_one(doc)
|
80
|
-
cv = coll.find({:name => "MyName"})
|
81
|
-
|
82
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
83
|
-
r = cv.find_one_and_update({ "$set" => { :name => 'test1' }}, :return_document => :after)
|
84
|
-
end
|
85
|
-
|
86
|
-
traces = get_all_traces
|
87
|
-
traces.count.must_equal 4
|
88
|
-
|
89
|
-
validate_outer_layers(traces, 'mongo_test')
|
90
|
-
validate_event_keys(traces[1], @entry_kvs)
|
91
|
-
validate_event_keys(traces[2], @exit_kvs)
|
92
|
-
|
93
|
-
r.must_be_instance_of BSON::Document
|
94
|
-
|
95
|
-
traces[1]['Collection'].must_equal "test_collection"
|
96
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
97
|
-
traces[1]['QueryOp'].must_equal "find_one_and_update"
|
98
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
99
|
-
traces[1].has_key?('Query').must_equal true
|
100
|
-
end
|
101
|
-
|
102
|
-
it "should trace update_one" do
|
103
|
-
coll = @db[:test_collection]
|
104
|
-
r = nil
|
105
|
-
|
106
|
-
# Insert a doc to assure we get a result
|
107
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
108
|
-
coll.insert_one(doc)
|
109
|
-
cv = coll.find({:name => "MyName"})
|
110
|
-
|
111
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
112
|
-
r = cv.update_one({ "$set" => { :name => 'test1' }}, :return_document => :after)
|
113
|
-
end
|
114
|
-
|
115
|
-
traces = get_all_traces
|
116
|
-
traces.count.must_equal 4
|
117
|
-
|
118
|
-
validate_outer_layers(traces, 'mongo_test')
|
119
|
-
validate_event_keys(traces[1], @entry_kvs)
|
120
|
-
validate_event_keys(traces[2], @exit_kvs)
|
121
|
-
|
122
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
123
|
-
|
124
|
-
traces[1]['Collection'].must_equal "test_collection"
|
125
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
126
|
-
traces[1]['QueryOp'].must_equal "update_one"
|
127
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
128
|
-
traces[1].has_key?('Query').must_equal true
|
129
|
-
end
|
130
|
-
|
131
|
-
it "should trace update_many" do
|
132
|
-
coll = @db[:test_collection]
|
133
|
-
r = nil
|
134
|
-
|
135
|
-
# Insert a doc to assure we get a result
|
136
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
137
|
-
coll.insert_one(doc)
|
138
|
-
cv = coll.find({:name => "MyName"})
|
139
|
-
|
140
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
141
|
-
r = cv.update_many({ "$set" => { :name => 'test1' }}, :return_document => :after)
|
142
|
-
end
|
143
|
-
|
144
|
-
traces = get_all_traces
|
145
|
-
traces.count.must_equal 4
|
146
|
-
|
147
|
-
validate_outer_layers(traces, 'mongo_test')
|
148
|
-
validate_event_keys(traces[1], @entry_kvs)
|
149
|
-
validate_event_keys(traces[2], @exit_kvs)
|
150
|
-
|
151
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
152
|
-
|
153
|
-
traces[1]['Collection'].must_equal "test_collection"
|
154
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
155
|
-
traces[1]['QueryOp'].must_equal "update_many"
|
156
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
157
|
-
traces[1].has_key?('Query').must_equal true
|
158
|
-
end
|
159
|
-
|
160
|
-
it "should trace collection delete_one" do
|
161
|
-
coll = @db[:test_collection]
|
162
|
-
r = nil
|
163
|
-
|
164
|
-
# Insert a doc to assure we get a result
|
165
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
166
|
-
coll.insert_one(doc)
|
167
|
-
cv = coll.find({:name => "MyName"})
|
168
|
-
|
169
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
170
|
-
r = cv.delete_one
|
171
|
-
end
|
172
|
-
|
173
|
-
traces = get_all_traces
|
174
|
-
traces.count.must_equal 4
|
175
|
-
|
176
|
-
validate_outer_layers(traces, 'mongo_test')
|
177
|
-
validate_event_keys(traces[1], @entry_kvs)
|
178
|
-
validate_event_keys(traces[2], @exit_kvs)
|
179
|
-
|
180
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
181
|
-
|
182
|
-
traces[1]['Collection'].must_equal "test_collection"
|
183
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
184
|
-
traces[1]['QueryOp'].must_equal "delete_one"
|
185
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
186
|
-
traces[1].has_key?('Query').must_equal true
|
187
|
-
end
|
188
|
-
|
189
|
-
it "should trace collection delete_many" do
|
190
|
-
coll = @db[:test_collection]
|
191
|
-
r = nil
|
192
|
-
|
193
|
-
# Insert a doc to assure we get a result
|
194
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
195
|
-
coll.insert_one(doc)
|
196
|
-
cv = coll.find({ :name => 'MyName' })
|
197
|
-
|
198
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
199
|
-
r = cv.delete_many
|
200
|
-
end
|
201
|
-
|
202
|
-
traces = get_all_traces
|
203
|
-
traces.count.must_equal 4
|
204
|
-
|
205
|
-
validate_outer_layers(traces, 'mongo_test')
|
206
|
-
validate_event_keys(traces[1], @entry_kvs)
|
207
|
-
validate_event_keys(traces[2], @exit_kvs)
|
208
|
-
|
209
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
210
|
-
|
211
|
-
traces[1]['Collection'].must_equal "test_collection"
|
212
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
213
|
-
traces[1]['QueryOp'].must_equal "delete_many"
|
214
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
215
|
-
traces[1].has_key?('Query').must_equal true
|
216
|
-
end
|
217
|
-
|
218
|
-
it "should trace collection view delete_one" do
|
219
|
-
coll = @db[:test_collection]
|
220
|
-
r = nil
|
221
|
-
|
222
|
-
# Insert a doc to assure we get a result
|
223
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
224
|
-
coll.insert_one(doc)
|
225
|
-
cv = coll.find({ :name => 'MyName' })
|
226
|
-
|
227
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
228
|
-
r = cv.delete_one
|
229
|
-
end
|
230
|
-
|
231
|
-
traces = get_all_traces
|
232
|
-
traces.count.must_equal 4
|
233
|
-
|
234
|
-
validate_outer_layers(traces, 'mongo_test')
|
235
|
-
validate_event_keys(traces[1], @entry_kvs)
|
236
|
-
validate_event_keys(traces[2], @exit_kvs)
|
237
|
-
|
238
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
239
|
-
|
240
|
-
traces[1]['Collection'].must_equal "test_collection"
|
241
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
242
|
-
traces[1]['QueryOp'].must_equal "delete_one"
|
243
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
244
|
-
traces[1].has_key?('Query').must_equal true
|
245
|
-
end
|
246
|
-
|
247
|
-
it "should trace collection view delete_many" do
|
248
|
-
coll = @db[:test_collection]
|
249
|
-
r = nil
|
250
|
-
|
251
|
-
# Insert a doc to assure we get a result
|
252
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
253
|
-
coll.insert_one(doc)
|
254
|
-
cv = coll.find({ :name => 'MyName' })
|
255
|
-
|
256
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
257
|
-
r = cv.delete_many
|
258
|
-
end
|
259
|
-
|
260
|
-
traces = get_all_traces
|
261
|
-
traces.count.must_equal 4
|
262
|
-
|
263
|
-
validate_outer_layers(traces, 'mongo_test')
|
264
|
-
validate_event_keys(traces[1], @entry_kvs)
|
265
|
-
validate_event_keys(traces[2], @exit_kvs)
|
266
|
-
|
267
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
268
|
-
|
269
|
-
traces[1]['Collection'].must_equal "test_collection"
|
270
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
271
|
-
traces[1]['QueryOp'].must_equal "delete_many"
|
272
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
273
|
-
traces[1].has_key?('Query').must_equal true
|
274
|
-
end
|
275
|
-
|
276
|
-
it "should trace replace_one" do
|
277
|
-
coll = @db[:test_collection]
|
278
|
-
r = nil
|
279
|
-
|
280
|
-
# Insert a doc to assure we get a result
|
281
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
282
|
-
coll.insert_one(doc)
|
283
|
-
cv = coll.find({ :name => 'MyName' })
|
284
|
-
|
285
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
286
|
-
r = cv.replace_one({ :name => 'test1' })
|
287
|
-
end
|
288
|
-
|
289
|
-
traces = get_all_traces
|
290
|
-
traces.count.must_equal 4
|
291
|
-
|
292
|
-
validate_outer_layers(traces, 'mongo_test')
|
293
|
-
validate_event_keys(traces[1], @entry_kvs)
|
294
|
-
validate_event_keys(traces[2], @exit_kvs)
|
295
|
-
|
296
|
-
r.class.ancestors.include?(Mongo::Operation::Result).must_equal true
|
297
|
-
|
298
|
-
traces[1]['Collection'].must_equal "test_collection"
|
299
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
300
|
-
traces[1]['QueryOp'].must_equal "replace_one"
|
301
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
302
|
-
traces[1].has_key?('Query').must_equal true
|
303
|
-
end
|
304
|
-
|
305
|
-
it "should trace count" do
|
306
|
-
coll = @db[:test_collection]
|
307
|
-
r = nil
|
308
|
-
|
309
|
-
cv = coll.find({ :name => 'MyName' })
|
310
|
-
|
311
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
312
|
-
r = cv.count({ :name => 'MyName' })
|
313
|
-
end
|
314
|
-
|
315
|
-
traces = get_all_traces
|
316
|
-
traces.count.must_equal 4
|
317
|
-
|
318
|
-
validate_outer_layers(traces, 'mongo_test')
|
319
|
-
validate_event_keys(traces[1], @entry_kvs)
|
320
|
-
validate_event_keys(traces[2], @exit_kvs)
|
321
|
-
|
322
|
-
r.is_a?(Numeric).must_equal true
|
323
|
-
|
324
|
-
traces[1]['Collection'].must_equal "test_collection"
|
325
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
326
|
-
traces[1]['QueryOp'].must_equal "count"
|
327
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
328
|
-
traces[1].has_key?('Query').must_equal true
|
329
|
-
end
|
330
|
-
|
331
|
-
it "should trace distinct" do
|
332
|
-
coll = @db[:test_collection]
|
333
|
-
r = nil
|
334
|
-
|
335
|
-
cv = coll.find({ :name => 'MyName' })
|
336
|
-
|
337
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
338
|
-
r = cv.distinct('name', { :name => 'MyName' })
|
339
|
-
end
|
340
|
-
|
341
|
-
traces = get_all_traces
|
342
|
-
traces.count.must_equal 4
|
343
|
-
|
344
|
-
validate_outer_layers(traces, 'mongo_test')
|
345
|
-
validate_event_keys(traces[1], @entry_kvs)
|
346
|
-
validate_event_keys(traces[2], @exit_kvs)
|
347
|
-
|
348
|
-
r.is_a?(Array).must_equal true
|
349
|
-
|
350
|
-
traces[1]['Collection'].must_equal "test_collection"
|
351
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
352
|
-
traces[1]['QueryOp'].must_equal "distinct"
|
353
|
-
traces[1]['Query'].must_equal "{\"name\":\"MyName\"}"
|
354
|
-
traces[1].has_key?('Query').must_equal true
|
355
|
-
end
|
356
|
-
|
357
|
-
it "should trace aggregate" do
|
358
|
-
coll = @db[:test_collection]
|
359
|
-
r = nil
|
360
|
-
|
361
|
-
cv = coll.find({ :name => 'MyName' })
|
362
|
-
|
363
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
364
|
-
r = cv.aggregate([ { "$group" => { "_id" => "$city", "tpop" => { "$sum" => "$pop" }}} ])
|
365
|
-
end
|
366
|
-
|
367
|
-
traces = get_all_traces
|
368
|
-
traces.count.must_equal 4
|
369
|
-
|
370
|
-
validate_outer_layers(traces, 'mongo_test')
|
371
|
-
validate_event_keys(traces[1], @entry_kvs)
|
372
|
-
validate_event_keys(traces[2], @exit_kvs)
|
373
|
-
|
374
|
-
r.must_be_instance_of Mongo::Collection::View::Aggregation
|
375
|
-
|
376
|
-
traces[1]['Collection'].must_equal "test_collection"
|
377
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
378
|
-
traces[1]['QueryOp'].must_equal "aggregate"
|
379
|
-
traces[1].key?('Query').must_equal false
|
380
|
-
end
|
381
|
-
|
382
|
-
it "should trace map_reduce" do
|
383
|
-
coll = @db[:test_collection]
|
384
|
-
view = coll.find(:name => "MyName")
|
385
|
-
|
386
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
387
|
-
map = "function() { emit(this.name, 1); }"
|
388
|
-
reduce = "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
389
|
-
view.map_reduce(map, reduce, { :out => "mr_results", :limit => 100, :read => :primary })
|
390
|
-
end
|
391
|
-
|
392
|
-
traces = get_all_traces
|
393
|
-
traces.count.must_equal 4
|
394
|
-
|
395
|
-
validate_outer_layers(traces, 'mongo_test')
|
396
|
-
validate_event_keys(traces[1], @entry_kvs)
|
397
|
-
validate_event_keys(traces[2], @exit_kvs)
|
398
|
-
|
399
|
-
traces[1]['Collection'].must_equal "test_collection"
|
400
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:mongo][:collect_backtraces]
|
401
|
-
traces[1]['QueryOp'].must_equal "map_reduce"
|
402
|
-
traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
|
403
|
-
traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
404
|
-
traces[1]['Limit'].must_equal 100
|
405
|
-
end
|
406
|
-
|
407
|
-
it "should obey :collect_backtraces setting when true" do
|
408
|
-
AppOpticsAPM::Config[:mongo][:collect_backtraces] = true
|
409
|
-
|
410
|
-
coll = @db[:test_collection]
|
411
|
-
|
412
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
413
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
414
|
-
coll.insert_one(doc)
|
415
|
-
end
|
416
|
-
|
417
|
-
traces = get_all_traces
|
418
|
-
layer_has_key(traces, 'mongo', 'Backtrace')
|
419
|
-
end
|
420
|
-
|
421
|
-
it "should obey :collect_backtraces setting when false" do
|
422
|
-
AppOpticsAPM::Config[:mongo][:collect_backtraces] = false
|
423
|
-
|
424
|
-
coll = @db[:test_collection]
|
425
|
-
|
426
|
-
AppOpticsAPM::API.start_trace('mongo_test', '', {}) do
|
427
|
-
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
428
|
-
coll.insert_one(doc)
|
429
|
-
end
|
430
|
-
|
431
|
-
traces = get_all_traces
|
432
|
-
layer_doesnt_have_key(traces, 'mongo', 'Backtrace')
|
433
|
-
end
|
434
|
-
end
|
435
|
-
end
|
@@ -1,517 +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 RUBY_VERSION >= '1.9.3'
|
11
|
-
# Moped is tested against MRI 2.3.1 and 2.4.1
|
12
|
-
|
13
|
-
describe "Moped" do
|
14
|
-
before do
|
15
|
-
clear_all_traces
|
16
|
-
@session = Moped::Session.new([ ENV['APPOPTICS_MONGO_SERVER'] ])
|
17
|
-
@session.use :moped_test
|
18
|
-
@users = @session[:users]
|
19
|
-
@users.drop
|
20
|
-
@users.insert({ :name => "Syd", :city => "Boston" })
|
21
|
-
|
22
|
-
# These are standard entry/exit KVs that are passed up with all moped operations
|
23
|
-
@entry_kvs = {
|
24
|
-
'Layer' => 'mongo',
|
25
|
-
'Label' => 'entry',
|
26
|
-
'Flavor' => 'mongodb',
|
27
|
-
'Database' => 'moped_test',
|
28
|
-
'RemoteHost' => ENV['APPOPTICS_MONGO_SERVER'] }
|
29
|
-
|
30
|
-
@exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
|
31
|
-
@collect_backtraces = AppOpticsAPM::Config[:moped][:collect_backtraces]
|
32
|
-
end
|
33
|
-
|
34
|
-
after do
|
35
|
-
AppOpticsAPM::Config[:moped][:collect_backtraces] = @collect_backtraces
|
36
|
-
end
|
37
|
-
|
38
|
-
it 'Stock Moped should be loaded, defined and ready' do
|
39
|
-
defined?(::Moped).wont_match nil
|
40
|
-
defined?(::Moped::Database).wont_match nil
|
41
|
-
defined?(::Moped::Indexes).wont_match nil
|
42
|
-
defined?(::Moped::Query).wont_match nil
|
43
|
-
defined?(::Moped::Collection).wont_match nil
|
44
|
-
end
|
45
|
-
|
46
|
-
it 'Moped should have appoptics_apm methods defined' do
|
47
|
-
#::Moped::Database
|
48
|
-
AppOpticsAPM::Inst::Moped::DB_OPS.each do |m|
|
49
|
-
::Moped::Database.method_defined?("#{m}_with_appoptics").must_equal true
|
50
|
-
end
|
51
|
-
::Moped::Database.method_defined?(:extract_trace_details).must_equal true
|
52
|
-
::Moped::Database.method_defined?(:command_with_appoptics).must_equal true
|
53
|
-
::Moped::Database.method_defined?(:drop_with_appoptics).must_equal true
|
54
|
-
|
55
|
-
#::Moped::Indexes
|
56
|
-
AppOpticsAPM::Inst::Moped::INDEX_OPS.each do |m|
|
57
|
-
::Moped::Indexes.method_defined?("#{m}_with_appoptics").must_equal true
|
58
|
-
end
|
59
|
-
::Moped::Indexes.method_defined?(:extract_trace_details).must_equal true
|
60
|
-
::Moped::Indexes.method_defined?(:create_with_appoptics).must_equal true
|
61
|
-
::Moped::Indexes.method_defined?(:drop_with_appoptics).must_equal true
|
62
|
-
|
63
|
-
#::Moped::Query
|
64
|
-
AppOpticsAPM::Inst::Moped::QUERY_OPS.each do |m|
|
65
|
-
::Moped::Query.method_defined?("#{m}_with_appoptics").must_equal true
|
66
|
-
end
|
67
|
-
::Moped::Query.method_defined?(:extract_trace_details).must_equal true
|
68
|
-
|
69
|
-
#::Moped::Collection
|
70
|
-
AppOpticsAPM::Inst::Moped::COLLECTION_OPS.each do |m|
|
71
|
-
::Moped::Collection.method_defined?("#{m}_with_appoptics").must_equal true
|
72
|
-
end
|
73
|
-
::Moped::Collection.method_defined?(:extract_trace_details).must_equal true
|
74
|
-
end
|
75
|
-
|
76
|
-
it 'should trace command' do
|
77
|
-
# TODO: This randomly fails for a yet unknown reason. Does it?
|
78
|
-
# skip
|
79
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
80
|
-
command = {}
|
81
|
-
command[:mapreduce] = "users"
|
82
|
-
command[:map] = "function() { emit(this.name, 1); }"
|
83
|
-
command[:reduce] = "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
84
|
-
command[:out] = "inline: 1"
|
85
|
-
@session.command(command)
|
86
|
-
end
|
87
|
-
|
88
|
-
traces = get_all_traces
|
89
|
-
|
90
|
-
traces.count.must_equal 4
|
91
|
-
validate_outer_layers(traces, 'moped_test')
|
92
|
-
|
93
|
-
validate_event_keys(traces[1], @entry_kvs)
|
94
|
-
traces[1]['QueryOp'].must_equal "map_reduce"
|
95
|
-
traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
|
96
|
-
traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0;" +
|
97
|
-
" for(var i in vals) sum += vals[i]; return sum; }"
|
98
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
99
|
-
validate_event_keys(traces[2], @exit_kvs)
|
100
|
-
end
|
101
|
-
|
102
|
-
it 'should trace drop_collection' do
|
103
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
104
|
-
@users.drop
|
105
|
-
@session.drop
|
106
|
-
end
|
107
|
-
|
108
|
-
traces = get_all_traces
|
109
|
-
|
110
|
-
traces.count.must_equal 6
|
111
|
-
validate_outer_layers(traces, 'moped_test')
|
112
|
-
|
113
|
-
validate_event_keys(traces[1], @entry_kvs)
|
114
|
-
traces[1]['QueryOp'].must_equal "drop_collection"
|
115
|
-
traces[1]['Collection'].must_equal "users"
|
116
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
117
|
-
validate_event_keys(traces[2], @exit_kvs)
|
118
|
-
|
119
|
-
validate_event_keys(traces[3], @entry_kvs)
|
120
|
-
traces[3]['QueryOp'].must_equal "drop_database"
|
121
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
122
|
-
validate_event_keys(traces[4], @exit_kvs)
|
123
|
-
end
|
124
|
-
|
125
|
-
it 'should trace create_index, indexes and drop_indexes' do
|
126
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
127
|
-
@users.indexes.create({:name => 1}, {:unique => true})
|
128
|
-
@users.indexes.drop
|
129
|
-
end
|
130
|
-
|
131
|
-
traces = get_all_traces
|
132
|
-
|
133
|
-
traces.count.must_equal 10
|
134
|
-
validate_outer_layers(traces, 'moped_test')
|
135
|
-
|
136
|
-
validate_event_keys(traces[1], @entry_kvs)
|
137
|
-
traces[1]['QueryOp'].must_equal "indexes"
|
138
|
-
traces[1]['Collection'].must_equal "users"
|
139
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
140
|
-
validate_event_keys(traces[2], @exit_kvs)
|
141
|
-
|
142
|
-
validate_event_keys(traces[3], @entry_kvs)
|
143
|
-
traces[3]['QueryOp'].must_equal "create_index"
|
144
|
-
traces[3]['Key'].must_equal "{\"name\":1}"
|
145
|
-
traces[3]['Options'].must_equal "{\"unique\":true}"
|
146
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
147
|
-
validate_event_keys(traces[4], @exit_kvs)
|
148
|
-
|
149
|
-
validate_event_keys(traces[5], @entry_kvs)
|
150
|
-
traces[5]['QueryOp'].must_equal "indexes"
|
151
|
-
traces[5]['Collection'].must_equal "users"
|
152
|
-
traces[5].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
153
|
-
validate_event_keys(traces[6], @exit_kvs)
|
154
|
-
|
155
|
-
validate_event_keys(traces[7], @entry_kvs)
|
156
|
-
traces[7]['QueryOp'].must_equal "drop_indexes"
|
157
|
-
traces[7]['Key'].must_equal "all"
|
158
|
-
traces[7].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
159
|
-
validate_event_keys(traces[8], @exit_kvs)
|
160
|
-
end
|
161
|
-
|
162
|
-
it 'should trace find and count' do
|
163
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
164
|
-
@users.find.count
|
165
|
-
end
|
166
|
-
|
167
|
-
traces = get_all_traces
|
168
|
-
|
169
|
-
traces.count.must_equal 6
|
170
|
-
validate_outer_layers(traces, 'moped_test')
|
171
|
-
|
172
|
-
validate_event_keys(traces[1], @entry_kvs)
|
173
|
-
traces[1]['QueryOp'].must_equal "find"
|
174
|
-
traces[1]['Collection'].must_equal "users"
|
175
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
176
|
-
validate_event_keys(traces[2], @exit_kvs)
|
177
|
-
|
178
|
-
validate_event_keys(traces[3], @entry_kvs)
|
179
|
-
traces[3]['QueryOp'].must_equal "count"
|
180
|
-
traces[3]['Query'].must_equal "all"
|
181
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
182
|
-
validate_event_keys(traces[4], @exit_kvs)
|
183
|
-
end
|
184
|
-
|
185
|
-
it 'should trace find and sort' do
|
186
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
187
|
-
@users.find(:name => "Mary").sort(:city => 1, :created_at => -1)
|
188
|
-
end
|
189
|
-
|
190
|
-
traces = get_all_traces
|
191
|
-
|
192
|
-
traces.count.must_equal 6
|
193
|
-
validate_outer_layers(traces, 'moped_test')
|
194
|
-
|
195
|
-
validate_event_keys(traces[1], @entry_kvs)
|
196
|
-
traces[1]['QueryOp'].must_equal "find"
|
197
|
-
traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
|
198
|
-
traces[1]['Collection'].must_equal "users"
|
199
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
200
|
-
validate_event_keys(traces[2], @exit_kvs)
|
201
|
-
|
202
|
-
validate_event_keys(traces[3], @entry_kvs)
|
203
|
-
traces[3]['QueryOp'].must_equal "sort"
|
204
|
-
traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
|
205
|
-
traces[3]['Order'].must_equal "{:city=>1, :created_at=>-1}"
|
206
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
207
|
-
validate_event_keys(traces[4], @exit_kvs)
|
208
|
-
end
|
209
|
-
|
210
|
-
it 'should trace find with limit' do
|
211
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
212
|
-
@users.find(:name => "Mary").limit(1)
|
213
|
-
end
|
214
|
-
|
215
|
-
traces = get_all_traces
|
216
|
-
|
217
|
-
traces.count.must_equal 6
|
218
|
-
validate_outer_layers(traces, 'moped_test')
|
219
|
-
|
220
|
-
validate_event_keys(traces[1], @entry_kvs)
|
221
|
-
traces[1]['QueryOp'].must_equal "find"
|
222
|
-
traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
|
223
|
-
traces[1]['Collection'].must_equal "users"
|
224
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
225
|
-
validate_event_keys(traces[2], @exit_kvs)
|
226
|
-
|
227
|
-
validate_event_keys(traces[3], @entry_kvs)
|
228
|
-
traces[3]['QueryOp'].must_equal "limit"
|
229
|
-
traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
|
230
|
-
traces[3]['Limit'].must_equal "1"
|
231
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
232
|
-
validate_event_keys(traces[4], @exit_kvs)
|
233
|
-
end
|
234
|
-
|
235
|
-
it 'should trace find with distinct' do
|
236
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
237
|
-
@users.find(:name => "Mary").distinct(:city)
|
238
|
-
end
|
239
|
-
|
240
|
-
traces = get_all_traces
|
241
|
-
|
242
|
-
traces.count.must_equal 6
|
243
|
-
validate_outer_layers(traces, 'moped_test')
|
244
|
-
|
245
|
-
validate_event_keys(traces[1], @entry_kvs)
|
246
|
-
traces[1]['QueryOp'].must_equal "find"
|
247
|
-
traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
|
248
|
-
traces[1]['Collection'].must_equal "users"
|
249
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
250
|
-
validate_event_keys(traces[2], @exit_kvs)
|
251
|
-
|
252
|
-
validate_event_keys(traces[3], @entry_kvs)
|
253
|
-
traces[3]['QueryOp'].must_equal "distinct"
|
254
|
-
traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
|
255
|
-
traces[3]['Key'].must_equal "city"
|
256
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
257
|
-
validate_event_keys(traces[4], @exit_kvs)
|
258
|
-
end
|
259
|
-
|
260
|
-
it 'should trace find and update' do
|
261
|
-
2.times { @users.insert(:name => "Mary") }
|
262
|
-
mary_count = @users.find(:name => "Mary").count
|
263
|
-
mary_count.wont_equal 0
|
264
|
-
|
265
|
-
tool_count = @users.find(:name => "Tool").count
|
266
|
-
tool_count.must_equal 0
|
267
|
-
|
268
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
269
|
-
old_attrs = { :name => "Mary" }
|
270
|
-
new_attrs = { :name => "Tool" }
|
271
|
-
@users.find(old_attrs).update({ '$set' => new_attrs }, { :multi => true })
|
272
|
-
end
|
273
|
-
|
274
|
-
new_tool_count = @users.find(:name => "Tool").count
|
275
|
-
new_tool_count.must_equal mary_count
|
276
|
-
|
277
|
-
new_mary_count = @users.find(:name => "Mary").count
|
278
|
-
new_mary_count.must_equal 0
|
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 AppOpticsAPM::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"
|
294
|
-
traces[3]['Update_Document'].must_equal "{\"$set\":{\"name\":\"Tool\"}}"
|
295
|
-
traces[3]['Flags'].must_equal "{:multi=>true}"
|
296
|
-
traces[3]['Collection'].must_equal "users"
|
297
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
298
|
-
validate_event_keys(traces[4], @exit_kvs)
|
299
|
-
end
|
300
|
-
|
301
|
-
it 'should trace find and update_all' do
|
302
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
303
|
-
@users.find(:name => "Mary").update_all({:name => "Tool"})
|
304
|
-
end
|
305
|
-
|
306
|
-
traces = get_all_traces
|
307
|
-
|
308
|
-
traces.count.must_equal 6
|
309
|
-
validate_outer_layers(traces, 'moped_test')
|
310
|
-
|
311
|
-
validate_event_keys(traces[1], @entry_kvs)
|
312
|
-
traces[1]['QueryOp'].must_equal "find"
|
313
|
-
traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
|
314
|
-
traces[1]['Collection'].must_equal "users"
|
315
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
316
|
-
validate_event_keys(traces[2], @exit_kvs)
|
317
|
-
|
318
|
-
validate_event_keys(traces[3], @entry_kvs)
|
319
|
-
traces[3]['QueryOp'].must_equal "update_all"
|
320
|
-
traces[3]['Update_Document'].must_equal "{\"name\":\"Tool\"}"
|
321
|
-
traces[3]['Collection'].must_equal "users"
|
322
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
323
|
-
validate_event_keys(traces[4], @exit_kvs)
|
324
|
-
end
|
325
|
-
|
326
|
-
it 'should trace find and upsert' do
|
327
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
328
|
-
@users.find(:name => "Tool").upsert({:name => "Mary"})
|
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\":\"Tool\"}"
|
339
|
-
traces[1]['Collection'].must_equal "users"
|
340
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::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 "upsert"
|
345
|
-
traces[3]['Query'].must_equal "{\"name\":\"Tool\"}"
|
346
|
-
traces[3]['Update_Document'].must_equal "{\"name\":\"Mary\"}"
|
347
|
-
traces[3]['Collection'].must_equal "users"
|
348
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
349
|
-
validate_event_keys(traces[4], @exit_kvs)
|
350
|
-
end
|
351
|
-
|
352
|
-
it 'should trace find and explain' do
|
353
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
354
|
-
@users.find(:name => "Mary").explain
|
355
|
-
end
|
356
|
-
|
357
|
-
traces = get_all_traces
|
358
|
-
|
359
|
-
traces.count.must_equal 6
|
360
|
-
validate_outer_layers(traces, 'moped_test')
|
361
|
-
|
362
|
-
validate_event_keys(traces[1], @entry_kvs)
|
363
|
-
traces[1]['QueryOp'].must_equal "find"
|
364
|
-
traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
|
365
|
-
traces[1]['Collection'].must_equal "users"
|
366
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
367
|
-
validate_event_keys(traces[2], @exit_kvs)
|
368
|
-
|
369
|
-
validate_event_keys(traces[3], @entry_kvs)
|
370
|
-
traces[3]['QueryOp'].must_equal "explain"
|
371
|
-
traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
|
372
|
-
traces[3]['Collection'].must_equal "users"
|
373
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
374
|
-
validate_event_keys(traces[4], @exit_kvs)
|
375
|
-
end
|
376
|
-
|
377
|
-
it 'should trace 3 types of find and modify calls' do
|
378
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
379
|
-
@users.find(:likes => 1).modify({ "$set" => { :name => "Tool" }}, :upsert => true)
|
380
|
-
@users.find.modify({ "$inc" => { :likes => 1 }}, :new => true)
|
381
|
-
@users.find.modify({:query => {}}, :remove => true)
|
382
|
-
end
|
383
|
-
|
384
|
-
traces = get_all_traces
|
385
|
-
|
386
|
-
traces.count.must_equal 14
|
387
|
-
validate_outer_layers(traces, 'moped_test')
|
388
|
-
|
389
|
-
validate_event_keys(traces[1], @entry_kvs)
|
390
|
-
traces[1]['QueryOp'].must_equal "find"
|
391
|
-
traces[1]['Query'].must_equal "{\"likes\":1}"
|
392
|
-
traces[1]['Collection'].must_equal "users"
|
393
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
394
|
-
validate_event_keys(traces[2], @exit_kvs)
|
395
|
-
|
396
|
-
validate_event_keys(traces[3], @entry_kvs)
|
397
|
-
traces[3]['QueryOp'].must_equal "modify"
|
398
|
-
traces[3]['Update_Document'].must_equal "{\"likes\":1}"
|
399
|
-
traces[3]['Collection'].must_equal "users"
|
400
|
-
traces[3]['Options'].must_equal "{\"upsert\":true}"
|
401
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
402
|
-
validate_event_keys(traces[4], @exit_kvs)
|
403
|
-
|
404
|
-
validate_event_keys(traces[7], @entry_kvs)
|
405
|
-
traces[7]['QueryOp'].must_equal "modify"
|
406
|
-
traces[7]['Update_Document'].must_equal "all"
|
407
|
-
traces[7]['Collection'].must_equal "users"
|
408
|
-
traces[7]['Options'].must_equal "{\"new\":true}"
|
409
|
-
traces[7]['Change'].must_equal "{\"$inc\":{\"likes\":1}}"
|
410
|
-
traces[7].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
411
|
-
validate_event_keys(traces[8], @exit_kvs)
|
412
|
-
|
413
|
-
validate_event_keys(traces[11], @entry_kvs)
|
414
|
-
traces[11]['Collection'].must_equal "users"
|
415
|
-
traces[11]['QueryOp'].must_equal "modify"
|
416
|
-
traces[11]['Update_Document'].must_equal "all"
|
417
|
-
traces[11]['Change'].must_equal "{\"query\":{}}"
|
418
|
-
traces[11]['Options'].must_equal "{\"remove\":true}"
|
419
|
-
traces[11].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
420
|
-
validate_event_keys(traces[12], @exit_kvs)
|
421
|
-
end
|
422
|
-
|
423
|
-
it 'should trace remove' do
|
424
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
425
|
-
@users.find(:name => "Tool").remove
|
426
|
-
end
|
427
|
-
|
428
|
-
traces = get_all_traces
|
429
|
-
|
430
|
-
traces.count.must_equal 6
|
431
|
-
validate_outer_layers(traces, 'moped_test')
|
432
|
-
|
433
|
-
validate_event_keys(traces[1], @entry_kvs)
|
434
|
-
traces[1]['QueryOp'].must_equal "find"
|
435
|
-
traces[1]['Query'].must_equal "{\"name\":\"Tool\"}"
|
436
|
-
traces[1]['Collection'].must_equal "users"
|
437
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
438
|
-
validate_event_keys(traces[2], @exit_kvs)
|
439
|
-
|
440
|
-
validate_event_keys(traces[3], @entry_kvs)
|
441
|
-
traces[3]['QueryOp'].must_equal "remove"
|
442
|
-
traces[3]['Query'].must_equal "{\"name\":\"Tool\"}"
|
443
|
-
traces[3]['Collection'].must_equal "users"
|
444
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
445
|
-
validate_event_keys(traces[4], @exit_kvs)
|
446
|
-
end
|
447
|
-
|
448
|
-
it 'should trace remove_all' do
|
449
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
450
|
-
@users.find(:name => "Mary").remove_all
|
451
|
-
end
|
452
|
-
|
453
|
-
traces = get_all_traces
|
454
|
-
|
455
|
-
traces.count.must_equal 6
|
456
|
-
validate_outer_layers(traces, 'moped_test')
|
457
|
-
|
458
|
-
validate_event_keys(traces[1], @entry_kvs)
|
459
|
-
traces[1]['QueryOp'].must_equal "find"
|
460
|
-
traces[1]['Query'].must_equal "{\"name\":\"Mary\"}"
|
461
|
-
traces[1]['Collection'].must_equal "users"
|
462
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
463
|
-
validate_event_keys(traces[2], @exit_kvs)
|
464
|
-
|
465
|
-
validate_event_keys(traces[3], @entry_kvs)
|
466
|
-
traces[3]['QueryOp'].must_equal "remove_all"
|
467
|
-
traces[3]['Query'].must_equal "{\"name\":\"Mary\"}"
|
468
|
-
traces[3]['Collection'].must_equal "users"
|
469
|
-
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
470
|
-
validate_event_keys(traces[4], @exit_kvs)
|
471
|
-
end
|
472
|
-
|
473
|
-
it 'should trace aggregate' do
|
474
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
475
|
-
@users.aggregate(
|
476
|
-
{'$match' => {:name => "Mary"}},
|
477
|
-
{'$group' => {"_id" => "$name"}}
|
478
|
-
)
|
479
|
-
end
|
480
|
-
|
481
|
-
traces = get_all_traces
|
482
|
-
|
483
|
-
traces.count.must_equal 4
|
484
|
-
validate_outer_layers(traces, 'moped_test')
|
485
|
-
|
486
|
-
validate_event_keys(traces[1], @entry_kvs)
|
487
|
-
traces[1]['QueryOp'].must_equal "aggregate"
|
488
|
-
traces[1]['Query'].must_equal "[{\"$match\"=>{:name=>\"Mary\"}}, {\"$group\"=>{\"_id\"=>\"$name\"}}]"
|
489
|
-
traces[1]['Collection'].must_equal "users"
|
490
|
-
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:moped][:collect_backtraces]
|
491
|
-
validate_event_keys(traces[2], @exit_kvs)
|
492
|
-
end
|
493
|
-
|
494
|
-
it "should obey :collect_backtraces setting when true" do
|
495
|
-
AppOpticsAPM::Config[:moped][:collect_backtraces] = true
|
496
|
-
|
497
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
498
|
-
@users.find(:name => "Mary").limit(1)
|
499
|
-
end
|
500
|
-
|
501
|
-
traces = get_all_traces
|
502
|
-
layer_has_key(traces, 'mongo', 'Backtrace')
|
503
|
-
end
|
504
|
-
|
505
|
-
it "should obey :collect_backtraces setting when false" do
|
506
|
-
AppOpticsAPM::Config[:moped][:collect_backtraces] = false
|
507
|
-
|
508
|
-
AppOpticsAPM::API.start_trace('moped_test', '', {}) do
|
509
|
-
@users.find(:name => "Mary").limit(1)
|
510
|
-
end
|
511
|
-
|
512
|
-
traces = get_all_traces
|
513
|
-
layer_doesnt_have_key(traces, 'mongo', 'Backtrace')
|
514
|
-
end
|
515
|
-
end
|
516
|
-
|
517
|
-
end
|