traceview 3.0.0-java
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.gitignore +10 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +58 -0
- data/Appraisals +10 -0
- data/CHANGELOG.md +490 -0
- data/CONFIG.md +16 -0
- data/Gemfile +95 -0
- data/LICENSE +199 -0
- data/README.md +380 -0
- data/Rakefile +109 -0
- data/examples/DNT.md +35 -0
- data/examples/carrying_context.rb +225 -0
- data/examples/instrumenting_metal_controller.rb +8 -0
- data/examples/puma_on_heroku_config.rb +17 -0
- data/examples/tracing_async_threads.rb +125 -0
- data/examples/tracing_background_jobs.rb +52 -0
- data/examples/tracing_forked_processes.rb +100 -0
- data/examples/unicorn_on_heroku_config.rb +28 -0
- data/ext/oboe_metal/extconf.rb +61 -0
- data/ext/oboe_metal/noop/noop.c +7 -0
- data/ext/oboe_metal/src/bson/bson.h +221 -0
- data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
- data/ext/oboe_metal/src/oboe.h +275 -0
- data/ext/oboe_metal/src/oboe.hpp +352 -0
- data/ext/oboe_metal/src/oboe_wrap.cxx +3886 -0
- data/ext/oboe_metal/tests/test.rb +11 -0
- data/gemfiles/mongo.gemfile +33 -0
- data/gemfiles/moped.gemfile +33 -0
- data/get_version.rb +5 -0
- data/init.rb +4 -0
- data/lib/joboe_metal.rb +206 -0
- data/lib/oboe/README +2 -0
- data/lib/oboe/backward_compatibility.rb +59 -0
- data/lib/oboe/inst/rack.rb +11 -0
- data/lib/oboe.rb +7 -0
- data/lib/oboe_metal.rb +151 -0
- data/lib/rails/generators/traceview/install_generator.rb +76 -0
- data/lib/rails/generators/traceview/templates/traceview_initializer.rb +159 -0
- data/lib/traceview/api/layerinit.rb +51 -0
- data/lib/traceview/api/logging.rb +209 -0
- data/lib/traceview/api/memcache.rb +31 -0
- data/lib/traceview/api/profiling.rb +50 -0
- data/lib/traceview/api/tracing.rb +135 -0
- data/lib/traceview/api/util.rb +121 -0
- data/lib/traceview/api.rb +18 -0
- data/lib/traceview/base.rb +225 -0
- data/lib/traceview/config.rb +238 -0
- data/lib/traceview/frameworks/grape.rb +97 -0
- data/lib/traceview/frameworks/padrino/templates.rb +58 -0
- data/lib/traceview/frameworks/padrino.rb +64 -0
- data/lib/traceview/frameworks/rails/helpers/rum/rum_ajax_header.js.erb +5 -0
- data/lib/traceview/frameworks/rails/helpers/rum/rum_footer.js.erb +1 -0
- data/lib/traceview/frameworks/rails/helpers/rum/rum_header.js.erb +3 -0
- data/lib/traceview/frameworks/rails/inst/action_controller.rb +216 -0
- data/lib/traceview/frameworks/rails/inst/action_view.rb +56 -0
- data/lib/traceview/frameworks/rails/inst/action_view_2x.rb +54 -0
- data/lib/traceview/frameworks/rails/inst/action_view_30.rb +48 -0
- data/lib/traceview/frameworks/rails/inst/active_record.rb +24 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
- data/lib/traceview/frameworks/rails/inst/connection_adapters/utils.rb +117 -0
- data/lib/traceview/frameworks/rails.rb +145 -0
- data/lib/traceview/frameworks/sinatra/templates.rb +56 -0
- data/lib/traceview/frameworks/sinatra.rb +95 -0
- data/lib/traceview/inst/cassandra.rb +279 -0
- data/lib/traceview/inst/dalli.rb +86 -0
- data/lib/traceview/inst/em-http-request.rb +99 -0
- data/lib/traceview/inst/excon.rb +111 -0
- data/lib/traceview/inst/faraday.rb +73 -0
- data/lib/traceview/inst/http.rb +87 -0
- data/lib/traceview/inst/httpclient.rb +173 -0
- data/lib/traceview/inst/memcache.rb +102 -0
- data/lib/traceview/inst/memcached.rb +94 -0
- data/lib/traceview/inst/mongo.rb +238 -0
- data/lib/traceview/inst/moped.rb +474 -0
- data/lib/traceview/inst/rack.rb +122 -0
- data/lib/traceview/inst/redis.rb +271 -0
- data/lib/traceview/inst/resque.rb +192 -0
- data/lib/traceview/inst/rest-client.rb +38 -0
- data/lib/traceview/inst/sequel.rb +162 -0
- data/lib/traceview/inst/typhoeus.rb +102 -0
- data/lib/traceview/instrumentation.rb +21 -0
- data/lib/traceview/loading.rb +94 -0
- data/lib/traceview/logger.rb +41 -0
- data/lib/traceview/method_profiling.rb +84 -0
- data/lib/traceview/ruby.rb +36 -0
- data/lib/traceview/support.rb +113 -0
- data/lib/traceview/thread_local.rb +26 -0
- data/lib/traceview/util.rb +250 -0
- data/lib/traceview/version.rb +16 -0
- data/lib/traceview/xtrace.rb +90 -0
- data/lib/traceview.rb +62 -0
- data/test/frameworks/apps/grape_nested.rb +30 -0
- data/test/frameworks/apps/grape_simple.rb +24 -0
- data/test/frameworks/apps/padrino_simple.rb +45 -0
- data/test/frameworks/apps/sinatra_simple.rb +24 -0
- data/test/frameworks/grape_test.rb +142 -0
- data/test/frameworks/padrino_test.rb +30 -0
- data/test/frameworks/sinatra_test.rb +30 -0
- data/test/instrumentation/cassandra_test.rb +380 -0
- data/test/instrumentation/dalli_test.rb +171 -0
- data/test/instrumentation/em_http_request_test.rb +86 -0
- data/test/instrumentation/excon_test.rb +207 -0
- data/test/instrumentation/faraday_test.rb +235 -0
- data/test/instrumentation/http_test.rb +140 -0
- data/test/instrumentation/httpclient_test.rb +296 -0
- data/test/instrumentation/memcache_test.rb +251 -0
- data/test/instrumentation/memcached_test.rb +226 -0
- data/test/instrumentation/mongo_test.rb +462 -0
- data/test/instrumentation/moped_test.rb +496 -0
- data/test/instrumentation/rack_test.rb +116 -0
- data/test/instrumentation/redis_hashes_test.rb +265 -0
- data/test/instrumentation/redis_keys_test.rb +318 -0
- data/test/instrumentation/redis_lists_test.rb +310 -0
- data/test/instrumentation/redis_misc_test.rb +160 -0
- data/test/instrumentation/redis_sets_test.rb +293 -0
- data/test/instrumentation/redis_sortedsets_test.rb +325 -0
- data/test/instrumentation/redis_strings_test.rb +333 -0
- data/test/instrumentation/resque_test.rb +62 -0
- data/test/instrumentation/rest-client_test.rb +294 -0
- data/test/instrumentation/sequel_mysql2_test.rb +326 -0
- data/test/instrumentation/sequel_mysql_test.rb +326 -0
- data/test/instrumentation/sequel_pg_test.rb +330 -0
- data/test/instrumentation/typhoeus_test.rb +285 -0
- data/test/minitest_helper.rb +187 -0
- data/test/profiling/method_test.rb +198 -0
- data/test/servers/rackapp_8101.rb +22 -0
- data/test/support/backcompat_test.rb +269 -0
- data/test/support/config_test.rb +128 -0
- data/test/support/dnt_test.rb +73 -0
- data/test/support/liboboe_settings_test.rb +104 -0
- data/test/support/xtrace_test.rb +35 -0
- data/traceview.gemspec +29 -0
- metadata +248 -0
@@ -0,0 +1,296 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require 'traceview/inst/rack'
|
3
|
+
require File.expand_path(File.dirname(__FILE__) + '../../frameworks/apps/sinatra_simple')
|
4
|
+
|
5
|
+
class HTTPClientTest < Minitest::Test
|
6
|
+
include Rack::Test::Methods
|
7
|
+
|
8
|
+
def app
|
9
|
+
SinatraSimple
|
10
|
+
end
|
11
|
+
|
12
|
+
def test_reports_version_init
|
13
|
+
init_kvs = ::TraceView::Util.build_init_report
|
14
|
+
assert init_kvs.key?('Ruby.HTTPClient.Version')
|
15
|
+
assert_equal init_kvs['Ruby.HTTPClient.Version'], "HTTPClient-#{::HTTPClient::VERSION}"
|
16
|
+
end
|
17
|
+
|
18
|
+
def test_get_request
|
19
|
+
clear_all_traces
|
20
|
+
|
21
|
+
response = nil
|
22
|
+
|
23
|
+
TraceView::API.start_trace('httpclient_tests') do
|
24
|
+
clnt = HTTPClient.new
|
25
|
+
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
26
|
+
end
|
27
|
+
|
28
|
+
traces = get_all_traces
|
29
|
+
|
30
|
+
# Validate returned xtrace
|
31
|
+
assert response.headers.key?("X-Trace")
|
32
|
+
assert TraceView::XTrace.valid?(response.headers["X-Trace"])
|
33
|
+
|
34
|
+
assert_equal traces.count, 7
|
35
|
+
valid_edges?(traces)
|
36
|
+
validate_outer_layers(traces, "httpclient_tests")
|
37
|
+
|
38
|
+
assert_equal traces[1]['IsService'], 1
|
39
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/?keyword=ruby&lang=en'
|
40
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
41
|
+
assert traces[1].key?('Backtrace')
|
42
|
+
|
43
|
+
assert_equal traces[5]['Layer'], 'httpclient'
|
44
|
+
assert_equal traces[5]['Label'], 'exit'
|
45
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
46
|
+
end
|
47
|
+
|
48
|
+
def test_get_with_header_hash
|
49
|
+
clear_all_traces
|
50
|
+
|
51
|
+
response = nil
|
52
|
+
|
53
|
+
TraceView::API.start_trace('httpclient_tests') do
|
54
|
+
clnt = HTTPClient.new
|
55
|
+
response = clnt.get('http://127.0.0.1:8101/', nil, { "SOAPAction" => "HelloWorld" })
|
56
|
+
end
|
57
|
+
|
58
|
+
traces = get_all_traces
|
59
|
+
|
60
|
+
xtrace = response.headers['X-Trace']
|
61
|
+
assert xtrace
|
62
|
+
assert TraceView::XTrace.valid?(xtrace)
|
63
|
+
|
64
|
+
assert_equal traces.count, 7
|
65
|
+
valid_edges?(traces)
|
66
|
+
validate_outer_layers(traces, "httpclient_tests")
|
67
|
+
|
68
|
+
assert_equal traces[1]['IsService'], 1
|
69
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
70
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
71
|
+
assert traces[1].key?('Backtrace')
|
72
|
+
|
73
|
+
assert_equal traces[5]['Layer'], 'httpclient'
|
74
|
+
assert_equal traces[5]['Label'], 'exit'
|
75
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
76
|
+
end
|
77
|
+
|
78
|
+
def test_get_with_header_array
|
79
|
+
clear_all_traces
|
80
|
+
|
81
|
+
response = nil
|
82
|
+
|
83
|
+
TraceView::API.start_trace('httpclient_tests') do
|
84
|
+
clnt = HTTPClient.new
|
85
|
+
response = clnt.get('http://127.0.0.1:8101/', nil, [["Accept", "text/plain"], ["Accept", "text/html"]])
|
86
|
+
end
|
87
|
+
|
88
|
+
traces = get_all_traces
|
89
|
+
|
90
|
+
xtrace = response.headers['X-Trace']
|
91
|
+
assert xtrace
|
92
|
+
assert TraceView::XTrace.valid?(xtrace)
|
93
|
+
|
94
|
+
assert_equal traces.count, 7
|
95
|
+
valid_edges?(traces)
|
96
|
+
validate_outer_layers(traces, "httpclient_tests")
|
97
|
+
|
98
|
+
assert_equal traces[1]['IsService'], 1
|
99
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
100
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
101
|
+
assert traces[1].key?('Backtrace')
|
102
|
+
|
103
|
+
assert_equal traces[5]['Layer'], 'httpclient'
|
104
|
+
assert_equal traces[5]['Label'], 'exit'
|
105
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
106
|
+
end
|
107
|
+
|
108
|
+
def test_post_request
|
109
|
+
clear_all_traces
|
110
|
+
|
111
|
+
response = nil
|
112
|
+
|
113
|
+
TraceView::API.start_trace('httpclient_tests') do
|
114
|
+
clnt = HTTPClient.new
|
115
|
+
response = clnt.post('http://127.0.0.1:8101/')
|
116
|
+
end
|
117
|
+
|
118
|
+
traces = get_all_traces
|
119
|
+
|
120
|
+
xtrace = response.headers['X-Trace']
|
121
|
+
assert xtrace
|
122
|
+
assert TraceView::XTrace.valid?(xtrace)
|
123
|
+
|
124
|
+
assert_equal traces.count, 7
|
125
|
+
valid_edges?(traces)
|
126
|
+
validate_outer_layers(traces, "httpclient_tests")
|
127
|
+
|
128
|
+
assert_equal traces[1]['IsService'], 1
|
129
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
130
|
+
assert_equal traces[1]['HTTPMethod'], 'POST'
|
131
|
+
assert traces[1].key?('Backtrace')
|
132
|
+
|
133
|
+
assert_equal traces[5]['Layer'], 'httpclient'
|
134
|
+
assert_equal traces[5]['Label'], 'exit'
|
135
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
136
|
+
end
|
137
|
+
|
138
|
+
def test_async_get
|
139
|
+
skip if RUBY_VERSION < '1.9.2'
|
140
|
+
|
141
|
+
clear_all_traces
|
142
|
+
|
143
|
+
conn = nil
|
144
|
+
|
145
|
+
TraceView::API.start_trace('httpclient_tests') do
|
146
|
+
clnt = HTTPClient.new
|
147
|
+
conn = clnt.get_async('http://127.0.0.1:8101/?blah=1')
|
148
|
+
end
|
149
|
+
|
150
|
+
# Allow async request to finish
|
151
|
+
Thread.pass until conn.finished?
|
152
|
+
|
153
|
+
traces = get_all_traces
|
154
|
+
#require 'byebug'; debugger
|
155
|
+
assert_equal traces.count, 7
|
156
|
+
valid_edges?(traces)
|
157
|
+
|
158
|
+
# FIXME: validate_outer_layers assumes that the traces
|
159
|
+
# are ordered which in the case of async, they aren't
|
160
|
+
# validate_outer_layers(traces, "httpclient_tests")
|
161
|
+
|
162
|
+
assert_equal traces[2]['Async'], 1
|
163
|
+
assert_equal traces[2]['IsService'], 1
|
164
|
+
assert_equal traces[2]['RemoteURL'], 'http://127.0.0.1:8101/?blah=1'
|
165
|
+
assert_equal traces[2]['HTTPMethod'], 'GET'
|
166
|
+
assert traces[2].key?('Backtrace')
|
167
|
+
|
168
|
+
assert_equal traces[6]['Layer'], 'httpclient'
|
169
|
+
assert_equal traces[6]['Label'], 'exit'
|
170
|
+
assert_equal traces[6]['HTTPStatus'], 200
|
171
|
+
end
|
172
|
+
|
173
|
+
def test_cross_app_tracing
|
174
|
+
clear_all_traces
|
175
|
+
|
176
|
+
response = nil
|
177
|
+
|
178
|
+
TraceView::API.start_trace('httpclient_tests') do
|
179
|
+
clnt = HTTPClient.new
|
180
|
+
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
181
|
+
end
|
182
|
+
|
183
|
+
xtrace = response.headers['X-Trace']
|
184
|
+
assert xtrace
|
185
|
+
assert TraceView::XTrace.valid?(xtrace)
|
186
|
+
|
187
|
+
traces = get_all_traces
|
188
|
+
|
189
|
+
assert_equal traces.count, 7
|
190
|
+
valid_edges?(traces)
|
191
|
+
validate_outer_layers(traces, "httpclient_tests")
|
192
|
+
|
193
|
+
assert_equal traces[1]['IsService'], 1
|
194
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/?keyword=ruby&lang=en'
|
195
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
196
|
+
assert traces[1].key?('Backtrace')
|
197
|
+
|
198
|
+
assert_equal traces[2]['Layer'], 'rack'
|
199
|
+
assert_equal traces[2]['Label'], 'entry'
|
200
|
+
assert_equal traces[3]['Layer'], 'rack'
|
201
|
+
assert_equal traces[3]['Label'], 'info'
|
202
|
+
assert_equal traces[4]['Layer'], 'rack'
|
203
|
+
assert_equal traces[4]['Label'], 'exit'
|
204
|
+
|
205
|
+
assert_equal traces[5]['Layer'], 'httpclient'
|
206
|
+
assert_equal traces[5]['Label'], 'exit'
|
207
|
+
assert_equal traces[5]['HTTPStatus'], 200
|
208
|
+
end
|
209
|
+
|
210
|
+
def test_requests_with_errors
|
211
|
+
clear_all_traces
|
212
|
+
|
213
|
+
result = nil
|
214
|
+
begin
|
215
|
+
TraceView::API.start_trace('httpclient_tests') do
|
216
|
+
clnt = HTTPClient.new
|
217
|
+
result = clnt.get('http://asfjalkfjlajfljkaljf/')
|
218
|
+
end
|
219
|
+
rescue
|
220
|
+
end
|
221
|
+
|
222
|
+
traces = get_all_traces
|
223
|
+
assert_equal traces.count, 5
|
224
|
+
valid_edges?(traces)
|
225
|
+
validate_outer_layers(traces, "httpclient_tests")
|
226
|
+
|
227
|
+
assert_equal traces[1]['IsService'], 1
|
228
|
+
assert_equal traces[1]['RemoteURL'], 'http://asfjalkfjlajfljkaljf/'
|
229
|
+
assert_equal traces[1]['HTTPMethod'], 'GET'
|
230
|
+
assert traces[1].key?('Backtrace')
|
231
|
+
|
232
|
+
assert_equal traces[2]['Layer'], 'httpclient'
|
233
|
+
assert_equal traces[2]['Label'], 'error'
|
234
|
+
assert_equal traces[2]['ErrorClass'], "SocketError"
|
235
|
+
assert traces[2].key?('ErrorMsg')
|
236
|
+
assert traces[2].key?('Backtrace')
|
237
|
+
|
238
|
+
assert_equal traces[3]['Layer'], 'httpclient'
|
239
|
+
assert_equal traces[3]['Label'], 'exit'
|
240
|
+
end
|
241
|
+
|
242
|
+
def test_log_args_when_true
|
243
|
+
clear_all_traces
|
244
|
+
|
245
|
+
@log_args = TraceView::Config[:httpclient][:log_args]
|
246
|
+
TraceView::Config[:httpclient][:log_args] = true
|
247
|
+
|
248
|
+
response = nil
|
249
|
+
|
250
|
+
TraceView::API.start_trace('httpclient_tests') do
|
251
|
+
clnt = HTTPClient.new
|
252
|
+
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
253
|
+
end
|
254
|
+
|
255
|
+
traces = get_all_traces
|
256
|
+
|
257
|
+
xtrace = response.headers['X-Trace']
|
258
|
+
assert xtrace
|
259
|
+
assert TraceView::XTrace.valid?(xtrace)
|
260
|
+
|
261
|
+
assert_equal traces.count, 7
|
262
|
+
valid_edges?(traces)
|
263
|
+
|
264
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/?keyword=ruby&lang=en'
|
265
|
+
|
266
|
+
TraceView::Config[:httpclient][:log_args] = @log_args
|
267
|
+
end
|
268
|
+
|
269
|
+
def test_log_args_when_false
|
270
|
+
clear_all_traces
|
271
|
+
|
272
|
+
@log_args = TraceView::Config[:httpclient][:log_args]
|
273
|
+
TraceView::Config[:httpclient][:log_args] = false
|
274
|
+
|
275
|
+
response = nil
|
276
|
+
|
277
|
+
TraceView::API.start_trace('httpclient_tests') do
|
278
|
+
clnt = HTTPClient.new
|
279
|
+
response = clnt.get('http://127.0.0.1:8101/', :query => { :keyword => 'ruby', :lang => 'en' })
|
280
|
+
end
|
281
|
+
|
282
|
+
traces = get_all_traces
|
283
|
+
|
284
|
+
xtrace = response.headers['X-Trace']
|
285
|
+
assert xtrace
|
286
|
+
assert TraceView::XTrace.valid?(xtrace)
|
287
|
+
|
288
|
+
assert_equal traces.count, 7
|
289
|
+
valid_edges?(traces)
|
290
|
+
|
291
|
+
assert_equal traces[1]['RemoteURL'], 'http://127.0.0.1:8101/'
|
292
|
+
|
293
|
+
TraceView::Config[:httpclient][:log_args] = @log_args
|
294
|
+
end
|
295
|
+
end
|
296
|
+
|
@@ -0,0 +1,251 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require 'memcache'
|
3
|
+
|
4
|
+
describe "Memcache" do
|
5
|
+
before do
|
6
|
+
clear_all_traces
|
7
|
+
@mc = ::MemCache.new('127.0.0.1')
|
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 = TraceView::Config[:memcache][:collect_backtraces]
|
20
|
+
end
|
21
|
+
|
22
|
+
after do
|
23
|
+
TraceView::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 traceview methods defined' do
|
31
|
+
TraceView::API::Memcache::MEMCACHE_OPS.each do |m|
|
32
|
+
if ::MemCache.method_defined?(m)
|
33
|
+
::MemCache.method_defined?("#{m}_with_traceview").must_equal true
|
34
|
+
end
|
35
|
+
::MemCache.method_defined?(:request_setup_with_traceview).must_equal true
|
36
|
+
::MemCache.method_defined?(:cache_get_with_traceview).must_equal true
|
37
|
+
::MemCache.method_defined?(:get_multi_with_traceview).must_equal true
|
38
|
+
end
|
39
|
+
end
|
40
|
+
|
41
|
+
it "should trace set" do
|
42
|
+
TraceView::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 TraceView::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 TraceView::Config[:memcache][:collect_backtraces]
|
59
|
+
|
60
|
+
validate_event_keys(traces[3], @exit_kvs)
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should trace get" do
|
64
|
+
TraceView::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 TraceView::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 "127.0.0.1"
|
81
|
+
traces[2].has_key?('Backtrace').must_equal TraceView::Config[:memcache][:collect_backtraces]
|
82
|
+
|
83
|
+
traces[3].has_key?('KVHit').must_equal true
|
84
|
+
traces[3].has_key?('Backtrace').must_equal TraceView::Config[:memcache][:collect_backtraces]
|
85
|
+
|
86
|
+
validate_event_keys(traces[4], @exit_kvs)
|
87
|
+
end
|
88
|
+
|
89
|
+
it "should trace get_multi" do
|
90
|
+
TraceView::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 TraceView::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
|
+
TraceView::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 TraceView::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
|
+
TraceView::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 TraceView::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 TraceView::Config[:memcache][:collect_backtraces]
|
153
|
+
|
154
|
+
validate_event_keys(traces[3], @exit_kvs)
|
155
|
+
end
|
156
|
+
|
157
|
+
it "should trace decrement" do
|
158
|
+
TraceView::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 TraceView::Config[:memcache][:collect_backtraces]
|
171
|
+
|
172
|
+
traces[2]['KVKey'].must_equal "memcache_key_counter"
|
173
|
+
traces[2].has_key?('Backtrace').must_equal TraceView::Config[:memcache][:collect_backtraces]
|
174
|
+
|
175
|
+
validate_event_keys(traces[3], @exit_kvs)
|
176
|
+
end
|
177
|
+
|
178
|
+
it "should trace increment" do
|
179
|
+
TraceView::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
|
+
TraceView::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
|
+
TraceView::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
|
+
TraceView::Config[:memcache][:collect_backtraces] = true
|
232
|
+
|
233
|
+
TraceView::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
|
+
TraceView::Config[:memcache][:collect_backtraces] = false
|
243
|
+
|
244
|
+
TraceView::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
|