traceview 3.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (137) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +10 -0
  3. data/.rubocop.yml +5 -0
  4. data/.travis.yml +58 -0
  5. data/Appraisals +10 -0
  6. data/CHANGELOG.md +490 -0
  7. data/CONFIG.md +16 -0
  8. data/Gemfile +95 -0
  9. data/LICENSE +199 -0
  10. data/README.md +380 -0
  11. data/Rakefile +109 -0
  12. data/examples/DNT.md +35 -0
  13. data/examples/carrying_context.rb +225 -0
  14. data/examples/instrumenting_metal_controller.rb +8 -0
  15. data/examples/puma_on_heroku_config.rb +17 -0
  16. data/examples/tracing_async_threads.rb +125 -0
  17. data/examples/tracing_background_jobs.rb +52 -0
  18. data/examples/tracing_forked_processes.rb +100 -0
  19. data/examples/unicorn_on_heroku_config.rb +28 -0
  20. data/ext/oboe_metal/extconf.rb +61 -0
  21. data/ext/oboe_metal/noop/noop.c +7 -0
  22. data/ext/oboe_metal/src/bson/bson.h +221 -0
  23. data/ext/oboe_metal/src/bson/platform_hacks.h +91 -0
  24. data/ext/oboe_metal/src/oboe.h +275 -0
  25. data/ext/oboe_metal/src/oboe.hpp +352 -0
  26. data/ext/oboe_metal/src/oboe_wrap.cxx +3886 -0
  27. data/ext/oboe_metal/tests/test.rb +11 -0
  28. data/gemfiles/mongo.gemfile +33 -0
  29. data/gemfiles/moped.gemfile +33 -0
  30. data/get_version.rb +5 -0
  31. data/init.rb +4 -0
  32. data/lib/joboe_metal.rb +206 -0
  33. data/lib/oboe.rb +7 -0
  34. data/lib/oboe/README +2 -0
  35. data/lib/oboe/backward_compatibility.rb +59 -0
  36. data/lib/oboe/inst/rack.rb +11 -0
  37. data/lib/oboe_metal.rb +151 -0
  38. data/lib/rails/generators/traceview/install_generator.rb +76 -0
  39. data/lib/rails/generators/traceview/templates/traceview_initializer.rb +159 -0
  40. data/lib/traceview.rb +62 -0
  41. data/lib/traceview/api.rb +18 -0
  42. data/lib/traceview/api/layerinit.rb +51 -0
  43. data/lib/traceview/api/logging.rb +209 -0
  44. data/lib/traceview/api/memcache.rb +31 -0
  45. data/lib/traceview/api/profiling.rb +50 -0
  46. data/lib/traceview/api/tracing.rb +135 -0
  47. data/lib/traceview/api/util.rb +121 -0
  48. data/lib/traceview/base.rb +225 -0
  49. data/lib/traceview/config.rb +238 -0
  50. data/lib/traceview/frameworks/grape.rb +97 -0
  51. data/lib/traceview/frameworks/padrino.rb +64 -0
  52. data/lib/traceview/frameworks/padrino/templates.rb +58 -0
  53. data/lib/traceview/frameworks/rails.rb +145 -0
  54. data/lib/traceview/frameworks/rails/helpers/rum/rum_ajax_header.js.erb +5 -0
  55. data/lib/traceview/frameworks/rails/helpers/rum/rum_footer.js.erb +1 -0
  56. data/lib/traceview/frameworks/rails/helpers/rum/rum_header.js.erb +3 -0
  57. data/lib/traceview/frameworks/rails/inst/action_controller.rb +216 -0
  58. data/lib/traceview/frameworks/rails/inst/action_view.rb +56 -0
  59. data/lib/traceview/frameworks/rails/inst/action_view_2x.rb +54 -0
  60. data/lib/traceview/frameworks/rails/inst/action_view_30.rb +48 -0
  61. data/lib/traceview/frameworks/rails/inst/active_record.rb +24 -0
  62. data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
  63. data/lib/traceview/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
  64. data/lib/traceview/frameworks/rails/inst/connection_adapters/oracle.rb +18 -0
  65. data/lib/traceview/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
  66. data/lib/traceview/frameworks/rails/inst/connection_adapters/utils.rb +117 -0
  67. data/lib/traceview/frameworks/sinatra.rb +95 -0
  68. data/lib/traceview/frameworks/sinatra/templates.rb +56 -0
  69. data/lib/traceview/inst/cassandra.rb +279 -0
  70. data/lib/traceview/inst/dalli.rb +86 -0
  71. data/lib/traceview/inst/em-http-request.rb +99 -0
  72. data/lib/traceview/inst/excon.rb +111 -0
  73. data/lib/traceview/inst/faraday.rb +73 -0
  74. data/lib/traceview/inst/http.rb +87 -0
  75. data/lib/traceview/inst/httpclient.rb +173 -0
  76. data/lib/traceview/inst/memcache.rb +102 -0
  77. data/lib/traceview/inst/memcached.rb +94 -0
  78. data/lib/traceview/inst/mongo.rb +238 -0
  79. data/lib/traceview/inst/moped.rb +474 -0
  80. data/lib/traceview/inst/rack.rb +122 -0
  81. data/lib/traceview/inst/redis.rb +271 -0
  82. data/lib/traceview/inst/resque.rb +192 -0
  83. data/lib/traceview/inst/rest-client.rb +38 -0
  84. data/lib/traceview/inst/sequel.rb +162 -0
  85. data/lib/traceview/inst/typhoeus.rb +102 -0
  86. data/lib/traceview/instrumentation.rb +21 -0
  87. data/lib/traceview/loading.rb +94 -0
  88. data/lib/traceview/logger.rb +41 -0
  89. data/lib/traceview/method_profiling.rb +84 -0
  90. data/lib/traceview/ruby.rb +36 -0
  91. data/lib/traceview/support.rb +113 -0
  92. data/lib/traceview/thread_local.rb +26 -0
  93. data/lib/traceview/util.rb +250 -0
  94. data/lib/traceview/version.rb +16 -0
  95. data/lib/traceview/xtrace.rb +90 -0
  96. data/test/frameworks/apps/grape_nested.rb +30 -0
  97. data/test/frameworks/apps/grape_simple.rb +24 -0
  98. data/test/frameworks/apps/padrino_simple.rb +45 -0
  99. data/test/frameworks/apps/sinatra_simple.rb +24 -0
  100. data/test/frameworks/grape_test.rb +142 -0
  101. data/test/frameworks/padrino_test.rb +30 -0
  102. data/test/frameworks/sinatra_test.rb +30 -0
  103. data/test/instrumentation/cassandra_test.rb +380 -0
  104. data/test/instrumentation/dalli_test.rb +171 -0
  105. data/test/instrumentation/em_http_request_test.rb +86 -0
  106. data/test/instrumentation/excon_test.rb +207 -0
  107. data/test/instrumentation/faraday_test.rb +235 -0
  108. data/test/instrumentation/http_test.rb +140 -0
  109. data/test/instrumentation/httpclient_test.rb +296 -0
  110. data/test/instrumentation/memcache_test.rb +251 -0
  111. data/test/instrumentation/memcached_test.rb +226 -0
  112. data/test/instrumentation/mongo_test.rb +462 -0
  113. data/test/instrumentation/moped_test.rb +496 -0
  114. data/test/instrumentation/rack_test.rb +116 -0
  115. data/test/instrumentation/redis_hashes_test.rb +265 -0
  116. data/test/instrumentation/redis_keys_test.rb +318 -0
  117. data/test/instrumentation/redis_lists_test.rb +310 -0
  118. data/test/instrumentation/redis_misc_test.rb +160 -0
  119. data/test/instrumentation/redis_sets_test.rb +293 -0
  120. data/test/instrumentation/redis_sortedsets_test.rb +325 -0
  121. data/test/instrumentation/redis_strings_test.rb +333 -0
  122. data/test/instrumentation/resque_test.rb +62 -0
  123. data/test/instrumentation/rest-client_test.rb +294 -0
  124. data/test/instrumentation/sequel_mysql2_test.rb +326 -0
  125. data/test/instrumentation/sequel_mysql_test.rb +326 -0
  126. data/test/instrumentation/sequel_pg_test.rb +330 -0
  127. data/test/instrumentation/typhoeus_test.rb +285 -0
  128. data/test/minitest_helper.rb +187 -0
  129. data/test/profiling/method_test.rb +198 -0
  130. data/test/servers/rackapp_8101.rb +22 -0
  131. data/test/support/backcompat_test.rb +269 -0
  132. data/test/support/config_test.rb +128 -0
  133. data/test/support/dnt_test.rb +73 -0
  134. data/test/support/liboboe_settings_test.rb +104 -0
  135. data/test/support/xtrace_test.rb +35 -0
  136. data/traceview.gemspec +29 -0
  137. metadata +250 -0
@@ -0,0 +1,310 @@
1
+ require 'minitest_helper'
2
+ require "redis"
3
+
4
+ describe "Redis Lists" 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 blpop" do
30
+ min_server_version(2.0)
31
+
32
+ @redis.lpush("savage", "zombie")
33
+
34
+ TraceView::API.start_trace('redis_test', '', {}) do
35
+ @redis.blpop("savage")
36
+ end
37
+
38
+ traces = get_all_traces
39
+ traces.count.must_equal 4
40
+ traces[2]['KVOp'].must_equal "blpop"
41
+ traces[2]['KVKey'].must_equal "savage"
42
+ end
43
+
44
+ it "should trace brpop" do
45
+ min_server_version(2.0)
46
+
47
+ @redis.lpush("savage", "the walking dead")
48
+
49
+ TraceView::API.start_trace('redis_test', '', {}) do
50
+ @redis.brpop("savage")
51
+ end
52
+
53
+ traces = get_all_traces
54
+ traces.count.must_equal 4
55
+ traces[2]['KVOp'].must_equal "brpop"
56
+ traces[2]['KVKey'].must_equal "savage"
57
+ end
58
+
59
+ it "should trace brpoplpush" do
60
+ min_server_version(2.2)
61
+
62
+ @redis.lpush("savage", "night of the walking dead")
63
+
64
+ TraceView::API.start_trace('redis_test', '', {}) do
65
+ @redis.brpoplpush("savage", "crawlies")
66
+ end
67
+
68
+ traces = get_all_traces
69
+ traces.count.must_equal 4
70
+ traces[2]['KVOp'].must_equal "brpoplpush"
71
+ traces[2]['destination'].must_equal "crawlies"
72
+ end
73
+
74
+ it "should trace lindex" do
75
+ min_server_version(1.0)
76
+
77
+ @redis.lpush("fringe", "bishop")
78
+ @redis.lpush("fringe", "dunham")
79
+ @redis.lpush("fringe", "broyles")
80
+
81
+ TraceView::API.start_trace('redis_test', '', {}) do
82
+ @redis.lindex("fringe", 1)
83
+ end
84
+
85
+ traces = get_all_traces
86
+ traces.count.must_equal 4
87
+ traces[2]['KVOp'].must_equal "lindex"
88
+ traces[2]['index'].must_equal 1
89
+ end
90
+
91
+ it "should trace linsert" do
92
+ min_server_version(2.2)
93
+
94
+ @redis.lpush("gods of old", "sun")
95
+ @redis.lpush("gods of old", "moon")
96
+ @redis.lpush("gods of old", "night")
97
+
98
+ TraceView::API.start_trace('redis_test', '', {}) do
99
+ @redis.linsert("gods of old", "BEFORE", "night", "river")
100
+ end
101
+
102
+ traces = get_all_traces
103
+ traces.count.must_equal 4
104
+ traces[2]['KVOp'].must_equal "linsert"
105
+ traces[2]['KVKey'].must_equal "gods of old"
106
+ end
107
+
108
+ it "should trace llen" do
109
+ min_server_version(1.0)
110
+
111
+ @redis.lpush("gods of old", "sun")
112
+ @redis.lpush("gods of old", "moon")
113
+ @redis.lpush("gods of old", "night")
114
+
115
+ TraceView::API.start_trace('redis_test', '', {}) do
116
+ @redis.llen("gods of old")
117
+ end
118
+
119
+ traces = get_all_traces
120
+ traces.count.must_equal 4
121
+ traces[2]['KVOp'].must_equal "llen"
122
+ traces[2]['KVKey'].must_equal "gods of old"
123
+ end
124
+
125
+ it "should trace lpop" do
126
+ min_server_version(1.0)
127
+
128
+ @redis.lpush("gods of old", "sun")
129
+ @redis.lpush("gods of old", "moon")
130
+ @redis.lpush("gods of old", "night")
131
+
132
+ TraceView::API.start_trace('redis_test', '', {}) do
133
+ @redis.lpop("gods of old")
134
+ end
135
+
136
+ traces = get_all_traces
137
+ traces.count.must_equal 4
138
+ traces[2]['KVOp'].must_equal "lpop"
139
+ traces[2]['KVKey'].must_equal "gods of old"
140
+ end
141
+
142
+ it "should trace lpush" do
143
+ min_server_version(1.0)
144
+
145
+ TraceView::API.start_trace('redis_test', '', {}) do
146
+ @redis.lpush("gods of old", "night")
147
+ end
148
+
149
+ traces = get_all_traces
150
+ traces.count.must_equal 4
151
+ traces[2]['KVOp'].must_equal "lpush"
152
+ traces[2]['KVKey'].must_equal "gods of old"
153
+ end
154
+
155
+ it "should trace lpushx" do
156
+ min_server_version(2.2)
157
+
158
+ TraceView::API.start_trace('redis_test', '', {}) do
159
+ @redis.lpushx("gods of old", "night")
160
+ end
161
+
162
+ traces = get_all_traces
163
+ traces.count.must_equal 4
164
+ traces[2]['KVOp'].must_equal "lpushx"
165
+ traces[2]['KVKey'].must_equal "gods of old"
166
+ end
167
+
168
+ it "should trace lrange" do
169
+ min_server_version(1.0)
170
+
171
+ @redis.rpush("protein types", "structural")
172
+ @redis.rpush("protein types", "storage")
173
+ @redis.rpush("protein types", "hormonal")
174
+ @redis.rpush("protein types", "enzyme")
175
+ @redis.rpush("protein types", "immunoglobulins")
176
+
177
+ TraceView::API.start_trace('redis_test', '', {}) do
178
+ @redis.lrange("protein types", 2, 4)
179
+ end
180
+
181
+ traces = get_all_traces
182
+ traces.count.must_equal 4
183
+ traces[2]['KVOp'].must_equal "lrange"
184
+ traces[2]['KVKey'].must_equal "protein types"
185
+ traces[2]['start'].must_equal 2
186
+ traces[2]['stop'].must_equal 4
187
+ end
188
+
189
+ it "should trace lrem" do
190
+ min_server_version(1.0)
191
+
192
+ @redis.rpush("australia", "sydney")
193
+ @redis.rpush("australia", "sydney")
194
+ @redis.rpush("australia", "albury")
195
+ @redis.rpush("australia", "tamworth")
196
+ @redis.rpush("australia", "tamworth")
197
+ @redis.rpush("australia", "penrith")
198
+
199
+ TraceView::API.start_trace('redis_test', '', {}) do
200
+ @redis.lrem("australia", -2, "sydney")
201
+ end
202
+
203
+ traces = get_all_traces
204
+ traces.count.must_equal 4
205
+ traces[2]['KVOp'].must_equal "lrem"
206
+ traces[2]['KVKey'].must_equal "australia"
207
+ end
208
+
209
+ it "should trace lset" do
210
+ min_server_version(1.0)
211
+
212
+ @redis.rpush("australia", "sydney")
213
+ @redis.rpush("australia", "albury")
214
+ @redis.rpush("australia", "tamworth")
215
+ @redis.rpush("australia", "penrith")
216
+
217
+ TraceView::API.start_trace('redis_test', '', {}) do
218
+ @redis.lset("australia", 2, "Kalgoorlie")
219
+ end
220
+
221
+ traces = get_all_traces
222
+ traces.count.must_equal 4
223
+ traces[2]['KVOp'].must_equal "lset"
224
+ traces[2]['KVKey'].must_equal "australia"
225
+ end
226
+
227
+ it "should trace ltrim" do
228
+ min_server_version(1.0)
229
+
230
+ @redis.rpush("australia", "sydney")
231
+ @redis.rpush("australia", "albury")
232
+ @redis.rpush("australia", "tamworth")
233
+ @redis.rpush("australia", "albury")
234
+ @redis.rpush("australia", "tamworth")
235
+ @redis.rpush("australia", "albury")
236
+ @redis.rpush("australia", "tamworth")
237
+ @redis.rpush("australia", "penrith")
238
+
239
+ TraceView::API.start_trace('redis_test', '', {}) do
240
+ @redis.ltrim("australia", 2, 6)
241
+ end
242
+
243
+ traces = get_all_traces
244
+ traces.count.must_equal 4
245
+ traces[2]['KVOp'].must_equal "ltrim"
246
+ traces[2]['KVKey'].must_equal "australia"
247
+ end
248
+
249
+ it "should trace rpop" do
250
+ min_server_version(1.0)
251
+
252
+ @redis.rpush("santa esmeralda", "house of the rising sun")
253
+ @redis.rpush("santa esmeralda", "don't let me be misunderstood")
254
+ @redis.rpush("santa esmeralda", "sevilla nights")
255
+
256
+ TraceView::API.start_trace('redis_test', '', {}) do
257
+ @redis.rpop("santa esmeralda")
258
+ end
259
+
260
+ traces = get_all_traces
261
+ traces.count.must_equal 4
262
+ traces[2]['KVOp'].must_equal "rpop"
263
+ traces[2]['KVKey'].must_equal "santa esmeralda"
264
+ end
265
+
266
+ it "should trace rpoplpush" do
267
+ min_server_version(1.2)
268
+
269
+ @redis.rpush("santa esmeralda", "house of the rising sun")
270
+ @redis.rpush("santa esmeralda", "don't let me be misunderstood")
271
+ @redis.rpush("santa esmeralda", "sevilla nights")
272
+
273
+ TraceView::API.start_trace('redis_test', '', {}) do
274
+ @redis.rpoplpush("santa esmeralda", "the gods of old")
275
+ end
276
+
277
+ traces = get_all_traces
278
+ traces.count.must_equal 4
279
+ traces[2]['KVOp'].must_equal "rpoplpush"
280
+ traces[2]['KVKey'].must_equal "santa esmeralda"
281
+ traces[2]['destination'].must_equal "the gods of old"
282
+ end
283
+
284
+ it "should trace rpush" do
285
+ min_server_version(1.0)
286
+
287
+ TraceView::API.start_trace('redis_test', '', {}) do
288
+ @redis.rpush("boney m", "rasputin")
289
+ end
290
+
291
+ traces = get_all_traces
292
+ traces.count.must_equal 4
293
+ traces[2]['KVOp'].must_equal "rpush"
294
+ traces[2]['KVKey'].must_equal "boney m"
295
+ end
296
+
297
+ it "should trace rpushx" do
298
+ min_server_version(1.0)
299
+
300
+ TraceView::API.start_trace('redis_test', '', {}) do
301
+ @redis.rpushx("boney m", "rasputin")
302
+ end
303
+
304
+ traces = get_all_traces
305
+ traces.count.must_equal 4
306
+ traces[2]['KVOp'].must_equal "rpushx"
307
+ traces[2]['KVKey'].must_equal "boney m"
308
+ end
309
+ end
310
+
@@ -0,0 +1,160 @@
1
+ require 'minitest_helper'
2
+ require "redis"
3
+
4
+ describe "Redis Misc" 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 "should trace publish" do
26
+ min_server_version(2.0)
27
+
28
+ TraceView::API.start_trace('redis_test', '', {}) do
29
+ @redis.publish("channel1", "Broadcasting live from silicon circuits.")
30
+ end
31
+
32
+ traces = get_all_traces
33
+ traces.count.must_equal 4
34
+ traces[2]['KVOp'].must_equal "publish"
35
+ traces[2]['channel'].must_equal "channel1"
36
+ traces[2].has_key?('KVKey').must_equal false
37
+ end
38
+
39
+ it "should trace select" do
40
+ min_server_version(2.0)
41
+
42
+ TraceView::API.start_trace('redis_test', '', {}) do
43
+ @redis.select(2)
44
+ end
45
+
46
+ traces = get_all_traces
47
+ traces.count.must_equal 4
48
+ traces[2]['KVOp'].must_equal "select"
49
+ traces[2]['db'].must_equal 2
50
+ end
51
+
52
+ it "should trace pipelined operations" do
53
+ min_server_version(1.2)
54
+
55
+ TraceView::API.start_trace('redis_test', '', {}) do
56
+ @redis.pipelined do
57
+ @redis.zadd("staff", 0, "waiter")
58
+ @redis.zadd("staff", 1, "busser")
59
+ @redis.zadd("staff", 2, "chef")
60
+
61
+ @redis.lpush("fringe", "bishop")
62
+ @redis.lpush("fringe", "dunham")
63
+ @redis.lpush("fringe", "broyles")
64
+ end
65
+ end
66
+
67
+ traces = get_all_traces
68
+ traces.count.must_equal 4
69
+ traces[2]['KVOpCount'].must_equal 6
70
+ traces[2]['KVOps'].must_equal "zadd, zadd, zadd, lpush, lpush, lpush"
71
+ end
72
+
73
+ it "should trace multi with block" do
74
+ min_server_version(1.2)
75
+
76
+ TraceView::API.start_trace('redis_test', '', {}) do
77
+ @redis.multi do
78
+ @redis.zadd("presidents", 0, "Lincoln")
79
+ @redis.zadd("presidents", 1, "Adams")
80
+ @redis.zadd("presidents", 2, "Reagan")
81
+
82
+ @redis.lpush("hair", "blue")
83
+ @redis.lpush("hair", "gray")
84
+ @redis.lpush("hair", "yellow")
85
+ end
86
+ end
87
+
88
+ traces = get_all_traces
89
+ traces.count.must_equal 4
90
+ traces[2]['KVOpCount'].must_equal 8
91
+ traces[2]['KVOps'].must_equal "multi, zadd, zadd, zadd, lpush, lpush, lpush, exec"
92
+ end
93
+
94
+ it "should trace eval" do
95
+ min_server_version(2.6)
96
+
97
+ TraceView::API.start_trace('redis_test', '', {}) do
98
+ @redis.eval("return 1")
99
+ @redis.eval("return { KEYS, ARGV }", ["k1", "k2"], ["a1", "a2"])
100
+ @redis.eval("return { KEYS, ARGV }", :keys => ["k1", "k2"], :argv => ["a1", "a2"])
101
+ end
102
+
103
+ traces = get_all_traces
104
+ traces.count.must_equal 8
105
+ traces[2]['KVOp'].must_equal "eval"
106
+ traces[2]['Script'].must_equal "return 1"
107
+ traces[4]['KVOp'].must_equal "eval"
108
+ traces[4]['Script'].must_equal "return { KEYS, ARGV }"
109
+ traces[6]['KVOp'].must_equal "eval"
110
+ traces[6]['Script'].must_equal "return { KEYS, ARGV }"
111
+ end
112
+
113
+ it "should trace evalsha" do
114
+ min_server_version(2.6)
115
+
116
+ sha = @redis.script(:load, "return 1")
117
+
118
+ TraceView::API.start_trace('redis_test', '', {}) do
119
+ @redis.evalsha(sha)
120
+ end
121
+
122
+ traces = get_all_traces
123
+ traces.count.must_equal 4
124
+ traces[2]['KVOp'].must_equal "evalsha"
125
+ traces[2]['sha'].must_equal sha
126
+ end
127
+
128
+ it "should trace script" do
129
+ min_server_version(2.6)
130
+
131
+ TraceView::API.start_trace('redis_test', '', {}) do
132
+ @sha = @redis.script(:load, "return 1")
133
+ @it_exists1 = @redis.script(:exists, @sha)
134
+ @it_exists2 = @redis.script(:exists, [@sha, "other_sha"])
135
+ @redis.script(:flush)
136
+ end
137
+
138
+ traces = get_all_traces
139
+ traces.count.must_equal 10
140
+
141
+ # Validate return values
142
+ @it_exists1.must_equal true
143
+ @it_exists2.is_a?(Array).must_equal true
144
+ @it_exists2[0].must_equal true
145
+ @it_exists2[1].must_equal false
146
+
147
+ traces[2]['KVOp'].must_equal "script"
148
+ traces[2]['subcommand'].must_equal "load"
149
+ traces[2]['Script'].must_equal "return 1"
150
+ traces[4]['KVOp'].must_equal "script"
151
+ traces[4]['subcommand'].must_equal "exists"
152
+ traces[4]['KVKey'].must_equal @sha
153
+ traces[6]['KVOp'].must_equal "script"
154
+ traces[6]['subcommand'].must_equal "exists"
155
+ traces[6]['KVKey'].must_equal '["e0e1f9fabfc9d4800c877a703b823ac0578ff8db", "other_sha"]'
156
+ traces[8]['KVOp'].must_equal "script"
157
+ traces[8]['subcommand'].must_equal "flush"
158
+ end
159
+ end
160
+