oboe 2.4.0.1 → 2.5.0.7
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.
- checksums.yaml +4 -4
- data/.travis.yml +2 -0
- data/{CHANGELOG → CHANGELOG.md} +9 -0
- data/Gemfile +2 -1
- data/README.md +20 -5
- data/lib/base.rb +5 -5
- data/lib/joboe_metal.rb +5 -1
- data/lib/oboe.rb +7 -4
- data/lib/oboe/api/layerinit.rb +24 -1
- data/lib/oboe/config.rb +5 -1
- data/lib/oboe/frameworks/rails.rb +2 -0
- data/lib/oboe/inst/rack.rb +1 -1
- data/lib/oboe/inst/redis.rb +273 -0
- data/lib/oboe/version.rb +2 -2
- data/lib/oboe/xtrace.rb +4 -7
- data/lib/oboe_metal.rb +5 -1
- data/lib/rails/generators/oboe/templates/oboe_initializer.rb +2 -0
- data/test/frameworks/apps/padrino_simple.rb +37 -0
- data/test/frameworks/test_padrino.rb +32 -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/minitest_helper.rb +1 -2
- metadata +23 -3
data/lib/oboe/version.rb
CHANGED
data/lib/oboe/xtrace.rb
CHANGED
|
@@ -12,16 +12,13 @@ module Oboe
|
|
|
12
12
|
#
|
|
13
13
|
def valid?(xtrace)
|
|
14
14
|
begin
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
# The X-Trace ID shouldn't be an initialized empty ID
|
|
16
|
+
return false if (xtrace =~ /^1b0000000/i) == 0
|
|
17
17
|
|
|
18
18
|
# Valid X-Trace IDs have a length of 58 bytes and start with '1b'
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
# The X-Trace ID shouldn't be an initialized empty ID
|
|
22
|
-
valid = false if (xtrace =~ /^1b0000000/i) == 0
|
|
19
|
+
return false unless xtrace.length == 58 and (xtrace =~ /^1b/i) == 0
|
|
23
20
|
|
|
24
|
-
|
|
21
|
+
true
|
|
25
22
|
rescue StandardError => e
|
|
26
23
|
Oboe.logger.debug e.message
|
|
27
24
|
Oboe.logger.debug e.backtrace
|
data/lib/oboe_metal.rb
CHANGED
|
@@ -52,7 +52,11 @@ module Oboe_metal
|
|
|
52
52
|
Oboe.reporter = Oboe::UdpReporter.new(Oboe::Config[:reporter_host])
|
|
53
53
|
end
|
|
54
54
|
|
|
55
|
-
|
|
55
|
+
# Only report __Init from here if we are not instrumenting a framework.
|
|
56
|
+
# Otherwise, frameworks will handle reporting __Init after full initialization
|
|
57
|
+
unless defined?(::Rails) or defined?(::Sinatra) or defined?(::Padrino)
|
|
58
|
+
Oboe::API.report_init('rack') unless ["development", "test"].include? ENV['RACK_ENV']
|
|
59
|
+
end
|
|
56
60
|
|
|
57
61
|
rescue Exception => e
|
|
58
62
|
$stderr.puts e.message
|
|
@@ -57,6 +57,7 @@ if defined?(Oboe::Config)
|
|
|
57
57
|
# Oboe::Config[:mongo][:enabled] = true
|
|
58
58
|
# Oboe::Config[:moped][:enabled] = true
|
|
59
59
|
# Oboe::Config[:nethttp][:enabled] = true
|
|
60
|
+
# Oboe::Config[:redis][:enabled] = true
|
|
60
61
|
# Oboe::Config[:resque][:enabled] = true
|
|
61
62
|
|
|
62
63
|
#
|
|
@@ -77,6 +78,7 @@ if defined?(Oboe::Config)
|
|
|
77
78
|
# Oboe::Config[:mongo][:collect_backtraces] = true
|
|
78
79
|
# Oboe::Config[:moped][:collect_backtraces] = true
|
|
79
80
|
# Oboe::Config[:nethttp][:collect_backtraces] = true
|
|
81
|
+
# Oboe::Config[:redis][:collect_backtraces] = false
|
|
80
82
|
# Oboe::Config[:resque][:collect_backtraces] = true
|
|
81
83
|
#
|
|
82
84
|
|
|
@@ -0,0 +1,37 @@
|
|
|
1
|
+
PADRINO_ROOT = File.dirname(__FILE__) unless defined? PADRINO_ROOT
|
|
2
|
+
# Remove this comment if you want do some like this: ruby PADRINO_ENV=test app.rb
|
|
3
|
+
#
|
|
4
|
+
# require 'rubygems'
|
|
5
|
+
# require 'padrino-core'
|
|
6
|
+
#
|
|
7
|
+
|
|
8
|
+
class SimpleDemo < Padrino::Application
|
|
9
|
+
set :reload, true
|
|
10
|
+
before { true }
|
|
11
|
+
after { true }
|
|
12
|
+
error(404) { "404" }
|
|
13
|
+
end
|
|
14
|
+
|
|
15
|
+
SimpleDemo.controllers do
|
|
16
|
+
get "/" do
|
|
17
|
+
'The magick number is: 2767356926488785838763860464013972991031534522105386787489885890443740254365!' # Change only the number!!!
|
|
18
|
+
end
|
|
19
|
+
|
|
20
|
+
get "/rand" do
|
|
21
|
+
rand(2 ** 256).to_s
|
|
22
|
+
end
|
|
23
|
+
|
|
24
|
+
get "/render" do
|
|
25
|
+
render :erb, "This is an erb render"
|
|
26
|
+
end
|
|
27
|
+
end
|
|
28
|
+
|
|
29
|
+
## If you want use this as a standalone app uncomment:
|
|
30
|
+
#
|
|
31
|
+
# Padrino.mount("SimpleDemo").to("/")
|
|
32
|
+
# Padrino.run! unless Padrino.loaded? # If you enable reloader prevent to re-run the app
|
|
33
|
+
#
|
|
34
|
+
# Then run it from your console: ruby -I"lib" test/fixtures/apps/simple.rb
|
|
35
|
+
#
|
|
36
|
+
|
|
37
|
+
Padrino.load!
|
|
@@ -0,0 +1,32 @@
|
|
|
1
|
+
require "minitest_helper"
|
|
2
|
+
|
|
3
|
+
describe Padrino do
|
|
4
|
+
before do
|
|
5
|
+
clear_all_traces
|
|
6
|
+
end
|
|
7
|
+
|
|
8
|
+
it "should do this" do
|
|
9
|
+
|
|
10
|
+
mock_app do
|
|
11
|
+
get("/") { render :erb, "ok" }
|
|
12
|
+
end
|
|
13
|
+
debugger
|
|
14
|
+
r = get "/"
|
|
15
|
+
|
|
16
|
+
traces = get_all_traces
|
|
17
|
+
traces.count.must_equal 5
|
|
18
|
+
|
|
19
|
+
validate_outer_layers(traces, 'dalli_test')
|
|
20
|
+
|
|
21
|
+
traces[1].has_key?("KVOp").must_equal true
|
|
22
|
+
traces[1].has_key?("KVKey").must_equal true
|
|
23
|
+
traces[1]['Layer'].must_equal "memcache"
|
|
24
|
+
traces[1]['KVKey'].must_equal "some_key"
|
|
25
|
+
|
|
26
|
+
traces[2]['Layer'].must_equal "memcache"
|
|
27
|
+
traces[2]['Label'].must_equal "info"
|
|
28
|
+
traces[2].has_key?('KVHit')
|
|
29
|
+
|
|
30
|
+
end
|
|
31
|
+
end
|
|
32
|
+
|
|
@@ -0,0 +1,265 @@
|
|
|
1
|
+
require 'minitest_helper'
|
|
2
|
+
require "redis"
|
|
3
|
+
|
|
4
|
+
describe Oboe::Inst::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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 Oboe::Inst::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
Oboe::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
|
+
|