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