oboe 2.7.0.3-java

Sign up to get free protection for your applications and to get access to all the features.
Files changed (102) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +8 -0
  3. data/.travis.yml +51 -0
  4. data/Appraisals +10 -0
  5. data/CHANGELOG.md +223 -0
  6. data/Gemfile +49 -0
  7. data/LICENSE +199 -0
  8. data/README.md +380 -0
  9. data/Rakefile +106 -0
  10. data/ext/oboe_metal/extconf.rb +61 -0
  11. data/ext/oboe_metal/noop/noop.c +7 -0
  12. data/ext/oboe_metal/src/bson/bson.h +221 -0
  13. data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
  14. data/ext/oboe_metal/src/oboe.h +275 -0
  15. data/ext/oboe_metal/src/oboe.hpp +352 -0
  16. data/ext/oboe_metal/src/oboe_wrap.cxx +3886 -0
  17. data/ext/oboe_metal/tests/test.rb +11 -0
  18. data/gemfiles/mongo.gemfile +33 -0
  19. data/gemfiles/moped.gemfile +33 -0
  20. data/get_version.rb +5 -0
  21. data/init.rb +4 -0
  22. data/lib/base.rb +99 -0
  23. data/lib/joboe_metal.rb +185 -0
  24. data/lib/method_profiling.rb +70 -0
  25. data/lib/oboe.rb +50 -0
  26. data/lib/oboe/api.rb +14 -0
  27. data/lib/oboe/api/layerinit.rb +99 -0
  28. data/lib/oboe/api/logging.rb +129 -0
  29. data/lib/oboe/api/memcache.rb +29 -0
  30. data/lib/oboe/api/profiling.rb +50 -0
  31. data/lib/oboe/api/tracing.rb +134 -0
  32. data/lib/oboe/api/util.rb +117 -0
  33. data/lib/oboe/config.rb +140 -0
  34. data/lib/oboe/frameworks/grape.rb +74 -0
  35. data/lib/oboe/frameworks/padrino.rb +66 -0
  36. data/lib/oboe/frameworks/padrino/templates.rb +59 -0
  37. data/lib/oboe/frameworks/rails.rb +139 -0
  38. data/lib/oboe/frameworks/rails/helpers/rum/rum_ajax_header.js.erb +5 -0
  39. data/lib/oboe/frameworks/rails/helpers/rum/rum_footer.js.erb +1 -0
  40. data/lib/oboe/frameworks/rails/helpers/rum/rum_header.js.erb +3 -0
  41. data/lib/oboe/frameworks/rails/inst/action_controller.rb +123 -0
  42. data/lib/oboe/frameworks/rails/inst/action_view.rb +56 -0
  43. data/lib/oboe/frameworks/rails/inst/action_view_2x.rb +54 -0
  44. data/lib/oboe/frameworks/rails/inst/action_view_30.rb +48 -0
  45. data/lib/oboe/frameworks/rails/inst/active_record.rb +24 -0
  46. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
  47. data/lib/oboe/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
  48. data/lib/oboe/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
  49. data/lib/oboe/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
  50. data/lib/oboe/frameworks/rails/inst/connection_adapters/utils.rb +118 -0
  51. data/lib/oboe/frameworks/sinatra.rb +96 -0
  52. data/lib/oboe/frameworks/sinatra/templates.rb +56 -0
  53. data/lib/oboe/inst/cassandra.rb +281 -0
  54. data/lib/oboe/inst/dalli.rb +75 -0
  55. data/lib/oboe/inst/http.rb +72 -0
  56. data/lib/oboe/inst/memcache.rb +105 -0
  57. data/lib/oboe/inst/memcached.rb +96 -0
  58. data/lib/oboe/inst/mongo.rb +240 -0
  59. data/lib/oboe/inst/moped.rb +474 -0
  60. data/lib/oboe/inst/rack.rb +81 -0
  61. data/lib/oboe/inst/redis.rb +273 -0
  62. data/lib/oboe/inst/resque.rb +193 -0
  63. data/lib/oboe/instrumentation.rb +18 -0
  64. data/lib/oboe/loading.rb +98 -0
  65. data/lib/oboe/logger.rb +41 -0
  66. data/lib/oboe/ruby.rb +11 -0
  67. data/lib/oboe/util.rb +129 -0
  68. data/lib/oboe/version.rb +13 -0
  69. data/lib/oboe/xtrace.rb +52 -0
  70. data/lib/oboe_metal.rb +140 -0
  71. data/lib/rails/generators/oboe/install_generator.rb +76 -0
  72. data/lib/rails/generators/oboe/templates/oboe_initializer.rb +94 -0
  73. data/oboe.gemspec +29 -0
  74. data/release.sh +65 -0
  75. data/test/frameworks/apps/grape_simple.rb +10 -0
  76. data/test/frameworks/apps/padrino_simple.rb +41 -0
  77. data/test/frameworks/apps/sinatra_simple.rb +20 -0
  78. data/test/frameworks/grape_test.rb +27 -0
  79. data/test/frameworks/padrino_test.rb +25 -0
  80. data/test/frameworks/sinatra_test.rb +25 -0
  81. data/test/instrumentation/cassandra_test.rb +381 -0
  82. data/test/instrumentation/dalli_test.rb +164 -0
  83. data/test/instrumentation/http_test.rb +97 -0
  84. data/test/instrumentation/memcache_test.rb +251 -0
  85. data/test/instrumentation/memcached_test.rb +226 -0
  86. data/test/instrumentation/mongo_test.rb +462 -0
  87. data/test/instrumentation/moped_test.rb +473 -0
  88. data/test/instrumentation/rack_test.rb +73 -0
  89. data/test/instrumentation/redis_hashes_test.rb +265 -0
  90. data/test/instrumentation/redis_keys_test.rb +318 -0
  91. data/test/instrumentation/redis_lists_test.rb +310 -0
  92. data/test/instrumentation/redis_misc_test.rb +160 -0
  93. data/test/instrumentation/redis_sets_test.rb +293 -0
  94. data/test/instrumentation/redis_sortedsets_test.rb +325 -0
  95. data/test/instrumentation/redis_strings_test.rb +333 -0
  96. data/test/instrumentation/resque_test.rb +62 -0
  97. data/test/minitest_helper.rb +148 -0
  98. data/test/profiling/method_test.rb +198 -0
  99. data/test/support/config_test.rb +39 -0
  100. data/test/support/liboboe_settings_test.rb +46 -0
  101. data/test/support/xtrace_test.rb +35 -0
  102. metadata +200 -0
@@ -0,0 +1,164 @@
1
+ require 'minitest_helper'
2
+
3
+ describe Oboe::Inst::Dalli < ::MiniTest::Spec do
4
+ before do
5
+ clear_all_traces
6
+ @dc = Dalli::Client.new
7
+ @collect_backtraces = Oboe::Config[:dalli][:collect_backtraces]
8
+ end
9
+
10
+ after do
11
+ Oboe::Config[:dalli][:collect_backtraces] = @collect_backtraces
12
+ end
13
+
14
+ it 'Stock Dalli should be loaded, defined and ready' do
15
+ defined?(::Dalli).wont_match nil
16
+ defined?(::Dalli::Client).wont_match nil
17
+ end
18
+
19
+ it 'should have oboe methods defined' do
20
+ [ :perform_with_oboe, :get_multi_with_oboe ].each do |m|
21
+ ::Dalli::Client.method_defined?(m).must_equal true
22
+ end
23
+ end
24
+
25
+ it 'should trace set' do
26
+ Oboe::API.start_trace('dalli_test', '', {}) do
27
+ @dc.set('some_key', 1234)
28
+ end
29
+
30
+ traces = get_all_traces
31
+ traces.count.must_equal 4
32
+
33
+ validate_outer_layers(traces, 'dalli_test')
34
+
35
+ traces[1].has_key?("KVOp").must_equal true
36
+ traces[1].has_key?("KVKey").must_equal true
37
+ traces[1]['Layer'].must_equal "memcache"
38
+ traces[1]['KVKey'].must_equal "some_key"
39
+ end
40
+
41
+ it 'should trace get' do
42
+ Oboe::API.start_trace('dalli_test', '', {}) do
43
+ @dc.get('some_key')
44
+ end
45
+
46
+ traces = get_all_traces
47
+ traces.count.must_equal 5
48
+
49
+ validate_outer_layers(traces, 'dalli_test')
50
+
51
+ traces[1]['KVOp'].must_equal "get"
52
+ traces[1]['KVKey'].must_equal "some_key"
53
+ traces[2]['Label'].must_equal "info"
54
+ traces[2].has_key?('KVHit').must_equal true
55
+ traces[3]['Label'].must_equal "exit"
56
+ end
57
+
58
+ it 'should trace get_multi' do
59
+ Oboe::API.start_trace('dalli_test', '', {}) do
60
+ @dc.get_multi([:one, :two, :three, :four, :five, :six])
61
+ end
62
+
63
+ traces = get_all_traces
64
+ traces.count.must_equal 5
65
+
66
+ validate_outer_layers(traces, 'dalli_test')
67
+
68
+ traces[1]['KVOp'].must_equal "get_multi"
69
+ traces[2]['Label'].must_equal "info"
70
+ traces[2].has_key?('KVKeyCount').must_equal true
71
+ traces[2].has_key?('KVHitCount').must_equal true
72
+ traces[3]['Label'].must_equal "exit"
73
+ end
74
+
75
+ it "should trace increment" do
76
+ @dc.incr("dalli_key_counter", 1, nil, 0)
77
+
78
+ Oboe::API.start_trace('dalli_test', '', {}) do
79
+ @dc.incr("dalli_key_counter")
80
+ end
81
+
82
+ traces = get_all_traces
83
+ traces.count.must_equal 4
84
+
85
+ validate_outer_layers(traces, 'dalli_test')
86
+
87
+ traces[1]['KVOp'].must_equal "incr"
88
+ traces[1]['KVKey'].must_equal "dalli_key_counter"
89
+ traces[2]['Label'].must_equal "exit"
90
+ end
91
+
92
+ it "should trace decrement" do
93
+ @dc.incr("dalli_key_counter", 1, nil, 0)
94
+
95
+ Oboe::API.start_trace('dalli_test', '', {}) do
96
+ @dc.decr("dalli_key_counter")
97
+ end
98
+
99
+ traces = get_all_traces
100
+ traces.count.must_equal 4
101
+
102
+ validate_outer_layers(traces, 'dalli_test')
103
+
104
+ traces[1]['KVOp'].must_equal "decr"
105
+ traces[1]['KVKey'].must_equal "dalli_key_counter"
106
+ traces[2]['Label'].must_equal "exit"
107
+ end
108
+
109
+ it "should trace replace" do
110
+ @dc.set('some_key', 1)
111
+
112
+ Oboe::API.start_trace('dalli_test', '', {}) do
113
+ @dc.replace("some_key", "woop")
114
+ end
115
+
116
+ traces = get_all_traces
117
+ traces.count.must_equal 4
118
+
119
+ validate_outer_layers(traces, 'dalli_test')
120
+
121
+ traces[1]['KVOp'].must_equal "replace"
122
+ traces[1]['KVKey'].must_equal "some_key"
123
+ traces[2]['Label'].must_equal "exit"
124
+ end
125
+
126
+ it "should trace delete" do
127
+ @dc.set('some_key', 1)
128
+
129
+ Oboe::API.start_trace('dalli_test', '', {}) do
130
+ @dc.delete("some_key")
131
+ end
132
+
133
+ traces = get_all_traces
134
+ traces.count.must_equal 4
135
+
136
+ validate_outer_layers(traces, 'dalli_test')
137
+
138
+ traces[1]['KVOp'].must_equal "delete"
139
+ traces[1]['KVKey'].must_equal "some_key"
140
+ end
141
+
142
+ it "should obey :collect_backtraces setting when true" do
143
+ @dc.set('some_key', 1)
144
+ Oboe::Config[:dalli][:collect_backtraces] = true
145
+
146
+ Oboe::API.start_trace('dalli_test', '', {}) do
147
+ @dc.get('some_key')
148
+ end
149
+
150
+ traces = get_all_traces
151
+ layer_has_key(traces, 'memcache', 'Backtrace')
152
+ end
153
+
154
+ it "should obey :collect_backtraces setting when false" do
155
+ Oboe::Config[:dalli][:collect_backtraces] = false
156
+
157
+ Oboe::API.start_trace('dalli_test', '', {}) do
158
+ @dc.get('some_key')
159
+ end
160
+
161
+ traces = get_all_traces
162
+ layer_doesnt_have_key(traces, 'memcache', 'Backtrace')
163
+ end
164
+ end
@@ -0,0 +1,97 @@
1
+ require 'minitest_helper'
2
+ require 'net/http'
3
+
4
+ describe Oboe::Inst do
5
+ before do
6
+ clear_all_traces
7
+ @collect_backtraces = Oboe::Config[:nethttp][:collect_backtraces]
8
+ end
9
+
10
+ after do
11
+ Oboe::Config[:nethttp][:collect_backtraces] = @collect_backtraces
12
+ end
13
+
14
+ it 'Net::HTTP should be defined and ready' do
15
+ defined?(::Net::HTTP).wont_match nil
16
+ end
17
+
18
+ it 'Net::HTTP should have oboe methods defined' do
19
+ [ :request_with_oboe ].each do |m|
20
+ ::Net::HTTP.method_defined?(m).must_equal true
21
+ end
22
+ end
23
+
24
+ it "should trace a Net::HTTP request to an instr'd app" do
25
+ Oboe::API.start_trace('net-http_test', '', {}) do
26
+ uri = URI('http://www.appneta.com')
27
+ http = Net::HTTP.new(uri.host, uri.port)
28
+ http.use_ssl = false
29
+ http.get('/?q=ruby_test_suite').read_body
30
+ end
31
+
32
+ traces = get_all_traces
33
+ traces.count.must_equal 5
34
+
35
+ validate_outer_layers(traces, 'net-http_test')
36
+
37
+ traces[1]['Layer'].must_equal 'net-http'
38
+ traces[2]['IsService'].must_equal "1"
39
+ traces[2]['RemoteProtocol'].must_equal "HTTP"
40
+ traces[2]['RemoteHost'].must_equal "www.appneta.com"
41
+ traces[2]['ServiceArg'].must_equal "/?q=ruby_test_suite"
42
+ traces[2]['HTTPMethod'].must_equal "GET"
43
+ traces[2]['HTTPStatus'].must_equal "200"
44
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
45
+ end
46
+
47
+ it "should trace a Net::HTTP request" do
48
+ Oboe::API.start_trace('net-http_test', '', {}) do
49
+ uri = URI('https://www.google.com')
50
+ http = Net::HTTP.new(uri.host, uri.port)
51
+ http.use_ssl = true
52
+ http.get('/?q=ruby_test_suite').read_body
53
+ end
54
+
55
+ traces = get_all_traces
56
+ traces.count.must_equal 5
57
+
58
+ validate_outer_layers(traces, 'net-http_test')
59
+
60
+ traces[1]['Layer'].must_equal 'net-http'
61
+ traces[2]['IsService'].must_equal "1"
62
+ traces[2]['RemoteProtocol'].must_equal "HTTPS"
63
+ traces[2]['RemoteHost'].must_equal "www.google.com"
64
+ traces[2]['ServiceArg'].must_equal "/?q=ruby_test_suite"
65
+ traces[2]['HTTPMethod'].must_equal "GET"
66
+ traces[2]['HTTPStatus'].must_equal "200"
67
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:nethttp][:collect_backtraces]
68
+ end
69
+
70
+ it "should obey :collect_backtraces setting when true" do
71
+ Oboe::Config[:nethttp][:collect_backtraces] = true
72
+
73
+ Oboe::API.start_trace('nethttp_test', '', {}) do
74
+ uri = URI('http://www.appneta.com')
75
+ http = Net::HTTP.new(uri.host, uri.port)
76
+ http.use_ssl = false
77
+ http.get('/?q=ruby_test_suite').read_body
78
+ end
79
+
80
+ traces = get_all_traces
81
+ layer_has_key(traces, 'net-http', 'Backtrace')
82
+ end
83
+
84
+ it "should obey :collect_backtraces setting when false" do
85
+ Oboe::Config[:nethttp][:collect_backtraces] = false
86
+
87
+ Oboe::API.start_trace('nethttp_test', '', {}) do
88
+ uri = URI('http://www.appneta.com')
89
+ http = Net::HTTP.new(uri.host, uri.port)
90
+ http.use_ssl = false
91
+ http.get('/?q=ruby_test_suite').read_body
92
+ end
93
+
94
+ traces = get_all_traces
95
+ layer_doesnt_have_key(traces, 'net-http', 'Backtrace')
96
+ end
97
+ end
@@ -0,0 +1,251 @@
1
+ require 'minitest_helper'
2
+ require 'memcache'
3
+
4
+ describe Oboe::API::Memcache do
5
+ before do
6
+ clear_all_traces
7
+ @mc = ::MemCache.new('localhost')
8
+
9
+ # These are standard entry/exit KVs that are passed up with all mongo operations
10
+ @entry_kvs = {
11
+ 'Layer' => 'memcache',
12
+ 'Label' => 'entry' }
13
+
14
+ @info_kvs = {
15
+ 'Layer' => 'memcache',
16
+ 'Label' => 'info' }
17
+
18
+ @exit_kvs = { 'Layer' => 'memcache', 'Label' => 'exit' }
19
+ @collect_backtraces = Oboe::Config[:memcache][:collect_backtraces]
20
+ end
21
+
22
+ after do
23
+ Oboe::Config[:memcache][:collect_backtraces] = @collect_backtraces
24
+ end
25
+
26
+ it 'Stock MemCache should be loaded, defined and ready' do
27
+ defined?(::MemCache).wont_match nil
28
+ end
29
+
30
+ it 'MemCache should have oboe methods defined' do
31
+ Oboe::API::Memcache::MEMCACHE_OPS.each do |m|
32
+ if ::MemCache.method_defined?(m)
33
+ ::MemCache.method_defined?("#{m}_with_oboe").must_equal true
34
+ end
35
+ ::MemCache.method_defined?(:request_setup_with_oboe).must_equal true
36
+ ::MemCache.method_defined?(:cache_get_with_oboe).must_equal true
37
+ ::MemCache.method_defined?(:get_multi_with_oboe).must_equal true
38
+ end
39
+ end
40
+
41
+ it "should trace set" do
42
+ Oboe::API.start_trace('memcache_test', '', {}) do
43
+ @mc.set('msg', 'blah')
44
+ end
45
+
46
+ traces = get_all_traces
47
+
48
+ traces.count.must_equal 5
49
+ validate_outer_layers(traces, 'memcache_test')
50
+
51
+ validate_event_keys(traces[1], @entry_kvs)
52
+
53
+ traces[1]['KVOp'].must_equal "set"
54
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
55
+
56
+ validate_event_keys(traces[2], @info_kvs)
57
+ traces[2]['KVKey'].must_equal "msg"
58
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
59
+
60
+ validate_event_keys(traces[3], @exit_kvs)
61
+ end
62
+
63
+ it "should trace get" do
64
+ Oboe::API.start_trace('memcache_test', '', {}) do
65
+ @mc.get('msg')
66
+ end
67
+
68
+ traces = get_all_traces
69
+
70
+ traces.count.must_equal 6
71
+ validate_outer_layers(traces, 'memcache_test')
72
+
73
+ validate_event_keys(traces[1], @entry_kvs)
74
+
75
+ traces[1]['KVOp'].must_equal "get"
76
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
77
+
78
+ validate_event_keys(traces[2], @info_kvs)
79
+ traces[2]['KVKey'].must_equal "msg"
80
+ traces[2]['RemoteHost'].must_equal "localhost"
81
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
82
+
83
+ traces[3].has_key?('KVHit').must_equal true
84
+ traces[3].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
85
+
86
+ validate_event_keys(traces[4], @exit_kvs)
87
+ end
88
+
89
+ it "should trace get_multi" do
90
+ Oboe::API.start_trace('memcache_test', '', {}) do
91
+ @mc.get_multi(['one', 'two', 'three', 'four', 'five', 'six'])
92
+ end
93
+
94
+ traces = get_all_traces
95
+
96
+ traces.count.must_equal 5
97
+ validate_outer_layers(traces, 'memcache_test')
98
+
99
+ validate_event_keys(traces[1], @entry_kvs)
100
+
101
+ traces[1]['KVOp'].must_equal "get_multi"
102
+
103
+ validate_event_keys(traces[2], @info_kvs)
104
+ traces[2]['KVKeyCount'].must_equal "6"
105
+ traces[2].has_key?('KVHitCount').must_equal true
106
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
107
+
108
+ validate_event_keys(traces[3], @exit_kvs)
109
+ end
110
+
111
+ it "should trace add for existing key" do
112
+ @mc.set('testKey', 'x', 1200)
113
+ Oboe::API.start_trace('memcache_test', '', {}) do
114
+ @mc.add('testKey', 'x', 1200)
115
+ end
116
+
117
+ traces = get_all_traces
118
+
119
+ traces.count.must_equal 5
120
+ validate_outer_layers(traces, 'memcache_test')
121
+
122
+ validate_event_keys(traces[1], @entry_kvs)
123
+
124
+ traces[1]['KVOp'].must_equal "add"
125
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
126
+
127
+ validate_event_keys(traces[2], @info_kvs)
128
+ traces[2]['KVKey'].must_equal "testKey"
129
+
130
+ validate_event_keys(traces[3], @exit_kvs)
131
+ end
132
+
133
+ it "should trace append" do
134
+ @mc.set('rawKey', "Peanut Butter ", 600, :raw => true)
135
+ Oboe::API.start_trace('memcache_test', '', {}) do
136
+ @mc.append('rawKey', "Jelly")
137
+ end
138
+
139
+ traces = get_all_traces
140
+
141
+ traces.count.must_equal 5
142
+ validate_outer_layers(traces, 'memcache_test')
143
+
144
+ validate_event_keys(traces[1], @entry_kvs)
145
+
146
+ traces[1]['KVOp'].must_equal "append"
147
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
148
+
149
+ validate_event_keys(traces[2], @info_kvs)
150
+
151
+ traces[2]['KVKey'].must_equal "rawKey"
152
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
153
+
154
+ validate_event_keys(traces[3], @exit_kvs)
155
+ end
156
+
157
+ it "should trace decrement" do
158
+ Oboe::API.start_trace('memcache_test', '', {}) do
159
+ @mc.decr('memcache_key_counter', 1)
160
+ end
161
+
162
+ traces = get_all_traces
163
+
164
+ traces.count.must_equal 5
165
+ validate_outer_layers(traces, 'memcache_test')
166
+
167
+ validate_event_keys(traces[1], @entry_kvs)
168
+
169
+ traces[1]['KVOp'].must_equal "decr"
170
+ traces[1].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
171
+
172
+ traces[2]['KVKey'].must_equal "memcache_key_counter"
173
+ traces[2].has_key?('Backtrace').must_equal Oboe::Config[:memcache][:collect_backtraces]
174
+
175
+ validate_event_keys(traces[3], @exit_kvs)
176
+ end
177
+
178
+ it "should trace increment" do
179
+ Oboe::API.start_trace('memcache_test', '', {}) do
180
+ @mc.incr("memcache_key_counter", 1)
181
+ end
182
+
183
+ traces = get_all_traces
184
+
185
+ traces.count.must_equal 5
186
+ validate_outer_layers(traces, 'memcache_test')
187
+
188
+ validate_event_keys(traces[1], @entry_kvs)
189
+ traces[1]['KVOp'].must_equal "incr"
190
+ validate_event_keys(traces[2], @info_kvs)
191
+ traces[2]['KVKey'].must_equal "memcache_key_counter"
192
+ validate_event_keys(traces[3], @exit_kvs)
193
+ end
194
+
195
+ it "should trace replace" do
196
+ @mc.set("some_key", "blah")
197
+ Oboe::API.start_trace('memcache_test', '', {}) do
198
+ @mc.replace("some_key", "woop")
199
+ end
200
+
201
+ traces = get_all_traces
202
+
203
+ traces.count.must_equal 5
204
+ validate_outer_layers(traces, 'memcache_test')
205
+
206
+ validate_event_keys(traces[1], @entry_kvs)
207
+ traces[1]['KVOp'].must_equal "replace"
208
+ traces[2]['KVKey'].must_equal "some_key"
209
+ validate_event_keys(traces[2], @info_kvs)
210
+ validate_event_keys(traces[3], @exit_kvs)
211
+ end
212
+
213
+ it "should trace delete" do
214
+ Oboe::API.start_trace('memcache_test', '', {}) do
215
+ @mc.delete("some_key")
216
+ end
217
+
218
+ traces = get_all_traces
219
+
220
+ traces.count.must_equal 5
221
+ validate_outer_layers(traces, 'memcache_test')
222
+
223
+ validate_event_keys(traces[1], @entry_kvs)
224
+ traces[1]['KVOp'].must_equal "delete"
225
+ traces[2]['KVKey'].must_equal "some_key"
226
+ validate_event_keys(traces[2], @info_kvs)
227
+ validate_event_keys(traces[3], @exit_kvs)
228
+ end
229
+
230
+ it "should obey :collect_backtraces setting when true" do
231
+ Oboe::Config[:memcache][:collect_backtraces] = true
232
+
233
+ Oboe::API.start_trace('memcache_test', '', {}) do
234
+ @mc.set('some_key', 1)
235
+ end
236
+
237
+ traces = get_all_traces
238
+ layer_has_key(traces, 'memcache', 'Backtrace')
239
+ end
240
+
241
+ it "should obey :collect_backtraces setting when false" do
242
+ Oboe::Config[:memcache][:collect_backtraces] = false
243
+
244
+ Oboe::API.start_trace('memcache_test', '', {}) do
245
+ @mc.set('some_key', 1)
246
+ end
247
+
248
+ traces = get_all_traces
249
+ layer_doesnt_have_key(traces, 'memcache', 'Backtrace')
250
+ end
251
+ end