oboe 2.3.2 → 2.3.3.7

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