oboe 2.6.6.1 → 2.6.7.1
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +6 -0
- data/Appraisals +6 -16
- data/CHANGELOG.md +30 -14
- data/Gemfile +4 -3
- data/Gemfile.lock +20 -25
- data/Rakefile +5 -1
- data/ext/oboe_metal/extconf.rb +2 -2
- data/gemfiles/mongo.gemfile +33 -0
- data/gemfiles/moped.gemfile +33 -0
- data/lib/base.rb +28 -10
- data/lib/joboe_metal.rb +12 -34
- data/lib/method_profiling.rb +3 -3
- data/lib/oboe/api/layerinit.rb +14 -14
- data/lib/oboe/api/logging.rb +11 -11
- data/lib/oboe/api/profiling.rb +7 -6
- data/lib/oboe/api/tracing.rb +3 -3
- data/lib/oboe/api/util.rb +4 -4
- data/lib/oboe/config.rb +7 -7
- data/lib/oboe/frameworks/padrino.rb +2 -2
- data/lib/oboe/frameworks/rails.rb +11 -11
- data/lib/oboe/frameworks/rails/inst/action_controller.rb +4 -4
- data/lib/oboe/frameworks/rails/inst/action_view.rb +2 -2
- data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/action_view_30.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/active_record.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +3 -3
- data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +2 -2
- data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +1 -1
- data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +8 -8
- data/lib/oboe/frameworks/sinatra.rb +33 -3
- data/lib/oboe/frameworks/sinatra/templates.rb +2 -2
- data/lib/oboe/inst/cassandra.rb +19 -19
- data/lib/oboe/inst/dalli.rb +7 -7
- data/lib/oboe/inst/http.rb +5 -5
- data/lib/oboe/inst/memcache.rb +14 -14
- data/lib/oboe/inst/memcached.rb +8 -8
- data/lib/oboe/inst/mongo.rb +2 -2
- data/lib/oboe/inst/moped.rb +29 -29
- data/lib/oboe/inst/rack.rb +3 -3
- data/lib/oboe/inst/redis.rb +24 -24
- data/lib/oboe/inst/resque.rb +4 -4
- data/lib/oboe/loading.rb +6 -6
- data/lib/oboe/logger.rb +4 -4
- data/lib/oboe/version.rb +1 -1
- data/lib/oboe_metal.rb +11 -39
- data/test/frameworks/apps/grape_simple.rb +1 -1
- data/test/frameworks/apps/sinatra_simple.rb +1 -1
- data/test/frameworks/padrino_test.rb +3 -3
- data/test/frameworks/sinatra_test.rb +3 -3
- data/test/instrumentation/cassandra_test.rb +45 -45
- data/test/instrumentation/http_test.rb +6 -6
- data/test/instrumentation/mongo_test.rb +347 -345
- data/test/instrumentation/moped_test.rb +40 -40
- data/test/instrumentation/redis_hashes_test.rb +20 -20
- data/test/instrumentation/redis_keys_test.rb +19 -19
- data/test/instrumentation/redis_lists_test.rb +22 -22
- data/test/instrumentation/redis_misc_test.rb +14 -14
- data/test/instrumentation/redis_sets_test.rb +20 -20
- data/test/instrumentation/redis_sortedsets_test.rb +25 -25
- data/test/instrumentation/redis_strings_test.rb +27 -27
- data/test/instrumentation/resque_test.rb +7 -7
- data/test/minitest_helper.rb +18 -6
- data/test/profiling/method_test.rb +24 -24
- data/test/support/liboboe_settings_test.rb +3 -3
- data/test/support/xtrace_test.rb +2 -2
- metadata +26 -32
- data/gemfiles/rails2.3.gemfile +0 -18
- data/gemfiles/rails2.3.gemfile.lock +0 -95
- data/gemfiles/rails3.0.gemfile +0 -18
- data/gemfiles/rails3.0.gemfile.lock +0 -142
- data/gemfiles/rails3.1.gemfile +0 -18
- data/gemfiles/rails3.1.gemfile.lock +0 -152
- data/gemfiles/rails3.2.gemfile +0 -18
- data/gemfiles/rails3.2.gemfile.lock +0 -150
@@ -3,7 +3,7 @@ require 'net/http'
|
|
3
3
|
|
4
4
|
describe Oboe::Inst do
|
5
5
|
before do
|
6
|
-
clear_all_traces
|
6
|
+
clear_all_traces
|
7
7
|
@collect_backtraces = Oboe::Config[:nethttp][:collect_backtraces]
|
8
8
|
end
|
9
9
|
|
@@ -12,7 +12,7 @@ describe Oboe::Inst do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
it 'Net::HTTP should be defined and ready' do
|
15
|
-
defined?(::Net::HTTP).wont_match nil
|
15
|
+
defined?(::Net::HTTP).wont_match nil
|
16
16
|
end
|
17
17
|
|
18
18
|
it 'Net::HTTP should have oboe methods defined' do
|
@@ -31,7 +31,7 @@ describe Oboe::Inst do
|
|
31
31
|
|
32
32
|
traces = get_all_traces
|
33
33
|
traces.count.must_equal 5
|
34
|
-
|
34
|
+
|
35
35
|
validate_outer_layers(traces, 'net-http_test')
|
36
36
|
|
37
37
|
traces[1]['Layer'].must_equal 'net-http'
|
@@ -43,7 +43,7 @@ describe Oboe::Inst do
|
|
43
43
|
traces[2]['HTTPStatus'].must_equal "200"
|
44
44
|
traces[2].has_key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
it "should trace a Net::HTTP request" do
|
48
48
|
Oboe::API.start_trace('net-http_test', '', {}) do
|
49
49
|
uri = URI('https://www.google.com')
|
@@ -54,7 +54,7 @@ describe Oboe::Inst do
|
|
54
54
|
|
55
55
|
traces = get_all_traces
|
56
56
|
traces.count.must_equal 5
|
57
|
-
|
57
|
+
|
58
58
|
validate_outer_layers(traces, 'net-http_test')
|
59
59
|
|
60
60
|
traces[1]['Layer'].must_equal 'net-http'
|
@@ -66,7 +66,7 @@ describe Oboe::Inst do
|
|
66
66
|
traces[2]['HTTPStatus'].must_equal "200"
|
67
67
|
traces[2].has_key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
|
68
68
|
end
|
69
|
-
|
69
|
+
|
70
70
|
it "should obey :collect_backtraces setting when true" do
|
71
71
|
Oboe::Config[:nethttp][:collect_backtraces] = true
|
72
72
|
|
@@ -1,460 +1,462 @@
|
|
1
1
|
require 'minitest_helper'
|
2
2
|
|
3
|
-
|
4
|
-
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
|
9
|
-
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
after do
|
26
|
-
Oboe::Config[:mongo][:collect_backtraces] = @collect_backtraces
|
27
|
-
end
|
28
|
-
|
29
|
-
it 'Stock Mongo should be loaded, defined and ready' do
|
30
|
-
defined?(::Mongo).wont_match nil
|
31
|
-
defined?(::Mongo::DB).wont_match nil
|
32
|
-
defined?(::Mongo::Cursor).wont_match nil
|
33
|
-
defined?(::Mongo::Collection).wont_match nil
|
34
|
-
end
|
35
|
-
|
36
|
-
it 'Mongo should have oboe methods defined' do
|
37
|
-
Oboe::Inst::Mongo::DB_OPS.each do |m|
|
38
|
-
::Mongo::DB.method_defined?("#{m}_with_oboe").must_equal true
|
39
|
-
end
|
40
|
-
Oboe::Inst::Mongo::CURSOR_OPS.each do |m|
|
41
|
-
::Mongo::Cursor.method_defined?("#{m}_with_oboe").must_equal true
|
3
|
+
if defined?(::BSON::VERSION) and (BSON::VERSION < "2.0")
|
4
|
+
describe Oboe::Inst::Mongo do
|
5
|
+
before do
|
6
|
+
clear_all_traces
|
7
|
+
@connection = Mongo::Connection.new("localhost", 27017, :slave_ok => true)
|
8
|
+
@db = @connection.db("test-#{ENV['RACK_ENV']}")
|
9
|
+
|
10
|
+
@collections = @db.collection_names
|
11
|
+
@db.create_collection("testCollection") unless @collections.include? "testCollection"
|
12
|
+
|
13
|
+
# These are standard entry/exit KVs that are passed up with all mongo operations
|
14
|
+
@entry_kvs = {
|
15
|
+
'Layer' => 'mongo',
|
16
|
+
'Label' => 'entry',
|
17
|
+
'Flavor' => 'mongodb',
|
18
|
+
'Database' => 'test-test',
|
19
|
+
'RemoteHost' => 'localhost',
|
20
|
+
'RemotePort' => '27017' }
|
21
|
+
|
22
|
+
@exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
|
23
|
+
@collect_backtraces = Oboe::Config[:mongo][:collect_backtraces]
|
42
24
|
end
|
43
|
-
|
44
|
-
|
45
|
-
|
46
|
-
Oboe::Inst::Mongo::COLL_QUERY_OPS.each do |m|
|
47
|
-
::Mongo::Collection.method_defined?("#{m}_with_oboe").must_equal true
|
48
|
-
end
|
49
|
-
Oboe::Inst::Mongo::COLL_INDEX_OPS.each do |m|
|
50
|
-
::Mongo::Collection.method_defined?("#{m}_with_oboe").must_equal true
|
25
|
+
|
26
|
+
after do
|
27
|
+
Oboe::Config[:mongo][:collect_backtraces] = @collect_backtraces
|
51
28
|
end
|
52
|
-
::Mongo::Collection.method_defined?(:oboe_collect).must_equal true
|
53
|
-
end
|
54
29
|
|
55
|
-
|
56
|
-
|
57
|
-
|
30
|
+
it 'Stock Mongo should be loaded, defined and ready' do
|
31
|
+
defined?(::Mongo).wont_match nil
|
32
|
+
defined?(::Mongo::DB).wont_match nil
|
33
|
+
defined?(::Mongo::Cursor).wont_match nil
|
34
|
+
defined?(::Mongo::Collection).wont_match nil
|
58
35
|
end
|
59
36
|
|
60
|
-
|
61
|
-
|
37
|
+
it 'Mongo should have oboe methods defined' do
|
38
|
+
Oboe::Inst::Mongo::DB_OPS.each do |m|
|
39
|
+
::Mongo::DB.method_defined?("#{m}_with_oboe").must_equal true
|
40
|
+
end
|
41
|
+
Oboe::Inst::Mongo::CURSOR_OPS.each do |m|
|
42
|
+
::Mongo::Cursor.method_defined?("#{m}_with_oboe").must_equal true
|
43
|
+
end
|
44
|
+
Oboe::Inst::Mongo::COLL_WRITE_OPS.each do |m|
|
45
|
+
::Mongo::Collection.method_defined?("#{m}_with_oboe").must_equal true
|
46
|
+
end
|
47
|
+
Oboe::Inst::Mongo::COLL_QUERY_OPS.each do |m|
|
48
|
+
::Mongo::Collection.method_defined?("#{m}_with_oboe").must_equal true
|
49
|
+
end
|
50
|
+
Oboe::Inst::Mongo::COLL_INDEX_OPS.each do |m|
|
51
|
+
::Mongo::Collection.method_defined?("#{m}_with_oboe").must_equal true
|
52
|
+
end
|
53
|
+
::Mongo::Collection.method_defined?(:oboe_collect).must_equal true
|
54
|
+
end
|
62
55
|
|
63
|
-
|
64
|
-
|
65
|
-
|
56
|
+
it "should trace create_collection" do
|
57
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
58
|
+
@db.create_collection("create_and_drop_collection_test")
|
59
|
+
end
|
66
60
|
|
67
|
-
|
68
|
-
|
69
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
70
|
-
end
|
61
|
+
traces = get_all_traces
|
62
|
+
traces.count.must_equal 4
|
71
63
|
|
72
|
-
|
73
|
-
|
74
|
-
|
64
|
+
validate_outer_layers(traces, 'mongo_test')
|
65
|
+
validate_event_keys(traces[1], @entry_kvs)
|
66
|
+
validate_event_keys(traces[2], @exit_kvs)
|
75
67
|
|
76
|
-
|
77
|
-
|
68
|
+
traces[1]['QueryOp'].must_equal "create_collection"
|
69
|
+
traces[1]['New_Collection_Name'].must_equal "create_and_drop_collection_test"
|
70
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
78
71
|
end
|
79
72
|
|
80
|
-
|
81
|
-
|
73
|
+
it "should trace drop_collection" do
|
74
|
+
# Create a collection so we have one to drop
|
75
|
+
@db.create_collection("create_and_drop_collection_test")
|
82
76
|
|
83
|
-
|
84
|
-
|
85
|
-
|
77
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
78
|
+
@db.drop_collection("create_and_drop_collection_test")
|
79
|
+
end
|
86
80
|
|
87
|
-
|
88
|
-
|
89
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
90
|
-
end
|
81
|
+
traces = get_all_traces
|
82
|
+
traces.count.must_equal 4
|
91
83
|
|
92
|
-
|
93
|
-
|
84
|
+
validate_outer_layers(traces, 'mongo_test')
|
85
|
+
validate_event_keys(traces[1], @entry_kvs)
|
86
|
+
validate_event_keys(traces[2], @exit_kvs)
|
94
87
|
|
95
|
-
|
96
|
-
|
88
|
+
traces[1]['QueryOp'].must_equal "drop_collection"
|
89
|
+
traces[1]['Collection'].must_equal "create_and_drop_collection_test"
|
90
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
97
91
|
end
|
98
92
|
|
99
|
-
|
100
|
-
|
93
|
+
it "should trace count" do
|
94
|
+
coll = @db.collection("testCollection")
|
101
95
|
|
102
|
-
|
103
|
-
|
104
|
-
|
96
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
97
|
+
coll.count(:query => {:name => "MyName"})
|
98
|
+
end
|
105
99
|
|
106
|
-
|
107
|
-
|
100
|
+
traces = get_all_traces
|
101
|
+
traces.count.must_equal 6
|
108
102
|
|
109
|
-
|
110
|
-
|
103
|
+
validate_outer_layers(traces, 'mongo_test')
|
104
|
+
validate_event_keys(traces[1], @entry_kvs)
|
105
|
+
validate_event_keys(traces[2], @exit_kvs)
|
111
106
|
|
112
|
-
|
113
|
-
coll.find_and_modify({ :query => { :name => "MyName" }, :update => { :count => 203 }})
|
107
|
+
traces[3]['QueryOp'].must_equal "count"
|
114
108
|
end
|
115
109
|
|
116
|
-
|
117
|
-
|
110
|
+
it "should trace find_and_modify" do
|
111
|
+
coll = @db.collection("testCollection")
|
118
112
|
|
119
|
-
|
120
|
-
|
121
|
-
|
113
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
114
|
+
coll.find_and_modify({ :query => { :name => "MyName" }, :update => { :count => 203 }})
|
115
|
+
end
|
122
116
|
|
123
|
-
|
124
|
-
|
125
|
-
traces[1]['QueryOp'].must_equal "find_and_modify"
|
126
|
-
traces[1]['Update_Document'].must_equal "{:count=>203}"
|
127
|
-
end
|
117
|
+
traces = get_all_traces
|
118
|
+
traces.count.must_equal 4
|
128
119
|
|
129
|
-
|
130
|
-
|
120
|
+
validate_outer_layers(traces, 'mongo_test')
|
121
|
+
validate_event_keys(traces[1], @entry_kvs)
|
122
|
+
validate_event_keys(traces[2], @exit_kvs)
|
131
123
|
|
132
|
-
|
133
|
-
|
134
|
-
|
124
|
+
traces[1]['Collection'].must_equal "testCollection"
|
125
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
126
|
+
traces[1]['QueryOp'].must_equal "find_and_modify"
|
127
|
+
traces[1]['Update_Document'].must_equal "{:count=>203}"
|
135
128
|
end
|
136
129
|
|
137
|
-
|
138
|
-
|
130
|
+
it "should trace insert" do
|
131
|
+
coll = @db.collection("testCollection")
|
139
132
|
|
140
|
-
|
141
|
-
|
142
|
-
|
133
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
134
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
135
|
+
id = coll.insert(doc)
|
136
|
+
end
|
143
137
|
|
144
|
-
|
145
|
-
|
146
|
-
traces[1]['QueryOp'].must_equal "insert"
|
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
|
149
|
-
end
|
138
|
+
traces = get_all_traces
|
139
|
+
traces.count.must_equal 4
|
150
140
|
|
151
|
-
|
152
|
-
|
141
|
+
validate_outer_layers(traces, 'mongo_test')
|
142
|
+
validate_event_keys(traces[1], @entry_kvs)
|
143
|
+
validate_event_keys(traces[2], @exit_kvs)
|
153
144
|
|
154
|
-
|
155
|
-
|
156
|
-
|
157
|
-
|
145
|
+
traces[1]['Collection'].must_equal "testCollection"
|
146
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
147
|
+
traces[1]['QueryOp'].must_equal "insert"
|
148
|
+
# Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+
|
149
|
+
traces[1].has_key?('Query').must_equal true
|
158
150
|
end
|
159
151
|
|
160
|
-
|
161
|
-
|
152
|
+
it "should trace map_reduce" do
|
153
|
+
coll = @db.collection("testCollection")
|
162
154
|
|
163
|
-
|
164
|
-
|
165
|
-
|
155
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
156
|
+
map = "function() { emit(this.name, 1); }"
|
157
|
+
reduce = "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
158
|
+
coll.map_reduce(map, reduce, { :out => "mr_results", :limit => 100, :read => :primary })
|
159
|
+
end
|
166
160
|
|
167
|
-
|
168
|
-
|
169
|
-
traces[1]['QueryOp'].must_equal "map_reduce"
|
170
|
-
traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
|
171
|
-
traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
172
|
-
traces[1]['Limit'].must_equal "100"
|
173
|
-
end
|
161
|
+
traces = get_all_traces
|
162
|
+
traces.count.must_equal 4
|
174
163
|
|
175
|
-
|
176
|
-
|
164
|
+
validate_outer_layers(traces, 'mongo_test')
|
165
|
+
validate_event_keys(traces[1], @entry_kvs)
|
166
|
+
validate_event_keys(traces[2], @exit_kvs)
|
177
167
|
|
178
|
-
|
179
|
-
|
168
|
+
traces[1]['Collection'].must_equal "testCollection"
|
169
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
170
|
+
traces[1]['QueryOp'].must_equal "map_reduce"
|
171
|
+
traces[1]['Map_Function'].must_equal "function() { emit(this.name, 1); }"
|
172
|
+
traces[1]['Reduce_Function'].must_equal "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
|
173
|
+
traces[1]['Limit'].must_equal "100"
|
180
174
|
end
|
181
175
|
|
182
|
-
|
183
|
-
|
176
|
+
it "should trace remove" do
|
177
|
+
coll = @db.collection("testCollection")
|
184
178
|
|
185
|
-
|
186
|
-
|
187
|
-
|
179
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
180
|
+
coll.remove(:name => "SaveOp")
|
181
|
+
end
|
188
182
|
|
189
|
-
|
190
|
-
|
191
|
-
traces[1]['QueryOp'].must_equal "remove"
|
192
|
-
traces[1]['Query'].must_equal "{\"name\":\"SaveOp\"}"
|
193
|
-
end
|
183
|
+
traces = get_all_traces
|
184
|
+
traces.count.must_equal 4
|
194
185
|
|
195
|
-
|
196
|
-
|
197
|
-
|
186
|
+
validate_outer_layers(traces, 'mongo_test')
|
187
|
+
validate_event_keys(traces[1], @entry_kvs)
|
188
|
+
validate_event_keys(traces[2], @exit_kvs)
|
198
189
|
|
199
|
-
|
200
|
-
|
190
|
+
traces[1]['Collection'].must_equal "testCollection"
|
191
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
192
|
+
traces[1]['QueryOp'].must_equal "remove"
|
193
|
+
traces[1]['Query'].must_equal "{\"name\":\"SaveOp\"}"
|
201
194
|
end
|
202
195
|
|
203
|
-
|
204
|
-
|
196
|
+
it "should trace rename" do
|
197
|
+
coll = @db.collection("testCollection")
|
198
|
+
new_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
205
199
|
|
206
|
-
|
207
|
-
|
208
|
-
|
200
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
201
|
+
coll.rename(new_name)
|
202
|
+
end
|
209
203
|
|
210
|
-
|
211
|
-
|
212
|
-
traces[1]['QueryOp'].must_equal "rename"
|
213
|
-
traces[1]['New_Collection_Name'].must_equal new_name
|
204
|
+
traces = get_all_traces
|
205
|
+
traces.count.must_equal 4
|
214
206
|
|
215
|
-
|
216
|
-
|
217
|
-
|
218
|
-
|
219
|
-
it "should trace update" do
|
220
|
-
coll = @db.collection("testCollection")
|
207
|
+
validate_outer_layers(traces, 'mongo_test')
|
208
|
+
validate_event_keys(traces[1], @entry_kvs)
|
209
|
+
validate_event_keys(traces[2], @exit_kvs)
|
221
210
|
|
222
|
-
|
223
|
-
|
224
|
-
|
211
|
+
traces[1]['Collection'].must_equal "testCollection"
|
212
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
213
|
+
traces[1]['QueryOp'].must_equal "rename"
|
214
|
+
traces[1]['New_Collection_Name'].must_equal new_name
|
225
215
|
|
226
|
-
|
227
|
-
coll.
|
216
|
+
# Clean up after test and set collection name back to original
|
217
|
+
coll.rename("testCollection")
|
228
218
|
end
|
229
219
|
|
230
|
-
|
231
|
-
|
232
|
-
|
233
|
-
validate_outer_layers(traces, 'mongo_test')
|
234
|
-
validate_event_keys(traces[1], @entry_kvs)
|
235
|
-
validate_event_keys(traces[2], @exit_kvs)
|
220
|
+
it "should trace update" do
|
221
|
+
coll = @db.collection("testCollection")
|
236
222
|
|
237
|
-
|
238
|
-
|
239
|
-
|
240
|
-
traces[1]['Query'].must_equal "{\"_id\":1}"
|
223
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
224
|
+
# Two types of update calls
|
225
|
+
coll.update({"_id" => 1}, { "$set" => {"name" => "MongoDB Ruby"}}, :multi => true)
|
241
226
|
|
242
|
-
|
243
|
-
|
227
|
+
doc = {"name" => "MyOtherName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
228
|
+
coll.update({"_id" => 1}, doc)
|
229
|
+
end
|
244
230
|
|
245
|
-
|
246
|
-
|
247
|
-
traces[3]['Query'].must_equal "{\"_id\":1}"
|
248
|
-
end
|
231
|
+
traces = get_all_traces
|
232
|
+
traces.count.must_equal 6
|
249
233
|
|
250
|
-
|
251
|
-
|
234
|
+
validate_outer_layers(traces, 'mongo_test')
|
235
|
+
validate_event_keys(traces[1], @entry_kvs)
|
236
|
+
validate_event_keys(traces[2], @exit_kvs)
|
252
237
|
|
253
|
-
|
254
|
-
|
255
|
-
|
238
|
+
traces[1]['Collection'].must_equal "testCollection"
|
239
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
240
|
+
traces[1]['QueryOp'].must_equal "update"
|
241
|
+
traces[1]['Query'].must_equal "{\"_id\":1}"
|
256
242
|
|
257
|
-
|
258
|
-
|
243
|
+
validate_event_keys(traces[3], @entry_kvs)
|
244
|
+
validate_event_keys(traces[4], @exit_kvs)
|
259
245
|
|
260
|
-
|
261
|
-
|
262
|
-
|
246
|
+
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
247
|
+
traces[3]['QueryOp'].must_equal "update"
|
248
|
+
traces[3]['Query'].must_equal "{\"_id\":1}"
|
249
|
+
end
|
263
250
|
|
264
|
-
|
265
|
-
|
266
|
-
traces[1]['QueryOp'].must_equal "distinct"
|
267
|
-
end
|
251
|
+
it "should trace distinct" do
|
252
|
+
coll = @db.collection("testCollection")
|
268
253
|
|
269
|
-
|
270
|
-
|
271
|
-
|
254
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
255
|
+
coll.distinct("count")
|
256
|
+
end
|
272
257
|
|
273
|
-
|
274
|
-
|
275
|
-
id = coll.insert(doc)
|
258
|
+
traces = get_all_traces
|
259
|
+
traces.count.must_equal 4
|
276
260
|
|
277
|
-
|
278
|
-
|
279
|
-
|
280
|
-
# cursor.
|
281
|
-
# https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
|
261
|
+
validate_outer_layers(traces, 'mongo_test')
|
262
|
+
validate_event_keys(traces[1], @entry_kvs)
|
263
|
+
validate_event_keys(traces[2], @exit_kvs)
|
282
264
|
|
283
|
-
|
284
|
-
|
265
|
+
traces[1]['Collection'].must_equal "testCollection"
|
266
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
267
|
+
traces[1]['QueryOp'].must_equal "distinct"
|
285
268
|
end
|
286
269
|
|
287
|
-
|
288
|
-
|
270
|
+
it "should trace find" do
|
271
|
+
coll = @db.collection("testCollection")
|
272
|
+
result = nil
|
289
273
|
|
290
|
-
|
291
|
-
|
292
|
-
|
293
|
-
|
294
|
-
result.wont_match nil
|
295
|
-
result.is_a?(Mongo::Cursor).must_equal true
|
296
|
-
traces[1]['Collection'].must_equal "testCollection"
|
297
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
298
|
-
traces[1]['QueryOp'].must_equal "find"
|
299
|
-
traces[1].has_key?('Query').must_equal true
|
300
|
-
traces[1]['Limit'].must_equal "1"
|
301
|
-
end
|
274
|
+
# Insert a doc to assure we get a result
|
275
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
276
|
+
id = coll.insert(doc)
|
302
277
|
|
303
|
-
|
304
|
-
|
305
|
-
|
278
|
+
# If given an optional block +find+ will yield a Cursor to that block,
|
279
|
+
# close the cursor, and then return nil. This guarantees that partially
|
280
|
+
# evaluated cursors will be closed. If given no block +find+ returns a
|
281
|
+
# cursor.
|
282
|
+
# https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
|
283
|
+
|
284
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
285
|
+
result = coll.find(:name => "MyName", :limit => 1)
|
286
|
+
end
|
287
|
+
|
288
|
+
traces = get_all_traces
|
289
|
+
traces.count.must_equal 4
|
290
|
+
|
291
|
+
validate_outer_layers(traces, 'mongo_test')
|
292
|
+
validate_event_keys(traces[1], @entry_kvs)
|
293
|
+
validate_event_keys(traces[2], @exit_kvs)
|
294
|
+
|
295
|
+
result.wont_match nil
|
296
|
+
result.is_a?(Mongo::Cursor).must_equal true
|
297
|
+
traces[1]['Collection'].must_equal "testCollection"
|
298
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
299
|
+
traces[1]['QueryOp'].must_equal "find"
|
300
|
+
traces[1].has_key?('Query').must_equal true
|
301
|
+
traces[1]['Limit'].must_equal "1"
|
302
|
+
end
|
306
303
|
|
307
|
-
|
308
|
-
|
309
|
-
|
304
|
+
it "should trace find (with block)" do
|
305
|
+
coll = @db.collection("testCollection")
|
306
|
+
result = []
|
310
307
|
|
311
|
-
|
312
|
-
|
313
|
-
|
314
|
-
# cursor.
|
315
|
-
# https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
|
308
|
+
# Insert a doc to assure we get a result
|
309
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
310
|
+
id = coll.insert(doc)
|
316
311
|
|
317
|
-
|
318
|
-
|
319
|
-
|
312
|
+
# If given an optional block +find+ will yield a Cursor to that block,
|
313
|
+
# close the cursor, and then return nil. This guarantees that partially
|
314
|
+
# evaluated cursors will be closed. If given no block +find+ returns a
|
315
|
+
# cursor.
|
316
|
+
# https://github.com/mongodb/mongo-ruby-driver/blob/1.10.1/lib/mongo/collection.rb#L178
|
317
|
+
|
318
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
319
|
+
blk = lambda { |x| x }
|
320
|
+
result = coll.find(:name => "MyName", :limit => 10, &blk)
|
321
|
+
end
|
322
|
+
|
323
|
+
traces = get_all_traces
|
324
|
+
traces.count.must_equal 4
|
325
|
+
|
326
|
+
validate_outer_layers(traces, 'mongo_test')
|
327
|
+
validate_event_keys(traces[1], @entry_kvs)
|
328
|
+
validate_event_keys(traces[2], @exit_kvs)
|
329
|
+
|
330
|
+
result.must_equal nil
|
331
|
+
traces[1]['Collection'].must_equal "testCollection"
|
332
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
333
|
+
traces[1]['QueryOp'].must_equal "find"
|
334
|
+
traces[1].has_key?('Query').must_equal true
|
320
335
|
end
|
321
336
|
|
322
|
-
|
323
|
-
|
337
|
+
it "should trace group" do
|
338
|
+
coll = @db.collection("testCollection")
|
324
339
|
|
325
|
-
|
326
|
-
|
327
|
-
|
340
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
341
|
+
coll.group( :key => :type,
|
342
|
+
:cond => { :count => 1 },
|
343
|
+
:initial => { :count => 0 },
|
344
|
+
:reduce => 'function(obj,prev) { prev.count += obj.c; }')
|
345
|
+
end
|
328
346
|
|
329
|
-
|
330
|
-
|
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
|
347
|
+
traces = get_all_traces
|
348
|
+
traces.count.must_equal 4
|
335
349
|
|
336
|
-
|
337
|
-
|
350
|
+
validate_outer_layers(traces, 'mongo_test')
|
351
|
+
validate_event_keys(traces[1], @entry_kvs)
|
352
|
+
validate_event_keys(traces[2], @exit_kvs)
|
338
353
|
|
339
|
-
|
340
|
-
|
341
|
-
|
342
|
-
|
343
|
-
|
354
|
+
traces[1]['Collection'].must_equal "testCollection"
|
355
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
356
|
+
traces[1]['QueryOp'].must_equal "group"
|
357
|
+
# Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+
|
358
|
+
traces[1].has_key?('Query').must_equal true
|
344
359
|
end
|
345
360
|
|
346
|
-
|
347
|
-
|
361
|
+
it "should trace create, ensure and drop index" do
|
362
|
+
coll = @db.collection("testCollection")
|
348
363
|
|
349
|
-
|
350
|
-
|
351
|
-
|
364
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
365
|
+
coll.create_index("i")
|
366
|
+
coll.ensure_index("i")
|
367
|
+
coll.drop_index("i_1")
|
368
|
+
end
|
352
369
|
|
353
|
-
|
354
|
-
|
355
|
-
traces[1]['QueryOp'].must_equal "group"
|
356
|
-
# Don't test exact hash value since to_json hash ordering varies between 1.8.7 and 1.9+
|
357
|
-
traces[1].has_key?('Query').must_equal true
|
358
|
-
end
|
370
|
+
traces = get_all_traces
|
371
|
+
traces.count.must_equal 8
|
359
372
|
|
360
|
-
|
361
|
-
|
373
|
+
validate_outer_layers(traces, 'mongo_test')
|
374
|
+
validate_event_keys(traces[1], @entry_kvs)
|
375
|
+
validate_event_keys(traces[2], @exit_kvs)
|
362
376
|
|
363
|
-
|
364
|
-
|
365
|
-
|
366
|
-
coll.drop_index("i_1")
|
367
|
-
end
|
377
|
+
traces[1]['Collection'].must_equal "testCollection"
|
378
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
379
|
+
traces[1]['QueryOp'].must_equal "create_index"
|
368
380
|
|
369
|
-
|
370
|
-
|
381
|
+
validate_event_keys(traces[3], @entry_kvs)
|
382
|
+
validate_event_keys(traces[4], @exit_kvs)
|
371
383
|
|
372
|
-
|
373
|
-
|
374
|
-
|
384
|
+
traces[3]['Collection'].must_equal "testCollection"
|
385
|
+
traces[3].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
386
|
+
traces[3]['QueryOp'].must_equal "ensure_index"
|
375
387
|
|
376
|
-
|
377
|
-
|
378
|
-
traces[1]['QueryOp'].must_equal "create_index"
|
388
|
+
validate_event_keys(traces[5], @entry_kvs)
|
389
|
+
validate_event_keys(traces[6], @exit_kvs)
|
379
390
|
|
380
|
-
|
381
|
-
|
391
|
+
traces[5]['Collection'].must_equal "testCollection"
|
392
|
+
traces[5].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
393
|
+
traces[5]['QueryOp'].must_equal "drop_index"
|
394
|
+
end
|
382
395
|
|
383
|
-
|
384
|
-
|
385
|
-
traces[3]['QueryOp'].must_equal "ensure_index"
|
396
|
+
it "should trace drop_indexes" do
|
397
|
+
coll = @db.collection("testCollection")
|
386
398
|
|
387
|
-
|
388
|
-
|
399
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
400
|
+
coll.drop_indexes
|
401
|
+
end
|
389
402
|
|
390
|
-
|
391
|
-
|
392
|
-
traces[5]['QueryOp'].must_equal "drop_index"
|
393
|
-
end
|
403
|
+
traces = get_all_traces
|
404
|
+
traces.count.must_equal 4
|
394
405
|
|
395
|
-
|
396
|
-
|
406
|
+
validate_outer_layers(traces, 'mongo_test')
|
407
|
+
validate_event_keys(traces[1], @entry_kvs)
|
408
|
+
validate_event_keys(traces[2], @exit_kvs)
|
397
409
|
|
398
|
-
|
399
|
-
|
410
|
+
traces[1]['Collection'].must_equal "testCollection"
|
411
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
412
|
+
traces[1]['QueryOp'].must_equal "drop_indexes"
|
400
413
|
end
|
401
414
|
|
402
|
-
|
403
|
-
|
415
|
+
it "should trace index_information" do
|
416
|
+
coll = @db.collection("testCollection")
|
404
417
|
|
405
|
-
|
406
|
-
|
407
|
-
|
418
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
419
|
+
coll.index_information
|
420
|
+
end
|
408
421
|
|
409
|
-
|
410
|
-
|
411
|
-
traces[1]['QueryOp'].must_equal "drop_indexes"
|
412
|
-
end
|
422
|
+
traces = get_all_traces
|
423
|
+
traces.count.must_equal 4
|
413
424
|
|
414
|
-
|
415
|
-
|
425
|
+
validate_outer_layers(traces, 'mongo_test')
|
426
|
+
validate_event_keys(traces[1], @entry_kvs)
|
427
|
+
validate_event_keys(traces[2], @exit_kvs)
|
416
428
|
|
417
|
-
|
418
|
-
|
429
|
+
traces[1]['Collection'].must_equal "testCollection"
|
430
|
+
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
431
|
+
traces[1]['QueryOp'].must_equal "index_information"
|
419
432
|
end
|
420
433
|
|
421
|
-
|
422
|
-
|
423
|
-
|
424
|
-
validate_outer_layers(traces, 'mongo_test')
|
425
|
-
validate_event_keys(traces[1], @entry_kvs)
|
426
|
-
validate_event_keys(traces[2], @exit_kvs)
|
427
|
-
|
428
|
-
traces[1]['Collection'].must_equal "testCollection"
|
429
|
-
traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
|
430
|
-
traces[1]['QueryOp'].must_equal "index_information"
|
431
|
-
end
|
434
|
+
it "should obey :collect_backtraces setting when true" do
|
435
|
+
Oboe::Config[:mongo][:collect_backtraces] = true
|
432
436
|
|
433
|
-
|
434
|
-
Oboe::Config[:mongo][:collect_backtraces] = true
|
437
|
+
coll = @db.collection("testCollection")
|
435
438
|
|
436
|
-
|
439
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
440
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
441
|
+
id = coll.insert(doc)
|
442
|
+
end
|
437
443
|
|
438
|
-
|
439
|
-
|
440
|
-
id = coll.insert(doc)
|
444
|
+
traces = get_all_traces
|
445
|
+
layer_has_key(traces, 'mongo', 'Backtrace')
|
441
446
|
end
|
442
447
|
|
443
|
-
|
444
|
-
|
445
|
-
end
|
448
|
+
it "should obey :collect_backtraces setting when false" do
|
449
|
+
Oboe::Config[:mongo][:collect_backtraces] = false
|
446
450
|
|
447
|
-
|
448
|
-
Oboe::Config[:mongo][:collect_backtraces] = false
|
451
|
+
coll = @db.collection("testCollection")
|
449
452
|
|
450
|
-
|
453
|
+
Oboe::API.start_trace('mongo_test', '', {}) do
|
454
|
+
doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
|
455
|
+
id = coll.insert(doc)
|
456
|
+
end
|
451
457
|
|
452
|
-
|
453
|
-
|
454
|
-
id = coll.insert(doc)
|
458
|
+
traces = get_all_traces
|
459
|
+
layer_doesnt_have_key(traces, 'mongo', 'Backtrace')
|
455
460
|
end
|
456
|
-
|
457
|
-
traces = get_all_traces
|
458
|
-
layer_doesnt_have_key(traces, 'mongo', 'Backtrace')
|
459
461
|
end
|
460
462
|
end
|