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,73 @@
1
+ require 'minitest_helper'
2
+ require 'rack/test'
3
+ require 'rack/lobster'
4
+ require 'oboe/inst/rack'
5
+
6
+ class RackTestApp < Minitest::Test
7
+ include Rack::Test::Methods
8
+
9
+ def app
10
+ @app = Rack::Builder.new {
11
+ use Rack::CommonLogger
12
+ use Rack::ShowExceptions
13
+ use Oboe::Rack
14
+ map "/lobster" do
15
+ use Rack::Lint
16
+ run Rack::Lobster.new
17
+ end
18
+ }
19
+ end
20
+
21
+ def test_get_the_lobster
22
+ clear_all_traces
23
+
24
+ get "/lobster"
25
+
26
+ traces = get_all_traces
27
+ traces.count.must_equal 3
28
+
29
+ validate_outer_layers(traces, 'rack')
30
+
31
+ kvs = {}
32
+ kvs["Label"] = "entry"
33
+ validate_event_keys(traces[0], kvs)
34
+
35
+ kvs.clear
36
+ kvs["Label"] = "info"
37
+ kvs["Status"] = "200"
38
+ kvs["HTTP-Host"] = "example.org"
39
+ kvs["Port"] = "80"
40
+ kvs["Proto"] = "http"
41
+ kvs["URL"] = "/lobster"
42
+ kvs["Method"] = "GET"
43
+ kvs["ClientIP"] = "127.0.0.1"
44
+ validate_event_keys(traces[1], kvs)
45
+
46
+ assert traces[0].has_key?('SampleRate')
47
+ assert traces[0].has_key?('SampleSource')
48
+
49
+ assert last_response.ok?
50
+
51
+ assert last_response['X-Trace']
52
+ end
53
+
54
+ def test_dont_trace_static_assets
55
+ clear_all_traces
56
+
57
+ get "/assets/static_asset.png"
58
+
59
+ traces = get_all_traces
60
+ assert traces.empty?
61
+
62
+ assert last_response.status == 404
63
+ end
64
+
65
+ def test_must_return_xtrace_header
66
+ clear_all_traces
67
+ get "/lobster"
68
+ xtrace = last_response['X-Trace']
69
+ assert xtrace
70
+ assert Oboe::XTrace.valid?(xtrace)
71
+ end
72
+ end
73
+
@@ -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
+