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,265 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require "redis"
|
3
|
+
|
4
|
+
describe "Redis Hashes" do
|
5
|
+
attr_reader :entry_kvs, :exit_kvs, :redis, :redis_version
|
6
|
+
|
7
|
+
def min_server_version(version)
|
8
|
+
unless Gem::Version.new(@redis_version) >= Gem::Version.new(version.to_s)
|
9
|
+
skip "supported only on redis-server #{version} or greater"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
before do
|
14
|
+
clear_all_traces
|
15
|
+
|
16
|
+
@redis ||= Redis.new
|
17
|
+
|
18
|
+
@redis_version ||= @redis.info["redis_version"]
|
19
|
+
|
20
|
+
# These are standard entry/exit KVs that are passed up with all moped operations
|
21
|
+
@entry_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'entry' }
|
22
|
+
@exit_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'exit' }
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'Stock Redis should be loaded, defined and ready' do
|
26
|
+
defined?(::Redis).wont_match nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should trace hdel" do
|
30
|
+
min_server_version(2.0)
|
31
|
+
|
32
|
+
@redis.hset("whale", "color", "blue")
|
33
|
+
|
34
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
35
|
+
@redis.hdel("whale", "color")
|
36
|
+
end
|
37
|
+
|
38
|
+
traces = get_all_traces
|
39
|
+
traces.count.must_equal 4
|
40
|
+
traces[2]['KVOp'].must_equal "hdel"
|
41
|
+
traces[2]['KVKey'].must_equal "whale"
|
42
|
+
traces[2]['field'].must_equal "color"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should trace hdel multiple fields" do
|
46
|
+
min_server_version(2.4)
|
47
|
+
|
48
|
+
@redis.hset("whale", "color", "blue")
|
49
|
+
@redis.hset("whale", "size", "big")
|
50
|
+
@redis.hset("whale", "eyes", "green")
|
51
|
+
|
52
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
53
|
+
@redis.hdel("whale", ["color", "eyes"])
|
54
|
+
end
|
55
|
+
|
56
|
+
traces = get_all_traces
|
57
|
+
traces.count.must_equal 4
|
58
|
+
traces[2]['KVOp'].must_equal "hdel"
|
59
|
+
traces[2]['KVKey'].must_equal "whale"
|
60
|
+
traces[2].has_key?('field').must_equal false
|
61
|
+
end
|
62
|
+
|
63
|
+
it "should trace hexists" do
|
64
|
+
min_server_version(2.0)
|
65
|
+
|
66
|
+
@redis.hset("whale", "color", "blue")
|
67
|
+
|
68
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
69
|
+
@redis.hexists("whale", "color")
|
70
|
+
end
|
71
|
+
|
72
|
+
traces = get_all_traces
|
73
|
+
traces.count.must_equal 4
|
74
|
+
traces[2]['KVOp'].must_equal "hexists"
|
75
|
+
traces[2]['KVKey'].must_equal "whale"
|
76
|
+
traces[2]['field'].must_equal "color"
|
77
|
+
end
|
78
|
+
|
79
|
+
it "should trace hget" do
|
80
|
+
min_server_version(2.0)
|
81
|
+
|
82
|
+
@redis.hset("whale", "color", "blue")
|
83
|
+
|
84
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
85
|
+
@redis.hget("whale", "color")
|
86
|
+
@redis.hget("whale", "noexist")
|
87
|
+
end
|
88
|
+
|
89
|
+
traces = get_all_traces
|
90
|
+
traces.count.must_equal 6
|
91
|
+
traces[2]['KVOp'].must_equal "hget"
|
92
|
+
traces[2]['KVKey'].must_equal "whale"
|
93
|
+
traces[2]['KVHit'].must_equal 1
|
94
|
+
traces[2]['field'].must_equal "color"
|
95
|
+
traces[4]['KVHit'].must_equal 0
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should trace hgetall" do
|
99
|
+
min_server_version(2.0)
|
100
|
+
|
101
|
+
@redis.hset("whale", "color", "blue")
|
102
|
+
|
103
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
104
|
+
@redis.hgetall("whale")
|
105
|
+
end
|
106
|
+
|
107
|
+
traces = get_all_traces
|
108
|
+
traces.count.must_equal 4
|
109
|
+
traces[2]['KVOp'].must_equal "hgetall"
|
110
|
+
traces[2]['KVKey'].must_equal "whale"
|
111
|
+
end
|
112
|
+
|
113
|
+
it "should trace hincrby" do
|
114
|
+
min_server_version(2.0)
|
115
|
+
|
116
|
+
@redis.hset("whale", "age", 32)
|
117
|
+
|
118
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
119
|
+
@redis.hincrby("whale", "age", 1)
|
120
|
+
end
|
121
|
+
|
122
|
+
traces = get_all_traces
|
123
|
+
traces.count.must_equal 4
|
124
|
+
traces[2]['KVOp'].must_equal "hincrby"
|
125
|
+
traces[2]['KVKey'].must_equal "whale"
|
126
|
+
traces[2]['field'].must_equal "age"
|
127
|
+
traces[2]['increment'].must_equal 1
|
128
|
+
end
|
129
|
+
|
130
|
+
it "should trace hincrbyfloat" do
|
131
|
+
min_server_version(2.6)
|
132
|
+
|
133
|
+
@redis.hset("whale", "age", 32)
|
134
|
+
|
135
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
136
|
+
@redis.hincrbyfloat("whale", "age", 1.3)
|
137
|
+
end
|
138
|
+
|
139
|
+
traces = get_all_traces
|
140
|
+
traces.count.must_equal 4
|
141
|
+
traces[2]['KVOp'].must_equal "hincrbyfloat"
|
142
|
+
traces[2]['KVKey'].must_equal "whale"
|
143
|
+
traces[2]['field'].must_equal "age"
|
144
|
+
traces[2]['increment'].must_equal 1.3
|
145
|
+
end
|
146
|
+
|
147
|
+
it "should trace hkeys" do
|
148
|
+
min_server_version(2.0)
|
149
|
+
|
150
|
+
@redis.hset("whale", "age", 32)
|
151
|
+
|
152
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
153
|
+
@redis.hkeys("whale")
|
154
|
+
end
|
155
|
+
|
156
|
+
traces = get_all_traces
|
157
|
+
traces.count.must_equal 4
|
158
|
+
traces[2]['KVOp'].must_equal "hkeys"
|
159
|
+
traces[2]['KVKey'].must_equal "whale"
|
160
|
+
end
|
161
|
+
|
162
|
+
it "should trace hlen" do
|
163
|
+
min_server_version(2.0)
|
164
|
+
|
165
|
+
@redis.hset("whale", "age", 32)
|
166
|
+
|
167
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
168
|
+
@redis.hlen("whale")
|
169
|
+
end
|
170
|
+
|
171
|
+
traces = get_all_traces
|
172
|
+
traces.count.must_equal 4
|
173
|
+
traces[2]['KVOp'].must_equal "hlen"
|
174
|
+
traces[2]['KVKey'].must_equal "whale"
|
175
|
+
end
|
176
|
+
|
177
|
+
it "should trace hmget" do
|
178
|
+
min_server_version(2.0)
|
179
|
+
|
180
|
+
@redis.hset("whale", "color", "blue")
|
181
|
+
@redis.hset("whale", "size", "big")
|
182
|
+
@redis.hset("whale", "eyes", "green")
|
183
|
+
|
184
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
185
|
+
@redis.hmget("whale", "color", "size", "blah", "brown")
|
186
|
+
end
|
187
|
+
|
188
|
+
traces = get_all_traces
|
189
|
+
traces.count.must_equal 4
|
190
|
+
traces[2]['KVOp'].must_equal "hmget"
|
191
|
+
traces[2]['KVKey'].must_equal "whale"
|
192
|
+
traces[2]['KVKeyCount'].must_equal 4
|
193
|
+
traces[2]['KVHitCount'].must_equal 2
|
194
|
+
end
|
195
|
+
|
196
|
+
it "should trace hmset" do
|
197
|
+
min_server_version(2.0)
|
198
|
+
|
199
|
+
@redis.hset("whale", "color", "blue")
|
200
|
+
@redis.hset("whale", "size", "big")
|
201
|
+
@redis.hset("whale", "eyes", "green")
|
202
|
+
|
203
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
204
|
+
@redis.hmset("whale", ["color", "red", "size", "very big"])
|
205
|
+
end
|
206
|
+
|
207
|
+
traces = get_all_traces
|
208
|
+
traces.count.must_equal 4
|
209
|
+
traces[2]['KVOp'].must_equal "hmset"
|
210
|
+
traces[2]['KVKey'].must_equal "whale"
|
211
|
+
end
|
212
|
+
|
213
|
+
it "should trace hset" do
|
214
|
+
min_server_version(2.0)
|
215
|
+
|
216
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
217
|
+
@redis.hset("whale", "eyes", "green")
|
218
|
+
end
|
219
|
+
|
220
|
+
traces = get_all_traces
|
221
|
+
traces.count.must_equal 4
|
222
|
+
traces[2]['KVOp'].must_equal "hset"
|
223
|
+
traces[2]['KVKey'].must_equal "whale"
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should trace hsetnx" do
|
227
|
+
min_server_version(2.0)
|
228
|
+
|
229
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
230
|
+
@redis.hsetnx("whale", "eyes", "green")
|
231
|
+
end
|
232
|
+
|
233
|
+
traces = get_all_traces
|
234
|
+
traces.count.must_equal 4
|
235
|
+
traces[2]['KVOp'].must_equal "hsetnx"
|
236
|
+
traces[2]['KVKey'].must_equal "whale"
|
237
|
+
end
|
238
|
+
|
239
|
+
it "should trace hvals" do
|
240
|
+
min_server_version(2.0)
|
241
|
+
|
242
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
243
|
+
@redis.hvals("whale")
|
244
|
+
end
|
245
|
+
|
246
|
+
traces = get_all_traces
|
247
|
+
traces.count.must_equal 4
|
248
|
+
traces[2]['KVOp'].must_equal "hvals"
|
249
|
+
traces[2]['KVKey'].must_equal "whale"
|
250
|
+
end
|
251
|
+
|
252
|
+
it "should trace hscan" do
|
253
|
+
min_server_version(2.8)
|
254
|
+
|
255
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
256
|
+
@redis.hscan("whale", 0)
|
257
|
+
end
|
258
|
+
|
259
|
+
traces = get_all_traces
|
260
|
+
traces.count.must_equal 4
|
261
|
+
traces[2]['KVOp'].must_equal "hscan"
|
262
|
+
traces[2]['KVKey'].must_equal "whale"
|
263
|
+
end
|
264
|
+
end
|
265
|
+
|
@@ -0,0 +1,318 @@
|
|
1
|
+
require 'minitest_helper'
|
2
|
+
require "redis"
|
3
|
+
|
4
|
+
describe "Redis Keys" do
|
5
|
+
attr_reader :entry_kvs, :exit_kvs, :redis, :redis_version
|
6
|
+
|
7
|
+
def min_server_version(version)
|
8
|
+
unless Gem::Version.new(@redis_version) >= Gem::Version.new(version.to_s)
|
9
|
+
skip "supported only on redis-server #{version} or greater"
|
10
|
+
end
|
11
|
+
end
|
12
|
+
|
13
|
+
before do
|
14
|
+
clear_all_traces
|
15
|
+
|
16
|
+
@redis ||= Redis.new
|
17
|
+
|
18
|
+
@redis_version ||= @redis.info["redis_version"]
|
19
|
+
|
20
|
+
# These are standard entry/exit KVs that are passed up with all moped operations
|
21
|
+
@entry_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'entry' }
|
22
|
+
@exit_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'exit' }
|
23
|
+
end
|
24
|
+
|
25
|
+
it 'Stock Redis should be loaded, defined and ready' do
|
26
|
+
defined?(::Redis).wont_match nil
|
27
|
+
end
|
28
|
+
|
29
|
+
it "should trace del" do
|
30
|
+
@redis.setex("del_test", 60, "blah")
|
31
|
+
|
32
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
33
|
+
@redis.del("del_test")
|
34
|
+
end
|
35
|
+
|
36
|
+
traces = get_all_traces
|
37
|
+
traces.count.must_equal 4
|
38
|
+
traces[2]['KVOp'].must_equal "del"
|
39
|
+
traces[2]['KVKey'].must_equal "del_test"
|
40
|
+
end
|
41
|
+
|
42
|
+
it "should trace del of multiple keys" do
|
43
|
+
@redis.setex("del_test", 60, "blah")
|
44
|
+
|
45
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
46
|
+
@redis.del(["del_test", "noexist", "maybe"])
|
47
|
+
end
|
48
|
+
|
49
|
+
traces = get_all_traces
|
50
|
+
traces.count.must_equal 4
|
51
|
+
traces[2]['KVOp'].must_equal "del"
|
52
|
+
traces[2].has_key?('KVKey').must_equal false
|
53
|
+
end
|
54
|
+
|
55
|
+
it "should trace dump" do
|
56
|
+
min_server_version(2.6)
|
57
|
+
|
58
|
+
@redis.setex("dump_test", 60, "blah")
|
59
|
+
|
60
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
61
|
+
@redis.dump("del_test")
|
62
|
+
end
|
63
|
+
|
64
|
+
traces = get_all_traces
|
65
|
+
traces.count.must_equal 4
|
66
|
+
traces[2]['KVOp'].must_equal "dump"
|
67
|
+
traces[2]['KVKey'].must_equal "del_test"
|
68
|
+
end
|
69
|
+
|
70
|
+
it "should trace exists" do
|
71
|
+
@redis.setex("talking_heads", 60, "burning down the house")
|
72
|
+
|
73
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
74
|
+
@it_exists = @redis.exists("talking_heads")
|
75
|
+
end
|
76
|
+
|
77
|
+
@it_exists.must_equal true
|
78
|
+
|
79
|
+
traces = get_all_traces
|
80
|
+
traces.count.must_equal 4
|
81
|
+
traces[2]['KVOp'].must_equal "exists"
|
82
|
+
traces[2]['KVKey'].must_equal "talking_heads"
|
83
|
+
end
|
84
|
+
|
85
|
+
it "should trace expire" do
|
86
|
+
@redis.set("expire_please", "burning down the house")
|
87
|
+
|
88
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
89
|
+
@redis.expire("expire_please", 120)
|
90
|
+
end
|
91
|
+
|
92
|
+
traces = get_all_traces
|
93
|
+
traces.count.must_equal 4
|
94
|
+
traces[2]['KVOp'].must_equal "expire"
|
95
|
+
traces[2]['KVKey'].must_equal "expire_please"
|
96
|
+
end
|
97
|
+
|
98
|
+
it "should trace expireat" do
|
99
|
+
@redis.set("expireat_please", "burning down the house")
|
100
|
+
|
101
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
102
|
+
@redis.expireat("expireat_please", Time.now.to_i)
|
103
|
+
end
|
104
|
+
|
105
|
+
traces = get_all_traces
|
106
|
+
traces.count.must_equal 4
|
107
|
+
traces[2]['KVOp'].must_equal "expireat"
|
108
|
+
traces[2]['KVKey'].must_equal "expireat_please"
|
109
|
+
end
|
110
|
+
|
111
|
+
it "should trace keys" do
|
112
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
113
|
+
@redis.keys("del*")
|
114
|
+
end
|
115
|
+
|
116
|
+
traces = get_all_traces
|
117
|
+
traces.count.must_equal 4
|
118
|
+
traces[2]['KVOp'].must_equal "keys"
|
119
|
+
traces[2]['pattern'].must_equal "del*"
|
120
|
+
end
|
121
|
+
|
122
|
+
it "should trace basic move" do
|
123
|
+
@redis.set("piano", Time.now)
|
124
|
+
|
125
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
126
|
+
@redis.move("piano", 1)
|
127
|
+
end
|
128
|
+
|
129
|
+
traces = get_all_traces
|
130
|
+
traces.count.must_equal 4
|
131
|
+
traces[2]['KVOp'].must_equal "move"
|
132
|
+
traces[2]['KVKey'].must_equal "piano"
|
133
|
+
traces[2]['db'].must_equal 1
|
134
|
+
end
|
135
|
+
|
136
|
+
it "should trace persist" do
|
137
|
+
min_server_version(2.2)
|
138
|
+
|
139
|
+
@redis.setex("mine", 60, "blah")
|
140
|
+
|
141
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
142
|
+
@redis.persist("mine")
|
143
|
+
end
|
144
|
+
|
145
|
+
traces = get_all_traces
|
146
|
+
traces.count.must_equal 4
|
147
|
+
traces[2]['KVOp'].must_equal "persist"
|
148
|
+
traces[2]['KVKey'].must_equal "mine"
|
149
|
+
end
|
150
|
+
|
151
|
+
it "should trace pexpire" do
|
152
|
+
min_server_version(2.6)
|
153
|
+
|
154
|
+
@redis.set("sand", "blah")
|
155
|
+
|
156
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
157
|
+
@rv = @redis.pexpire("sand", 8000)
|
158
|
+
end
|
159
|
+
|
160
|
+
@rv.must_equal true
|
161
|
+
|
162
|
+
traces = get_all_traces
|
163
|
+
traces.count.must_equal 4
|
164
|
+
traces[2]['KVOp'].must_equal "pexpire"
|
165
|
+
traces[2]['KVKey'].must_equal "sand"
|
166
|
+
traces[2]['milliseconds'].must_equal 8000
|
167
|
+
end
|
168
|
+
|
169
|
+
it "should trace pexpireat" do
|
170
|
+
min_server_version(2.6)
|
171
|
+
|
172
|
+
@redis.set("sand", "blah")
|
173
|
+
|
174
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
175
|
+
@rv = @redis.pexpireat("sand", 8000)
|
176
|
+
end
|
177
|
+
|
178
|
+
@rv.must_equal true
|
179
|
+
|
180
|
+
traces = get_all_traces
|
181
|
+
traces.count.must_equal 4
|
182
|
+
traces[2]['KVOp'].must_equal "pexpireat"
|
183
|
+
traces[2]['KVKey'].must_equal "sand"
|
184
|
+
traces[2]['milliseconds'].must_equal 8000
|
185
|
+
end
|
186
|
+
|
187
|
+
it "should trace pttl" do
|
188
|
+
min_server_version(2.6)
|
189
|
+
|
190
|
+
@redis.setex("sand", 120, "blah")
|
191
|
+
|
192
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
193
|
+
@redis.pttl("sand")
|
194
|
+
end
|
195
|
+
|
196
|
+
traces = get_all_traces
|
197
|
+
traces.count.must_equal 4
|
198
|
+
traces[2]['KVOp'].must_equal "pttl"
|
199
|
+
traces[2]['KVKey'].must_equal "sand"
|
200
|
+
end
|
201
|
+
|
202
|
+
it "should trace randomkey" do
|
203
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
204
|
+
@redis.randomkey()
|
205
|
+
end
|
206
|
+
|
207
|
+
traces = get_all_traces
|
208
|
+
traces.count.must_equal 4
|
209
|
+
traces[2]['KVOp'].must_equal "randomkey"
|
210
|
+
end
|
211
|
+
|
212
|
+
it "should trace rename" do
|
213
|
+
@redis.setex("sand", 120, "blah")
|
214
|
+
|
215
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
216
|
+
@redis.rename("sand", "sandy")
|
217
|
+
end
|
218
|
+
|
219
|
+
traces = get_all_traces
|
220
|
+
traces.count.must_equal 4
|
221
|
+
traces[2]['KVOp'].must_equal "rename"
|
222
|
+
traces[2]['KVKey'].must_equal "sand"
|
223
|
+
traces[2]['newkey'].must_equal "sandy"
|
224
|
+
end
|
225
|
+
|
226
|
+
it "should trace renamenx" do
|
227
|
+
@redis.setex("sand", 120, "blah")
|
228
|
+
|
229
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
230
|
+
@redis.renamenx("sand", "sandy")
|
231
|
+
end
|
232
|
+
|
233
|
+
traces = get_all_traces
|
234
|
+
traces.count.must_equal 4
|
235
|
+
traces[2]['KVOp'].must_equal "renamenx"
|
236
|
+
traces[2]['KVKey'].must_equal "sand"
|
237
|
+
traces[2]['newkey'].must_equal "sandy"
|
238
|
+
end
|
239
|
+
|
240
|
+
it "should trace restore" do
|
241
|
+
min_server_version(2.6)
|
242
|
+
|
243
|
+
@redis.setex("qubit", 60, "zero")
|
244
|
+
x = @redis.dump("qubit")
|
245
|
+
@redis.del "blue"
|
246
|
+
|
247
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
248
|
+
@redis.restore("blue", 0, x)
|
249
|
+
end
|
250
|
+
|
251
|
+
traces = get_all_traces
|
252
|
+
traces.count.must_equal 4
|
253
|
+
traces[2]['KVOp'].must_equal "restore"
|
254
|
+
traces[2]['KVKey'].must_equal "blue"
|
255
|
+
traces[2]['ttl'].must_equal 0
|
256
|
+
end
|
257
|
+
|
258
|
+
it "should trace sort" do
|
259
|
+
min_server_version(2.2)
|
260
|
+
|
261
|
+
@redis.rpush("penguin", "one")
|
262
|
+
@redis.rpush("penguin", "two")
|
263
|
+
@redis.rpush("penguin", "three")
|
264
|
+
@redis.rpush("penguin", "four")
|
265
|
+
|
266
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
267
|
+
@redis.sort("penguin", :order => "desc alpha", :store => "target")
|
268
|
+
end
|
269
|
+
|
270
|
+
traces = get_all_traces
|
271
|
+
traces.count.must_equal 4
|
272
|
+
traces[2]['KVOp'].must_equal "sort"
|
273
|
+
traces[2]['KVKey'].must_equal "penguin"
|
274
|
+
end
|
275
|
+
|
276
|
+
it "should trace ttl" do
|
277
|
+
min_server_version(2.6)
|
278
|
+
|
279
|
+
@redis.setex("sand", 120, "blah")
|
280
|
+
|
281
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
282
|
+
@redis.ttl("sand")
|
283
|
+
end
|
284
|
+
|
285
|
+
traces = get_all_traces
|
286
|
+
traces.count.must_equal 4
|
287
|
+
traces[2]['KVOp'].must_equal "ttl"
|
288
|
+
traces[2]['KVKey'].must_equal "sand"
|
289
|
+
end
|
290
|
+
|
291
|
+
it "should trace type" do
|
292
|
+
min_server_version(2.6)
|
293
|
+
|
294
|
+
@redis.setex("sand", 120, "blah")
|
295
|
+
|
296
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
297
|
+
@redis.type("sand")
|
298
|
+
end
|
299
|
+
|
300
|
+
traces = get_all_traces
|
301
|
+
traces.count.must_equal 4
|
302
|
+
traces[2]['KVOp'].must_equal "type"
|
303
|
+
traces[2]['KVKey'].must_equal "sand"
|
304
|
+
end
|
305
|
+
|
306
|
+
it "should trace scan" do
|
307
|
+
min_server_version(2.8)
|
308
|
+
|
309
|
+
TraceView::API.start_trace('redis_test', '', {}) do
|
310
|
+
@redis.scan(0)
|
311
|
+
end
|
312
|
+
|
313
|
+
traces = get_all_traces
|
314
|
+
traces.count.must_equal 4
|
315
|
+
traces[2]['KVOp'].must_equal "scan"
|
316
|
+
end
|
317
|
+
end
|
318
|
+
|