oboe 2.6.5.5 → 2.6.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/Gemfile +6 -5
- data/Gemfile.lock +40 -14
- data/README.md +38 -6
- data/Rakefile +4 -4
- data/lib/joboe_metal.rb +1 -1
- data/lib/oboe.rb +4 -3
- data/lib/oboe/frameworks/grape.rb +74 -0
- data/lib/oboe/frameworks/padrino/templates.rb +3 -1
- data/lib/oboe/inst/mongo.rb +23 -23
- data/lib/oboe/instrumentation.rb +1 -1
- data/lib/oboe/util.rb +54 -12
- data/lib/oboe/version.rb +3 -3
- data/lib/oboe_metal.rb +1 -1
- data/lib/rails/generators/oboe/install_generator.rb +3 -3
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +10 -10
- data/test/frameworks/apps/grape_simple.rb +12 -0
- data/test/frameworks/grape_test.rb +27 -0
- data/test/instrumentation/dalli_test.rb +36 -29
- data/test/instrumentation/memcache_test.rb +52 -52
- data/test/instrumentation/memcached_test.rb +49 -41
- data/test/instrumentation/mongo_test.rb +91 -45
- data/test/instrumentation/rack_test.rb +7 -6
- metadata +29 -24
@@ -4,9 +4,9 @@ if RUBY_VERSION < '2.0'
|
|
4
4
|
describe Oboe::Inst::Memcached do
|
5
5
|
require 'memcached'
|
6
6
|
require 'memcached/rails'
|
7
|
-
|
7
|
+
|
8
8
|
before do
|
9
|
-
clear_all_traces
|
9
|
+
clear_all_traces
|
10
10
|
@mc = ::Memcached::Rails.new(:servers => ['localhost'])
|
11
11
|
|
12
12
|
# These are standard entry/exit KVs that are passed up with all mongo operations
|
@@ -27,16 +27,16 @@ if RUBY_VERSION < '2.0'
|
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'Stock Memcached should be loaded, defined and ready' do
|
30
|
-
defined?(::Memcached).wont_match nil
|
31
|
-
defined?(::Memcached::Rails).wont_match nil
|
30
|
+
defined?(::Memcached).wont_match nil
|
31
|
+
defined?(::Memcached::Rails).wont_match nil
|
32
32
|
end
|
33
33
|
|
34
34
|
it 'Memcached should have oboe methods defined' do
|
35
35
|
Oboe::API::Memcache::MEMCACHE_OPS.each do |m|
|
36
36
|
if ::Memcached.method_defined?(m)
|
37
|
-
::Memcached.method_defined?("#{m}_with_oboe").must_equal true
|
37
|
+
::Memcached.method_defined?("#{m}_with_oboe").must_equal true
|
38
38
|
end
|
39
|
-
::Memcached::Rails.method_defined?(:get_multi_with_oboe).must_equal true
|
39
|
+
::Memcached::Rails.method_defined?(:get_multi_with_oboe).must_equal true
|
40
40
|
end
|
41
41
|
end
|
42
42
|
|
@@ -44,110 +44,118 @@ if RUBY_VERSION < '2.0'
|
|
44
44
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
45
45
|
@mc.set('testKey', 'blah')
|
46
46
|
end
|
47
|
-
|
47
|
+
|
48
48
|
traces = get_all_traces
|
49
49
|
traces.count.must_equal 4
|
50
|
-
|
50
|
+
|
51
51
|
validate_outer_layers(traces, 'memcached_test')
|
52
52
|
validate_event_keys(traces[1], @entry_kvs)
|
53
53
|
validate_event_keys(traces[2], @exit_kvs)
|
54
|
-
|
54
|
+
|
55
55
|
traces[1]['KVOp'].must_equal "set"
|
56
56
|
traces[1]['KVKey'].must_equal "testKey"
|
57
57
|
end
|
58
|
-
|
58
|
+
|
59
59
|
it "should trace get" do
|
60
|
+
@mc.set('testKey', 'blah')
|
61
|
+
|
60
62
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
61
|
-
@mc.get('
|
63
|
+
@mc.get('testKey')
|
62
64
|
end
|
63
|
-
|
65
|
+
|
64
66
|
traces = get_all_traces
|
65
67
|
traces.count.must_equal 4
|
66
|
-
|
68
|
+
|
67
69
|
validate_outer_layers(traces, 'memcached_test')
|
68
70
|
validate_event_keys(traces[1], @entry_kvs)
|
69
71
|
validate_event_keys(traces[2], @exit_kvs)
|
70
|
-
|
72
|
+
|
71
73
|
traces[1]['KVOp'].must_equal "get"
|
72
|
-
traces[1]['KVKey'].must_equal "
|
74
|
+
traces[1]['KVKey'].must_equal "testKey"
|
73
75
|
end
|
74
|
-
|
76
|
+
|
75
77
|
it "should trace get_multi" do
|
76
78
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
77
79
|
@mc.get_multi(['one', 'two', 'three', 'four', 'five', 'six'])
|
78
80
|
end
|
79
|
-
|
81
|
+
|
80
82
|
traces = get_all_traces
|
81
83
|
traces.count.must_equal 5
|
82
|
-
|
84
|
+
|
83
85
|
validate_outer_layers(traces, 'memcached_test')
|
84
86
|
validate_event_keys(traces[1], @entry_kvs)
|
85
87
|
validate_event_keys(traces[2], @info_kvs)
|
86
88
|
validate_event_keys(traces[3], @exit_kvs)
|
87
|
-
|
89
|
+
|
88
90
|
traces[1]['KVOp'].must_equal "get_multi"
|
89
|
-
|
91
|
+
|
90
92
|
traces[2]['KVKeyCount'].must_equal "6"
|
91
93
|
traces[2].has_key?('KVHitCount').must_equal true
|
92
94
|
end
|
93
|
-
|
95
|
+
|
94
96
|
it "should trace add for existing key" do
|
97
|
+
@mc.set('testKey', 'x', 1200)
|
98
|
+
|
95
99
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
96
100
|
@mc.add('testKey', 'x', 1200)
|
97
101
|
end
|
98
|
-
|
102
|
+
|
99
103
|
traces = get_all_traces
|
100
104
|
traces.count.must_equal 5
|
101
|
-
|
105
|
+
|
102
106
|
validate_outer_layers(traces, 'memcached_test')
|
103
107
|
validate_event_keys(traces[1], @entry_kvs)
|
104
108
|
validate_event_keys(traces[3], @exit_kvs)
|
105
109
|
|
106
110
|
traces[1]['KVOp'].must_equal "add"
|
107
111
|
traces[1]['KVKey'].must_equal "testKey"
|
108
|
-
|
112
|
+
|
109
113
|
traces[2]['ErrorClass'].must_equal "Memcached::NotStored"
|
110
114
|
traces[2]['Message'].must_equal "Memcached::NotStored"
|
111
115
|
end
|
112
|
-
|
116
|
+
|
113
117
|
it "should trace append" do
|
114
118
|
@mc.set('rawKey', "Peanut Butter ", 600, :raw => true)
|
115
119
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
116
120
|
@mc.append('rawKey', "Jelly")
|
117
121
|
end
|
118
|
-
|
122
|
+
|
119
123
|
traces = get_all_traces
|
120
124
|
traces.count.must_equal 4
|
121
|
-
|
125
|
+
|
122
126
|
validate_outer_layers(traces, 'memcached_test')
|
123
127
|
validate_event_keys(traces[1], @entry_kvs)
|
124
128
|
validate_event_keys(traces[2], @exit_kvs)
|
125
|
-
|
129
|
+
|
126
130
|
traces[1]['KVOp'].must_equal "append"
|
127
131
|
traces[1]['KVKey'].must_equal "rawKey"
|
128
132
|
end
|
129
|
-
|
133
|
+
|
130
134
|
it "should trace decr" do
|
135
|
+
@mc.set('some_key_counter', "100", 0, false)
|
136
|
+
|
131
137
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
132
138
|
@mc.decr('some_key_counter', 1)
|
133
139
|
end
|
134
|
-
|
140
|
+
|
135
141
|
traces = get_all_traces
|
136
142
|
traces.count.must_equal 4
|
137
|
-
|
143
|
+
|
138
144
|
validate_outer_layers(traces, 'memcached_test')
|
139
145
|
validate_event_keys(traces[1], @entry_kvs)
|
140
146
|
validate_event_keys(traces[2], @exit_kvs)
|
141
|
-
|
147
|
+
|
142
148
|
traces[1]['KVOp'].must_equal "decr"
|
143
149
|
traces[1]['KVKey'].must_equal "some_key_counter"
|
144
150
|
end
|
145
|
-
|
151
|
+
|
146
152
|
it "should trace increment" do
|
153
|
+
@mc.set('some_key_counter', "100", 0, false)
|
154
|
+
|
147
155
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
148
156
|
@mc.incr("some_key_counter", 1)
|
149
157
|
end
|
150
|
-
|
158
|
+
|
151
159
|
traces = get_all_traces
|
152
160
|
traces.count.must_equal 4
|
153
161
|
|
@@ -158,20 +166,20 @@ if RUBY_VERSION < '2.0'
|
|
158
166
|
traces[1]['KVOp'].must_equal "incr"
|
159
167
|
traces[1]['KVKey'].must_equal "some_key_counter"
|
160
168
|
end
|
161
|
-
|
169
|
+
|
162
170
|
it "should trace replace" do
|
163
171
|
@mc.set('some_key', 'blah')
|
164
172
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
165
173
|
@mc.replace("some_key", "woop")
|
166
174
|
end
|
167
|
-
|
175
|
+
|
168
176
|
traces = get_all_traces
|
169
177
|
traces.count.must_equal 4
|
170
|
-
|
178
|
+
|
171
179
|
validate_outer_layers(traces, 'memcached_test')
|
172
180
|
validate_event_keys(traces[1], @entry_kvs)
|
173
181
|
validate_event_keys(traces[2], @exit_kvs)
|
174
|
-
|
182
|
+
|
175
183
|
traces[1]['KVOp'].must_equal "replace"
|
176
184
|
traces[1]['KVKey'].must_equal "some_key"
|
177
185
|
end
|
@@ -181,10 +189,10 @@ if RUBY_VERSION < '2.0'
|
|
181
189
|
Oboe::API.start_trace('memcached_test', '', {}) do
|
182
190
|
@mc.delete("some_key")
|
183
191
|
end
|
184
|
-
|
192
|
+
|
185
193
|
traces = get_all_traces
|
186
194
|
traces.count.must_equal 4
|
187
|
-
|
195
|
+
|
188
196
|
validate_outer_layers(traces, 'memcached_test')
|
189
197
|
validate_event_keys(traces[1], @entry_kvs)
|
190
198
|
validate_event_keys(traces[2], @exit_kvs)
|
@@ -192,7 +200,7 @@ if RUBY_VERSION < '2.0'
|
|
192
200
|
traces[1]['KVOp'].must_equal "delete"
|
193
201
|
traces[1]['KVKey'].must_equal "some_key"
|
194
202
|
end
|
195
|
-
|
203
|
+
|
196
204
|
it "should obey :collect_backtraces setting when true" do
|
197
205
|
Oboe::Config[:memcached][:collect_backtraces] = true
|
198
206
|
|
@@ -2,7 +2,7 @@ require 'minitest_helper'
|
|
2
2
|
|
3
3
|
describe Oboe::Inst::Mongo do
|
4
4
|
before do
|
5
|
-
clear_all_traces
|
5
|
+
clear_all_traces
|
6
6
|
@connection = Mongo::Connection.new("localhost", 27017, :slave_ok => true)
|
7
7
|
@db = @connection.db("test-#{ENV['RACK_ENV']}")
|
8
8
|
|
@@ -21,13 +21,13 @@ describe Oboe::Inst::Mongo do
|
|
21
21
|
@exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
|
22
22
|
@collect_backtraces = Oboe::Config[:mongo][:collect_backtraces]
|
23
23
|
end
|
24
|
-
|
24
|
+
|
25
25
|
after do
|
26
26
|
Oboe::Config[:mongo][:collect_backtraces] = @collect_backtraces
|
27
27
|
end
|
28
28
|
|
29
29
|
it 'Stock Mongo should be loaded, defined and ready' do
|
30
|
-
defined?(::Mongo).wont_match nil
|
30
|
+
defined?(::Mongo).wont_match nil
|
31
31
|
defined?(::Mongo::DB).wont_match nil
|
32
32
|
defined?(::Mongo::Cursor).wont_match nil
|
33
33
|
defined?(::Mongo::Collection).wont_match nil
|
@@ -56,7 +56,7 @@ describe Oboe::Inst::Mongo do
|
|
56
56
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
57
57
|
@db.create_collection("create_and_drop_collection_test")
|
58
58
|
end
|
59
|
-
|
59
|
+
|
60
60
|
traces = get_all_traces
|
61
61
|
traces.count.must_equal 4
|
62
62
|
|
@@ -72,11 +72,11 @@ describe Oboe::Inst::Mongo do
|
|
72
72
|
it "should trace drop_collection" do
|
73
73
|
# Create a collection so we have one to drop
|
74
74
|
@db.create_collection("create_and_drop_collection_test")
|
75
|
-
|
75
|
+
|
76
76
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
77
77
|
@db.drop_collection("create_and_drop_collection_test")
|
78
78
|
end
|
79
|
-
|
79
|
+
|
80
80
|
traces = get_all_traces
|
81
81
|
traces.count.must_equal 4
|
82
82
|
|
@@ -95,7 +95,7 @@ describe Oboe::Inst::Mongo do
|
|
95
95
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
96
96
|
coll.count(:query => {:name => "MyName"})
|
97
97
|
end
|
98
|
-
|
98
|
+
|
99
99
|
traces = get_all_traces
|
100
100
|
traces.count.must_equal 6
|
101
101
|
|
@@ -105,14 +105,14 @@ describe Oboe::Inst::Mongo do
|
|
105
105
|
|
106
106
|
traces[3]['QueryOp'].must_equal "count"
|
107
107
|
end
|
108
|
-
|
108
|
+
|
109
109
|
it "should trace find_and_modify" do
|
110
110
|
coll = @db.collection("testCollection")
|
111
111
|
|
112
112
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
113
113
|
coll.find_and_modify({ :query => { :name => "MyName" }, :update => { :count => 203 }})
|
114
114
|
end
|
115
|
-
|
115
|
+
|
116
116
|
traces = get_all_traces
|
117
117
|
traces.count.must_equal 4
|
118
118
|
|
@@ -125,7 +125,7 @@ describe Oboe::Inst::Mongo do
|
|
125
125
|
traces[1]['QueryOp'].must_equal "find_and_modify"
|
126
126
|
traces[1]['Update_Document'].must_equal "{:count=>203}"
|
127
127
|
end
|
128
|
-
|
128
|
+
|
129
129
|
it "should trace insert" do
|
130
130
|
coll = @db.collection("testCollection")
|
131
131
|
|
@@ -133,21 +133,21 @@ describe Oboe::Inst::Mongo do
|
|
133
133
|
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
134
134
|
id = coll.insert(doc)
|
135
135
|
end
|
136
|
-
|
136
|
+
|
137
137
|
traces = get_all_traces
|
138
138
|
traces.count.must_equal 4
|
139
139
|
|
140
140
|
validate_outer_layers(traces, 'mongo_test')
|
141
141
|
validate_event_keys(traces[1], @entry_kvs)
|
142
142
|
validate_event_keys(traces[2], @exit_kvs)
|
143
|
-
|
143
|
+
|
144
144
|
traces[1]['Collection'].must_equal "testCollection"
|
145
145
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
146
146
|
traces[1]['QueryOp'].must_equal "insert"
|
147
147
|
# Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+
|
148
148
|
traces[1].has_key?('Query').must_equal true
|
149
149
|
end
|
150
|
-
|
150
|
+
|
151
151
|
it "should trace map_reduce" do
|
152
152
|
coll = @db.collection("testCollection")
|
153
153
|
|
@@ -156,14 +156,14 @@ describe Oboe::Inst::Mongo do
|
|
156
156
|
reduce = "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
157
157
|
coll.map_reduce(map, reduce, { :out => "mr_results", :limit => 100, :read => :primary })
|
158
158
|
end
|
159
|
-
|
159
|
+
|
160
160
|
traces = get_all_traces
|
161
161
|
traces.count.must_equal 4
|
162
162
|
|
163
163
|
validate_outer_layers(traces, 'mongo_test')
|
164
164
|
validate_event_keys(traces[1], @entry_kvs)
|
165
165
|
validate_event_keys(traces[2], @exit_kvs)
|
166
|
-
|
166
|
+
|
167
167
|
traces[1]['Collection'].must_equal "testCollection"
|
168
168
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
169
169
|
traces[1]['QueryOp'].must_equal "map_reduce"
|
@@ -171,14 +171,14 @@ describe Oboe::Inst::Mongo do
|
|
171
171
|
traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
172
172
|
traces[1]['Limit'].must_equal "100"
|
173
173
|
end
|
174
|
-
|
174
|
+
|
175
175
|
it "should trace remove" do
|
176
176
|
coll = @db.collection("testCollection")
|
177
177
|
|
178
178
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
179
179
|
coll.remove(:name => "SaveOp")
|
180
180
|
end
|
181
|
-
|
181
|
+
|
182
182
|
traces = get_all_traces
|
183
183
|
traces.count.must_equal 4
|
184
184
|
|
@@ -191,7 +191,7 @@ describe Oboe::Inst::Mongo do
|
|
191
191
|
traces[1]['QueryOp'].must_equal "remove"
|
192
192
|
traces[1]['Query'].must_equal "{\"name\":\"SaveOp\"}"
|
193
193
|
end
|
194
|
-
|
194
|
+
|
195
195
|
it "should trace rename" do
|
196
196
|
coll = @db.collection("testCollection")
|
197
197
|
new_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
@@ -199,19 +199,19 @@ describe Oboe::Inst::Mongo do
|
|
199
199
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
200
200
|
coll.rename(new_name)
|
201
201
|
end
|
202
|
-
|
202
|
+
|
203
203
|
traces = get_all_traces
|
204
204
|
traces.count.must_equal 4
|
205
205
|
|
206
206
|
validate_outer_layers(traces, 'mongo_test')
|
207
207
|
validate_event_keys(traces[1], @entry_kvs)
|
208
208
|
validate_event_keys(traces[2], @exit_kvs)
|
209
|
-
|
209
|
+
|
210
210
|
traces[1]['Collection'].must_equal "testCollection"
|
211
211
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
212
212
|
traces[1]['QueryOp'].must_equal "rename"
|
213
213
|
traces[1]['New_Collection_Name'].must_equal new_name
|
214
|
-
|
214
|
+
|
215
215
|
# Clean up after test and set collection name back to original
|
216
216
|
coll.rename("testCollection")
|
217
217
|
end
|
@@ -222,23 +222,23 @@ describe Oboe::Inst::Mongo do
|
|
222
222
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
223
223
|
# Two types of update calls
|
224
224
|
coll.update({"_id" => 1}, { "$set" => {"name" => "MongoDB Ruby"}}, :multi => true)
|
225
|
-
|
225
|
+
|
226
226
|
doc = {"name" => "MyOtherName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
227
227
|
coll.update({"_id" => 1}, doc)
|
228
228
|
end
|
229
|
-
|
229
|
+
|
230
230
|
traces = get_all_traces
|
231
231
|
traces.count.must_equal 6
|
232
232
|
|
233
233
|
validate_outer_layers(traces, 'mongo_test')
|
234
234
|
validate_event_keys(traces[1], @entry_kvs)
|
235
235
|
validate_event_keys(traces[2], @exit_kvs)
|
236
|
-
|
236
|
+
|
237
237
|
traces[1]['Collection'].must_equal "testCollection"
|
238
238
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
239
239
|
traces[1]['QueryOp'].must_equal "update"
|
240
240
|
traces[1]['Query'].must_equal "{\"_id\":1}"
|
241
|
-
|
241
|
+
|
242
242
|
validate_event_keys(traces[3], @entry_kvs)
|
243
243
|
validate_event_keys(traces[4], @exit_kvs)
|
244
244
|
|
@@ -246,33 +246,44 @@ describe Oboe::Inst::Mongo do
|
|
246
246
|
traces[3]['QueryOp'].must_equal "update"
|
247
247
|
traces[3]['Query'].must_equal "{\"_id\":1}"
|
248
248
|
end
|
249
|
-
|
249
|
+
|
250
250
|
it "should trace distinct" do
|
251
251
|
coll = @db.collection("testCollection")
|
252
252
|
|
253
253
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
254
254
|
coll.distinct("count")
|
255
255
|
end
|
256
|
-
|
256
|
+
|
257
257
|
traces = get_all_traces
|
258
258
|
traces.count.must_equal 4
|
259
259
|
|
260
260
|
validate_outer_layers(traces, 'mongo_test')
|
261
261
|
validate_event_keys(traces[1], @entry_kvs)
|
262
262
|
validate_event_keys(traces[2], @exit_kvs)
|
263
|
-
|
263
|
+
|
264
264
|
traces[1]['Collection'].must_equal "testCollection"
|
265
265
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
266
266
|
traces[1]['QueryOp'].must_equal "distinct"
|
267
267
|
end
|
268
|
-
|
268
|
+
|
269
269
|
it "should trace find" do
|
270
270
|
coll = @db.collection("testCollection")
|
271
|
+
result = nil
|
272
|
+
|
273
|
+
# Insert a doc to assure we get a result
|
274
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
275
|
+
id = coll.insert(doc)
|
276
|
+
|
277
|
+
# If given an optional block +find+ will yield a Cursor to that block,
|
278
|
+
# close the cursor, and then return nil. This guarantees that partially
|
279
|
+
# evaluated cursors will be closed. If given no block +find+ returns a
|
280
|
+
# cursor.
|
281
|
+
# https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
|
271
282
|
|
272
283
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
273
|
-
coll.find(:name => "MyName", :limit => 1)
|
284
|
+
result = coll.find(:name => "MyName", :limit => 1)
|
274
285
|
end
|
275
|
-
|
286
|
+
|
276
287
|
traces = get_all_traces
|
277
288
|
traces.count.must_equal 4
|
278
289
|
|
@@ -280,13 +291,48 @@ describe Oboe::Inst::Mongo do
|
|
280
291
|
validate_event_keys(traces[1], @entry_kvs)
|
281
292
|
validate_event_keys(traces[2], @exit_kvs)
|
282
293
|
|
294
|
+
result.wont_match nil
|
295
|
+
result.is_a?(Mongo::Cursor).must_equal true
|
283
296
|
traces[1]['Collection'].must_equal "testCollection"
|
284
297
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
285
298
|
traces[1]['QueryOp'].must_equal "find"
|
286
299
|
traces[1].has_key?('Query').must_equal true
|
287
300
|
traces[1]['Limit'].must_equal "1"
|
288
301
|
end
|
289
|
-
|
302
|
+
|
303
|
+
it "should trace find (with block)" do
|
304
|
+
coll = @db.collection("testCollection")
|
305
|
+
result = []
|
306
|
+
|
307
|
+
# Insert a doc to assure we get a result
|
308
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
309
|
+
id = coll.insert(doc)
|
310
|
+
|
311
|
+
# If given an optional block +find+ will yield a Cursor to that block,
|
312
|
+
# close the cursor, and then return nil. This guarantees that partially
|
313
|
+
# evaluated cursors will be closed. If given no block +find+ returns a
|
314
|
+
# cursor.
|
315
|
+
# https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
|
316
|
+
|
317
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
318
|
+
blk = lambda { |x| x }
|
319
|
+
result = coll.find(:name => "MyName", :limit => 10, &blk)
|
320
|
+
end
|
321
|
+
|
322
|
+
traces = get_all_traces
|
323
|
+
traces.count.must_equal 4
|
324
|
+
|
325
|
+
validate_outer_layers(traces, 'mongo_test')
|
326
|
+
validate_event_keys(traces[1], @entry_kvs)
|
327
|
+
validate_event_keys(traces[2], @exit_kvs)
|
328
|
+
|
329
|
+
result.must_equal nil
|
330
|
+
traces[1]['Collection'].must_equal "testCollection"
|
331
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
332
|
+
traces[1]['QueryOp'].must_equal "find"
|
333
|
+
traces[1].has_key?('Query').must_equal true
|
334
|
+
end
|
335
|
+
|
290
336
|
it "should trace group" do
|
291
337
|
coll = @db.collection("testCollection")
|
292
338
|
|
@@ -296,14 +342,14 @@ describe Oboe::Inst::Mongo do
|
|
296
342
|
:initial => { :count => 0 },
|
297
343
|
:reduce => 'function(obj,prev) { prev.count += obj.c; }')
|
298
344
|
end
|
299
|
-
|
345
|
+
|
300
346
|
traces = get_all_traces
|
301
347
|
traces.count.must_equal 4
|
302
348
|
|
303
349
|
validate_outer_layers(traces, 'mongo_test')
|
304
350
|
validate_event_keys(traces[1], @entry_kvs)
|
305
351
|
validate_event_keys(traces[2], @exit_kvs)
|
306
|
-
|
352
|
+
|
307
353
|
traces[1]['Collection'].must_equal "testCollection"
|
308
354
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
309
355
|
traces[1]['QueryOp'].must_equal "group"
|
@@ -319,14 +365,14 @@ describe Oboe::Inst::Mongo do
|
|
319
365
|
coll.ensure_index("i")
|
320
366
|
coll.drop_index("i_1")
|
321
367
|
end
|
322
|
-
|
368
|
+
|
323
369
|
traces = get_all_traces
|
324
370
|
traces.count.must_equal 8
|
325
371
|
|
326
372
|
validate_outer_layers(traces, 'mongo_test')
|
327
373
|
validate_event_keys(traces[1], @entry_kvs)
|
328
374
|
validate_event_keys(traces[2], @exit_kvs)
|
329
|
-
|
375
|
+
|
330
376
|
traces[1]['Collection'].must_equal "testCollection"
|
331
377
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
332
378
|
traces[1]['QueryOp'].must_equal "create_index"
|
@@ -345,48 +391,48 @@ describe Oboe::Inst::Mongo do
|
|
345
391
|
traces[5].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
346
392
|
traces[5]['QueryOp'].must_equal "drop_index"
|
347
393
|
end
|
348
|
-
|
394
|
+
|
349
395
|
it "should trace drop_indexes" do
|
350
396
|
coll = @db.collection("testCollection")
|
351
397
|
|
352
398
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
353
399
|
coll.drop_indexes
|
354
400
|
end
|
355
|
-
|
401
|
+
|
356
402
|
traces = get_all_traces
|
357
403
|
traces.count.must_equal 4
|
358
404
|
|
359
405
|
validate_outer_layers(traces, 'mongo_test')
|
360
406
|
validate_event_keys(traces[1], @entry_kvs)
|
361
407
|
validate_event_keys(traces[2], @exit_kvs)
|
362
|
-
|
408
|
+
|
363
409
|
traces[1]['Collection'].must_equal "testCollection"
|
364
410
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
365
411
|
traces[1]['QueryOp'].must_equal "drop_indexes"
|
366
412
|
end
|
367
|
-
|
413
|
+
|
368
414
|
it "should trace index_information" do
|
369
415
|
coll = @db.collection("testCollection")
|
370
416
|
|
371
417
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
372
418
|
coll.index_information
|
373
419
|
end
|
374
|
-
|
420
|
+
|
375
421
|
traces = get_all_traces
|
376
422
|
traces.count.must_equal 4
|
377
423
|
|
378
424
|
validate_outer_layers(traces, 'mongo_test')
|
379
425
|
validate_event_keys(traces[1], @entry_kvs)
|
380
426
|
validate_event_keys(traces[2], @exit_kvs)
|
381
|
-
|
427
|
+
|
382
428
|
traces[1]['Collection'].must_equal "testCollection"
|
383
429
|
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
384
430
|
traces[1]['QueryOp'].must_equal "index_information"
|
385
431
|
end
|
386
|
-
|
432
|
+
|
387
433
|
it "should obey :collect_backtraces setting when true" do
|
388
434
|
Oboe::Config[:mongo][:collect_backtraces] = true
|
389
|
-
|
435
|
+
|
390
436
|
coll = @db.collection("testCollection")
|
391
437
|
|
392
438
|
Oboe::API.start_trace('mongo_test', '', {}) do
|
@@ -400,7 +446,7 @@ describe Oboe::Inst::Mongo do
|
|
400
446
|
|
401
447
|
it "should obey :collect_backtraces setting when false" do
|
402
448
|
Oboe::Config[:mongo][:collect_backtraces] = false
|
403
|
-
|
449
|
+
|
404
450
|
coll = @db.collection("testCollection")
|
405
451
|
|
406
452
|
Oboe::API.start_trace('mongo_test', '', {}) do
|