oboe 2.6.6.1 → 2.6.7.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.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +6 -0
  3. data/Appraisals +6 -16
  4. data/CHANGELOG.md +30 -14
  5. data/Gemfile +4 -3
  6. data/Gemfile.lock +20 -25
  7. data/Rakefile +5 -1
  8. data/ext/oboe_metal/extconf.rb +2 -2
  9. data/gemfiles/mongo.gemfile +33 -0
  10. data/gemfiles/moped.gemfile +33 -0
  11. data/lib/base.rb +28 -10
  12. data/lib/joboe_metal.rb +12 -34
  13. data/lib/method_profiling.rb +3 -3
  14. data/lib/oboe/api/layerinit.rb +14 -14
  15. data/lib/oboe/api/logging.rb +11 -11
  16. data/lib/oboe/api/profiling.rb +7 -6
  17. data/lib/oboe/api/tracing.rb +3 -3
  18. data/lib/oboe/api/util.rb +4 -4
  19. data/lib/oboe/config.rb +7 -7
  20. data/lib/oboe/frameworks/padrino.rb +2 -2
  21. data/lib/oboe/frameworks/rails.rb +11 -11
  22. data/lib/oboe/frameworks/rails/inst/action_controller.rb +4 -4
  23. data/lib/oboe/frameworks/rails/inst/action_view.rb +2 -2
  24. data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +1 -1
  25. data/lib/oboe/frameworks/rails/inst/action_view_30.rb +1 -1
  26. data/lib/oboe/frameworks/rails/inst/active_record.rb +1 -1
  27. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +3 -3
  28. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +2 -2
  29. data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +1 -1
  30. data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +8 -8
  31. data/lib/oboe/frameworks/sinatra.rb +33 -3
  32. data/lib/oboe/frameworks/sinatra/templates.rb +2 -2
  33. data/lib/oboe/inst/cassandra.rb +19 -19
  34. data/lib/oboe/inst/dalli.rb +7 -7
  35. data/lib/oboe/inst/http.rb +5 -5
  36. data/lib/oboe/inst/memcache.rb +14 -14
  37. data/lib/oboe/inst/memcached.rb +8 -8
  38. data/lib/oboe/inst/mongo.rb +2 -2
  39. data/lib/oboe/inst/moped.rb +29 -29
  40. data/lib/oboe/inst/rack.rb +3 -3
  41. data/lib/oboe/inst/redis.rb +24 -24
  42. data/lib/oboe/inst/resque.rb +4 -4
  43. data/lib/oboe/loading.rb +6 -6
  44. data/lib/oboe/logger.rb +4 -4
  45. data/lib/oboe/version.rb +1 -1
  46. data/lib/oboe_metal.rb +11 -39
  47. data/test/frameworks/apps/grape_simple.rb +1 -1
  48. data/test/frameworks/apps/sinatra_simple.rb +1 -1
  49. data/test/frameworks/padrino_test.rb +3 -3
  50. data/test/frameworks/sinatra_test.rb +3 -3
  51. data/test/instrumentation/cassandra_test.rb +45 -45
  52. data/test/instrumentation/http_test.rb +6 -6
  53. data/test/instrumentation/mongo_test.rb +347 -345
  54. data/test/instrumentation/moped_test.rb +40 -40
  55. data/test/instrumentation/redis_hashes_test.rb +20 -20
  56. data/test/instrumentation/redis_keys_test.rb +19 -19
  57. data/test/instrumentation/redis_lists_test.rb +22 -22
  58. data/test/instrumentation/redis_misc_test.rb +14 -14
  59. data/test/instrumentation/redis_sets_test.rb +20 -20
  60. data/test/instrumentation/redis_sortedsets_test.rb +25 -25
  61. data/test/instrumentation/redis_strings_test.rb +27 -27
  62. data/test/instrumentation/resque_test.rb +7 -7
  63. data/test/minitest_helper.rb +18 -6
  64. data/test/profiling/method_test.rb +24 -24
  65. data/test/support/liboboe_settings_test.rb +3 -3
  66. data/test/support/xtrace_test.rb +2 -2
  67. metadata +26 -32
  68. data/gemfiles/rails2.3.gemfile +0 -18
  69. data/gemfiles/rails2.3.gemfile.lock +0 -95
  70. data/gemfiles/rails3.0.gemfile +0 -18
  71. data/gemfiles/rails3.0.gemfile.lock +0 -142
  72. data/gemfiles/rails3.1.gemfile +0 -18
  73. data/gemfiles/rails3.1.gemfile.lock +0 -152
  74. data/gemfiles/rails3.2.gemfile +0 -18
  75. 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
- describe Oboe::Inst::Mongo do
4
- before do
5
- clear_all_traces
6
- @connection = Mongo::Connection.new("localhost", 27017, :slave_ok => true)
7
- @db = @connection.db("test-#{ENV['RACK_ENV']}")
8
-
9
- @collections = @db.collection_names
10
- @db.create_collection("testCollection") unless @collections.include? "testCollection"
11
-
12
- # These are standard entry/exit KVs that are passed up with all mongo operations
13
- @entry_kvs = {
14
- 'Layer' => 'mongo',
15
- 'Label' => 'entry',
16
- 'Flavor' => 'mongodb',
17
- 'Database' => 'test-test',
18
- 'RemoteHost' => 'localhost',
19
- 'RemotePort' => '27017' }
20
-
21
- @exit_kvs = { 'Layer' => 'mongo', 'Label' => 'exit' }
22
- @collect_backtraces = Oboe::Config[:mongo][:collect_backtraces]
23
- end
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
- Oboe::Inst::Mongo::COLL_WRITE_OPS.each do |m|
44
- ::Mongo::Collection.method_defined?("#{m}_with_oboe").must_equal true
45
- end
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
- it "should trace create_collection" do
56
- Oboe::API.start_trace('mongo_test', '', {}) do
57
- @db.create_collection("create_and_drop_collection_test")
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
- traces = get_all_traces
61
- traces.count.must_equal 4
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
- validate_outer_layers(traces, 'mongo_test')
64
- validate_event_keys(traces[1], @entry_kvs)
65
- validate_event_keys(traces[2], @exit_kvs)
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
- traces[1]['QueryOp'].must_equal "create_collection"
68
- traces[1]['New_Collection_Name'].must_equal "create_and_drop_collection_test"
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
- 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")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
77
- @db.drop_collection("create_and_drop_collection_test")
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
- traces = get_all_traces
81
- traces.count.must_equal 4
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
- validate_outer_layers(traces, 'mongo_test')
84
- validate_event_keys(traces[1], @entry_kvs)
85
- validate_event_keys(traces[2], @exit_kvs)
77
+ Oboe::API.start_trace('mongo_test', '', {}) do
78
+ @db.drop_collection("create_and_drop_collection_test")
79
+ end
86
80
 
87
- traces[1]['QueryOp'].must_equal "drop_collection"
88
- traces[1]['Collection'].must_equal "create_and_drop_collection_test"
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
- it "should trace count" do
93
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
96
- coll.count(:query => {:name => "MyName"})
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
- traces = get_all_traces
100
- traces.count.must_equal 6
93
+ it "should trace count" do
94
+ coll = @db.collection("testCollection")
101
95
 
102
- validate_outer_layers(traces, 'mongo_test')
103
- validate_event_keys(traces[1], @entry_kvs)
104
- validate_event_keys(traces[2], @exit_kvs)
96
+ Oboe::API.start_trace('mongo_test', '', {}) do
97
+ coll.count(:query => {:name => "MyName"})
98
+ end
105
99
 
106
- traces[3]['QueryOp'].must_equal "count"
107
- end
100
+ traces = get_all_traces
101
+ traces.count.must_equal 6
108
102
 
109
- it "should trace find_and_modify" do
110
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
113
- coll.find_and_modify({ :query => { :name => "MyName" }, :update => { :count => 203 }})
107
+ traces[3]['QueryOp'].must_equal "count"
114
108
  end
115
109
 
116
- traces = get_all_traces
117
- traces.count.must_equal 4
110
+ it "should trace find_and_modify" do
111
+ coll = @db.collection("testCollection")
118
112
 
119
- validate_outer_layers(traces, 'mongo_test')
120
- validate_event_keys(traces[1], @entry_kvs)
121
- validate_event_keys(traces[2], @exit_kvs)
113
+ Oboe::API.start_trace('mongo_test', '', {}) do
114
+ coll.find_and_modify({ :query => { :name => "MyName" }, :update => { :count => 203 }})
115
+ end
122
116
 
123
- traces[1]['Collection'].must_equal "testCollection"
124
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- it "should trace insert" do
130
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
133
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
134
- id = coll.insert(doc)
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
- traces = get_all_traces
138
- traces.count.must_equal 4
130
+ it "should trace insert" do
131
+ coll = @db.collection("testCollection")
139
132
 
140
- validate_outer_layers(traces, 'mongo_test')
141
- validate_event_keys(traces[1], @entry_kvs)
142
- validate_event_keys(traces[2], @exit_kvs)
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
- traces[1]['Collection'].must_equal "testCollection"
145
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- it "should trace map_reduce" do
152
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
155
- map = "function() { emit(this.name, 1); }"
156
- reduce = "function(k, vals) { var sum = 0; for(var i in vals) sum += vals[i]; return sum; }"
157
- coll.map_reduce(map, reduce, { :out => "mr_results", :limit => 100, :read => :primary })
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
- traces = get_all_traces
161
- traces.count.must_equal 4
152
+ it "should trace map_reduce" do
153
+ coll = @db.collection("testCollection")
162
154
 
163
- validate_outer_layers(traces, 'mongo_test')
164
- validate_event_keys(traces[1], @entry_kvs)
165
- validate_event_keys(traces[2], @exit_kvs)
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
- traces[1]['Collection'].must_equal "testCollection"
168
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- it "should trace remove" do
176
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
179
- coll.remove(:name => "SaveOp")
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
- traces = get_all_traces
183
- traces.count.must_equal 4
176
+ it "should trace remove" do
177
+ coll = @db.collection("testCollection")
184
178
 
185
- validate_outer_layers(traces, 'mongo_test')
186
- validate_event_keys(traces[1], @entry_kvs)
187
- validate_event_keys(traces[2], @exit_kvs)
179
+ Oboe::API.start_trace('mongo_test', '', {}) do
180
+ coll.remove(:name => "SaveOp")
181
+ end
188
182
 
189
- traces[1]['Collection'].must_equal "testCollection"
190
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- it "should trace rename" do
196
- coll = @db.collection("testCollection")
197
- new_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
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
- Oboe::API.start_trace('mongo_test', '', {}) do
200
- coll.rename(new_name)
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
- traces = get_all_traces
204
- traces.count.must_equal 4
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
- validate_outer_layers(traces, 'mongo_test')
207
- validate_event_keys(traces[1], @entry_kvs)
208
- validate_event_keys(traces[2], @exit_kvs)
200
+ Oboe::API.start_trace('mongo_test', '', {}) do
201
+ coll.rename(new_name)
202
+ end
209
203
 
210
- traces[1]['Collection'].must_equal "testCollection"
211
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- # Clean up after test and set collection name back to original
216
- coll.rename("testCollection")
217
- end
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
- Oboe::API.start_trace('mongo_test', '', {}) do
223
- # Two types of update calls
224
- coll.update({"_id" => 1}, { "$set" => {"name" => "MongoDB Ruby"}}, :multi => true)
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
- doc = {"name" => "MyOtherName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
227
- coll.update({"_id" => 1}, doc)
216
+ # Clean up after test and set collection name back to original
217
+ coll.rename("testCollection")
228
218
  end
229
219
 
230
- traces = get_all_traces
231
- traces.count.must_equal 6
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
- traces[1]['Collection'].must_equal "testCollection"
238
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
239
- traces[1]['QueryOp'].must_equal "update"
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
- validate_event_keys(traces[3], @entry_kvs)
243
- validate_event_keys(traces[4], @exit_kvs)
227
+ doc = {"name" => "MyOtherName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
228
+ coll.update({"_id" => 1}, doc)
229
+ end
244
230
 
245
- traces[3].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
246
- traces[3]['QueryOp'].must_equal "update"
247
- traces[3]['Query'].must_equal "{\"_id\":1}"
248
- end
231
+ traces = get_all_traces
232
+ traces.count.must_equal 6
249
233
 
250
- it "should trace distinct" do
251
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
254
- coll.distinct("count")
255
- end
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
- traces = get_all_traces
258
- traces.count.must_equal 4
243
+ validate_event_keys(traces[3], @entry_kvs)
244
+ validate_event_keys(traces[4], @exit_kvs)
259
245
 
260
- validate_outer_layers(traces, 'mongo_test')
261
- validate_event_keys(traces[1], @entry_kvs)
262
- validate_event_keys(traces[2], @exit_kvs)
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
- traces[1]['Collection'].must_equal "testCollection"
265
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
266
- traces[1]['QueryOp'].must_equal "distinct"
267
- end
251
+ it "should trace distinct" do
252
+ coll = @db.collection("testCollection")
268
253
 
269
- it "should trace find" do
270
- coll = @db.collection("testCollection")
271
- result = nil
254
+ Oboe::API.start_trace('mongo_test', '', {}) do
255
+ coll.distinct("count")
256
+ end
272
257
 
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)
258
+ traces = get_all_traces
259
+ traces.count.must_equal 4
276
260
 
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
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
- Oboe::API.start_trace('mongo_test', '', {}) do
284
- result = coll.find(:name => "MyName", :limit => 1)
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
- traces = get_all_traces
288
- traces.count.must_equal 4
270
+ it "should trace find" do
271
+ coll = @db.collection("testCollection")
272
+ result = nil
289
273
 
290
- validate_outer_layers(traces, 'mongo_test')
291
- validate_event_keys(traces[1], @entry_kvs)
292
- validate_event_keys(traces[2], @exit_kvs)
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
- it "should trace find (with block)" do
304
- coll = @db.collection("testCollection")
305
- result = []
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
- # 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)
304
+ it "should trace find (with block)" do
305
+ coll = @db.collection("testCollection")
306
+ result = []
310
307
 
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
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
- Oboe::API.start_trace('mongo_test', '', {}) do
318
- blk = lambda { |x| x }
319
- result = coll.find(:name => "MyName", :limit => 10, &blk)
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
- traces = get_all_traces
323
- traces.count.must_equal 4
337
+ it "should trace group" do
338
+ coll = @db.collection("testCollection")
324
339
 
325
- validate_outer_layers(traces, 'mongo_test')
326
- validate_event_keys(traces[1], @entry_kvs)
327
- validate_event_keys(traces[2], @exit_kvs)
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
- 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
347
+ traces = get_all_traces
348
+ traces.count.must_equal 4
335
349
 
336
- it "should trace group" do
337
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
340
- coll.group( :key => :type,
341
- :cond => { :count => 1 },
342
- :initial => { :count => 0 },
343
- :reduce => 'function(obj,prev) { prev.count += obj.c; }')
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
- traces = get_all_traces
347
- traces.count.must_equal 4
361
+ it "should trace create, ensure and drop index" do
362
+ coll = @db.collection("testCollection")
348
363
 
349
- validate_outer_layers(traces, 'mongo_test')
350
- validate_event_keys(traces[1], @entry_kvs)
351
- validate_event_keys(traces[2], @exit_kvs)
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
- traces[1]['Collection'].must_equal "testCollection"
354
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- it "should trace create, ensure and drop index" do
361
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
364
- coll.create_index("i")
365
- coll.ensure_index("i")
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
- traces = get_all_traces
370
- traces.count.must_equal 8
381
+ validate_event_keys(traces[3], @entry_kvs)
382
+ validate_event_keys(traces[4], @exit_kvs)
371
383
 
372
- validate_outer_layers(traces, 'mongo_test')
373
- validate_event_keys(traces[1], @entry_kvs)
374
- validate_event_keys(traces[2], @exit_kvs)
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
- traces[1]['Collection'].must_equal "testCollection"
377
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
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
- validate_event_keys(traces[3], @entry_kvs)
381
- validate_event_keys(traces[4], @exit_kvs)
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
- traces[3]['Collection'].must_equal "testCollection"
384
- traces[3].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
385
- traces[3]['QueryOp'].must_equal "ensure_index"
396
+ it "should trace drop_indexes" do
397
+ coll = @db.collection("testCollection")
386
398
 
387
- validate_event_keys(traces[5], @entry_kvs)
388
- validate_event_keys(traces[6], @exit_kvs)
399
+ Oboe::API.start_trace('mongo_test', '', {}) do
400
+ coll.drop_indexes
401
+ end
389
402
 
390
- traces[5]['Collection'].must_equal "testCollection"
391
- traces[5].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
392
- traces[5]['QueryOp'].must_equal "drop_index"
393
- end
403
+ traces = get_all_traces
404
+ traces.count.must_equal 4
394
405
 
395
- it "should trace drop_indexes" do
396
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
399
- coll.drop_indexes
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
- traces = get_all_traces
403
- traces.count.must_equal 4
415
+ it "should trace index_information" do
416
+ coll = @db.collection("testCollection")
404
417
 
405
- validate_outer_layers(traces, 'mongo_test')
406
- validate_event_keys(traces[1], @entry_kvs)
407
- validate_event_keys(traces[2], @exit_kvs)
418
+ Oboe::API.start_trace('mongo_test', '', {}) do
419
+ coll.index_information
420
+ end
408
421
 
409
- traces[1]['Collection'].must_equal "testCollection"
410
- traces[1].has_key?('Backtrace').must_equal Oboe::Config[:mongo][:collect_backtraces]
411
- traces[1]['QueryOp'].must_equal "drop_indexes"
412
- end
422
+ traces = get_all_traces
423
+ traces.count.must_equal 4
413
424
 
414
- it "should trace index_information" do
415
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
418
- coll.index_information
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
- traces = get_all_traces
422
- traces.count.must_equal 4
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
- it "should obey :collect_backtraces setting when true" do
434
- Oboe::Config[:mongo][:collect_backtraces] = true
437
+ coll = @db.collection("testCollection")
435
438
 
436
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
439
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
440
- id = coll.insert(doc)
444
+ traces = get_all_traces
445
+ layer_has_key(traces, 'mongo', 'Backtrace')
441
446
  end
442
447
 
443
- traces = get_all_traces
444
- layer_has_key(traces, 'mongo', 'Backtrace')
445
- end
448
+ it "should obey :collect_backtraces setting when false" do
449
+ Oboe::Config[:mongo][:collect_backtraces] = false
446
450
 
447
- it "should obey :collect_backtraces setting when false" do
448
- Oboe::Config[:mongo][:collect_backtraces] = false
451
+ coll = @db.collection("testCollection")
449
452
 
450
- coll = @db.collection("testCollection")
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
- Oboe::API.start_trace('mongo_test', '', {}) do
453
- doc = {"name" => "MyName", "type" => "MyType", "count" => 1, "info" => {"x" => 203, "y" => '102'}}
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