appoptics_apm 4.0.2
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/.codeclimate.yml +43 -0
- data/.dockerignore +5 -0
- data/.gitignore +23 -0
- data/.rubocop.yml +5 -0
- data/.travis.yml +82 -0
- data/CHANGELOG.md +769 -0
- data/CONFIG.md +33 -0
- data/Dockerfile +41 -0
- data/Dockerfile_test +66 -0
- data/Gemfile +41 -0
- data/LICENSE +193 -0
- data/README.md +351 -0
- data/Rakefile +202 -0
- data/Vagrantfile +67 -0
- data/appoptics_apm.gemspec +55 -0
- data/build_gems.sh +15 -0
- data/docker-compose.yml +73 -0
- data/examples/DNT.md +35 -0
- data/examples/carrying_context.rb +220 -0
- data/examples/instrumenting_metal_controller.rb +8 -0
- data/examples/puma_on_heroku_config.rb +17 -0
- data/examples/tracing_async_threads.rb +124 -0
- data/examples/tracing_background_jobs.rb +53 -0
- data/examples/tracing_forked_processes.rb +99 -0
- data/examples/unicorn_on_heroku_config.rb +28 -0
- data/ext/oboe_metal/extconf.rb +54 -0
- data/ext/oboe_metal/lib/.keep +0 -0
- data/ext/oboe_metal/lib/liboboe-1.0.so.0.0.0 +0 -0
- data/ext/oboe_metal/noop/noop.c +7 -0
- data/ext/oboe_metal/src/VERSION +1 -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 +883 -0
- data/ext/oboe_metal/src/oboe.hpp +793 -0
- data/ext/oboe_metal/src/oboe_debug.h +50 -0
- data/ext/oboe_metal/src/oboe_wrap.cxx +6088 -0
- data/ext/oboe_metal/tests/test.rb +11 -0
- data/gemfiles/delayed_job.gemfile +36 -0
- data/gemfiles/frameworks.gemfile +44 -0
- data/gemfiles/instrumentation_mocked.gemfile +29 -0
- data/gemfiles/libraries.gemfile +85 -0
- data/gemfiles/rails23.gemfile +39 -0
- data/gemfiles/rails30.gemfile +42 -0
- data/gemfiles/rails31.gemfile +44 -0
- data/gemfiles/rails32.gemfile +54 -0
- data/gemfiles/rails40.gemfile +27 -0
- data/gemfiles/rails41.gemfile +27 -0
- data/gemfiles/rails42.gemfile +35 -0
- data/gemfiles/rails50.gemfile +44 -0
- data/gemfiles/rails51.gemfile +44 -0
- data/get_version.rb +5 -0
- data/init.rb +4 -0
- data/lib/appoptics_apm/api/layerinit.rb +39 -0
- data/lib/appoptics_apm/api/logging.rb +359 -0
- data/lib/appoptics_apm/api/memcache.rb +34 -0
- data/lib/appoptics_apm/api/profiling.rb +201 -0
- data/lib/appoptics_apm/api/tracing.rb +152 -0
- data/lib/appoptics_apm/api/util.rb +128 -0
- data/lib/appoptics_apm/api.rb +18 -0
- data/lib/appoptics_apm/base.rb +252 -0
- data/lib/appoptics_apm/config.rb +281 -0
- data/lib/appoptics_apm/frameworks/grape.rb +93 -0
- data/lib/appoptics_apm/frameworks/padrino/templates.rb +58 -0
- data/lib/appoptics_apm/frameworks/padrino.rb +52 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller.rb +106 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller2.rb +61 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller3.rb +58 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller4.rb +48 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller5.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_controller_api.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view.rb +58 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view_2x.rb +56 -0
- data/lib/appoptics_apm/frameworks/rails/inst/action_view_30.rb +50 -0
- data/lib/appoptics_apm/frameworks/rails/inst/active_record.rb +27 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql.rb +43 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/mysql2.rb +28 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/postgresql.rb +30 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +120 -0
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +101 -0
- data/lib/appoptics_apm/frameworks/rails.rb +116 -0
- data/lib/appoptics_apm/frameworks/sinatra/templates.rb +56 -0
- data/lib/appoptics_apm/frameworks/sinatra.rb +71 -0
- data/lib/appoptics_apm/inst/bunny-client.rb +148 -0
- data/lib/appoptics_apm/inst/bunny-consumer.rb +92 -0
- data/lib/appoptics_apm/inst/curb.rb +329 -0
- data/lib/appoptics_apm/inst/dalli.rb +85 -0
- data/lib/appoptics_apm/inst/delayed_job.rb +92 -0
- data/lib/appoptics_apm/inst/em-http-request.rb +105 -0
- data/lib/appoptics_apm/inst/excon.rb +130 -0
- data/lib/appoptics_apm/inst/faraday.rb +77 -0
- data/lib/appoptics_apm/inst/http.rb +83 -0
- data/lib/appoptics_apm/inst/httpclient.rb +176 -0
- data/lib/appoptics_apm/inst/memcache.rb +102 -0
- data/lib/appoptics_apm/inst/memcached.rb +94 -0
- data/lib/appoptics_apm/inst/mongo.rb +242 -0
- data/lib/appoptics_apm/inst/mongo2.rb +225 -0
- data/lib/appoptics_apm/inst/moped.rb +466 -0
- data/lib/appoptics_apm/inst/rack.rb +146 -0
- data/lib/appoptics_apm/inst/redis.rb +275 -0
- data/lib/appoptics_apm/inst/resque.rb +151 -0
- data/lib/appoptics_apm/inst/rest-client.rb +50 -0
- data/lib/appoptics_apm/inst/sequel.rb +178 -0
- data/lib/appoptics_apm/inst/sidekiq-client.rb +53 -0
- data/lib/appoptics_apm/inst/sidekiq-worker.rb +67 -0
- data/lib/appoptics_apm/inst/twitter-cassandra.rb +294 -0
- data/lib/appoptics_apm/inst/typhoeus.rb +113 -0
- data/lib/appoptics_apm/instrumentation.rb +22 -0
- data/lib/appoptics_apm/legacy_method_profiling.rb +97 -0
- data/lib/appoptics_apm/loading.rb +66 -0
- data/lib/appoptics_apm/logger.rb +41 -0
- data/lib/appoptics_apm/method_profiling.rb +33 -0
- data/lib/appoptics_apm/ruby.rb +35 -0
- data/lib/appoptics_apm/support.rb +135 -0
- data/lib/appoptics_apm/test.rb +94 -0
- data/lib/appoptics_apm/thread_local.rb +26 -0
- data/lib/appoptics_apm/util.rb +312 -0
- data/lib/appoptics_apm/version.rb +15 -0
- data/lib/appoptics_apm/xtrace.rb +103 -0
- data/lib/appoptics_apm.rb +72 -0
- data/lib/joboe_metal.rb +214 -0
- data/lib/oboe/README +2 -0
- data/lib/oboe/backward_compatibility.rb +80 -0
- data/lib/oboe/inst/rack.rb +11 -0
- data/lib/oboe.rb +7 -0
- data/lib/oboe_metal.rb +187 -0
- data/lib/rails/generators/appoptics_apm/install_generator.rb +45 -0
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +222 -0
- data/ruby_setup.sh +47 -0
- data/run_docker_build_gem_upload_to_packagecloud.sh +20 -0
- data/run_tests_docker.rb +32 -0
- data/test/benchmark/README.md +65 -0
- data/test/benchmark/logging_bench.rb +54 -0
- data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +69 -0
- data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +43 -0
- data/test/frameworks/apps/grape_nested.rb +33 -0
- data/test/frameworks/apps/grape_simple.rb +80 -0
- data/test/frameworks/apps/padrino_simple.rb +80 -0
- data/test/frameworks/apps/sinatra_simple.rb +55 -0
- data/test/frameworks/grape_test.rb +286 -0
- data/test/frameworks/padrino_test.rb +222 -0
- data/test/frameworks/rails3x_test.rb +554 -0
- data/test/frameworks/rails4x_test.rb +570 -0
- data/test/frameworks/rails5x_api_test.rb +210 -0
- data/test/frameworks/rails5x_test.rb +376 -0
- data/test/frameworks/rails_shared_tests.rb +172 -0
- data/test/frameworks/sinatra_test.rb +140 -0
- data/test/instrumentation/bunny_client_test.rb +276 -0
- data/test/instrumentation/bunny_consumer_test.rb +204 -0
- data/test/instrumentation/curb_test.rb +398 -0
- data/test/instrumentation/dalli_test.rb +177 -0
- data/test/instrumentation/em_http_request_test.rb +89 -0
- data/test/instrumentation/excon_test.rb +231 -0
- data/test/instrumentation/faraday_test.rb +228 -0
- data/test/instrumentation/http_test.rb +143 -0
- data/test/instrumentation/httpclient_test.rb +320 -0
- data/test/instrumentation/memcache_test.rb +260 -0
- data/test/instrumentation/memcached_test.rb +229 -0
- data/test/instrumentation/mongo_v1_test.rb +479 -0
- data/test/instrumentation/mongo_v2_index_test.rb +124 -0
- data/test/instrumentation/mongo_v2_test.rb +584 -0
- data/test/instrumentation/mongo_v2_view_test.rb +435 -0
- data/test/instrumentation/moped_test.rb +517 -0
- data/test/instrumentation/rack_test.rb +165 -0
- data/test/instrumentation/redis_hashes_test.rb +268 -0
- data/test/instrumentation/redis_keys_test.rb +321 -0
- data/test/instrumentation/redis_lists_test.rb +310 -0
- data/test/instrumentation/redis_misc_test.rb +163 -0
- data/test/instrumentation/redis_sets_test.rb +296 -0
- data/test/instrumentation/redis_sortedsets_test.rb +328 -0
- data/test/instrumentation/redis_strings_test.rb +349 -0
- data/test/instrumentation/resque_test.rb +185 -0
- data/test/instrumentation/rest-client_test.rb +288 -0
- data/test/instrumentation/sequel_mysql2_test.rb +353 -0
- data/test/instrumentation/sequel_mysql_test.rb +334 -0
- data/test/instrumentation/sequel_pg_test.rb +336 -0
- data/test/instrumentation/sidekiq-client_test.rb +159 -0
- data/test/instrumentation/sidekiq-worker_test.rb +180 -0
- data/test/instrumentation/twitter-cassandra_test.rb +424 -0
- data/test/instrumentation/typhoeus_test.rb +284 -0
- data/test/jobs/delayed_job/db_worker_job.rb +29 -0
- data/test/jobs/delayed_job/error_worker_job.rb +10 -0
- data/test/jobs/delayed_job/remote_call_worker_job.rb +20 -0
- data/test/jobs/resque/db_worker_job.rb +29 -0
- data/test/jobs/resque/error_worker_job.rb +10 -0
- data/test/jobs/resque/remote_call_worker_job.rb +20 -0
- data/test/jobs/sidekiq/db_worker_job.rb +29 -0
- data/test/jobs/sidekiq/error_worker_job.rb +10 -0
- data/test/jobs/sidekiq/remote_call_worker_job.rb +20 -0
- data/test/minitest_helper.rb +276 -0
- data/test/mocked/curb_mocked_test.rb +311 -0
- data/test/mocked/excon_mocked_test.rb +166 -0
- data/test/mocked/faraday_mocked_test.rb +93 -0
- data/test/mocked/http_mocked_test.rb +129 -0
- data/test/mocked/httpclient_mocked_test.rb +245 -0
- data/test/mocked/rest_client_mocked_test.rb +103 -0
- data/test/mocked/typhoeus_mocked_test.rb +192 -0
- data/test/models/widget.rb +36 -0
- data/test/profiling/legacy_method_profiling_test.rb +201 -0
- data/test/profiling/method_profiling_test.rb +631 -0
- data/test/queues/delayed_job-client_test.rb +95 -0
- data/test/queues/delayed_job-worker_test.rb +91 -0
- data/test/reporter/reporter_test.rb +14 -0
- data/test/servers/delayed_job.rb +107 -0
- data/test/servers/rackapp_8101.rb +29 -0
- data/test/servers/rails3x_8140.rb +96 -0
- data/test/servers/rails4x_8140.rb +96 -0
- data/test/servers/rails5x_8140.rb +95 -0
- data/test/servers/rails5x_api_8150.rb +78 -0
- data/test/servers/sidekiq.rb +29 -0
- data/test/servers/sidekiq.yml +7 -0
- data/test/servers/sidekiq_initializer.rb +25 -0
- data/test/settings +0 -0
- data/test/support/auto_tracing_test.rb +50 -0
- data/test/support/backcompat_test.rb +276 -0
- data/test/support/config_test.rb +149 -0
- data/test/support/dnt_test.rb +98 -0
- data/test/support/init_report_test.rb +25 -0
- data/test/support/liboboe_settings_test.rb +110 -0
- data/test/support/logging_test.rb +130 -0
- data/test/support/noop_test.rb +88 -0
- data/test/support/sql_sanitize_test.rb +55 -0
- data/test/support/tracing_mode_test.rb +33 -0
- data/test/support/tvalias_test.rb +15 -0
- data/test/support/xtrace_test.rb +41 -0
- metadata +475 -0
@@ -0,0 +1,268 @@
|
|
1
|
+
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'minitest_helper'
|
5
|
+
|
6
|
+
if defined?(::Redis)
|
7
|
+
describe "Redis Hashes" do
|
8
|
+
attr_reader :entry_kvs, :exit_kvs, :redis, :redis_version
|
9
|
+
|
10
|
+
def min_server_version(version)
|
11
|
+
unless Gem::Version.new(@redis_version) >= Gem::Version.new(version.to_s)
|
12
|
+
skip "supported only on redis-server #{version} or greater"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
clear_all_traces
|
18
|
+
|
19
|
+
@redis ||= Redis.new(:host => ENV['APPOPTICS_REDIS_SERVER'] || '127.0.0.1')
|
20
|
+
|
21
|
+
@redis_version ||= @redis.info["redis_version"]
|
22
|
+
|
23
|
+
# These are standard entry/exit KVs that are passed up with all moped operations
|
24
|
+
@entry_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'entry' }
|
25
|
+
@exit_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'exit' }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'Stock Redis should be loaded, defined and ready' do
|
29
|
+
defined?(::Redis).wont_match nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should trace hdel" do
|
33
|
+
min_server_version(2.0)
|
34
|
+
|
35
|
+
@redis.hset("whale", "color", "blue")
|
36
|
+
|
37
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
38
|
+
@redis.hdel("whale", "color")
|
39
|
+
end
|
40
|
+
|
41
|
+
traces = get_all_traces
|
42
|
+
traces.count.must_equal 4
|
43
|
+
traces[2]['KVOp'].must_equal "hdel"
|
44
|
+
traces[2]['KVKey'].must_equal "whale"
|
45
|
+
traces[2]['field'].must_equal "color"
|
46
|
+
end
|
47
|
+
|
48
|
+
it "should trace hdel multiple fields" do
|
49
|
+
min_server_version(2.4)
|
50
|
+
|
51
|
+
@redis.hset("whale", "color", "blue")
|
52
|
+
@redis.hset("whale", "size", "big")
|
53
|
+
@redis.hset("whale", "eyes", "green")
|
54
|
+
|
55
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
56
|
+
@redis.hdel("whale", ["color", "eyes"])
|
57
|
+
end
|
58
|
+
|
59
|
+
traces = get_all_traces
|
60
|
+
traces.count.must_equal 4
|
61
|
+
traces[2]['KVOp'].must_equal "hdel"
|
62
|
+
traces[2]['KVKey'].must_equal "whale"
|
63
|
+
traces[2].has_key?('field').must_equal false
|
64
|
+
end
|
65
|
+
|
66
|
+
it "should trace hexists" do
|
67
|
+
min_server_version(2.0)
|
68
|
+
|
69
|
+
@redis.hset("whale", "color", "blue")
|
70
|
+
|
71
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
72
|
+
@redis.hexists("whale", "color")
|
73
|
+
end
|
74
|
+
|
75
|
+
traces = get_all_traces
|
76
|
+
traces.count.must_equal 4
|
77
|
+
traces[2]['KVOp'].must_equal "hexists"
|
78
|
+
traces[2]['KVKey'].must_equal "whale"
|
79
|
+
traces[2]['field'].must_equal "color"
|
80
|
+
end
|
81
|
+
|
82
|
+
it "should trace hget" do
|
83
|
+
min_server_version(2.0)
|
84
|
+
|
85
|
+
@redis.hset("whale", "color", "blue")
|
86
|
+
|
87
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
88
|
+
@redis.hget("whale", "color")
|
89
|
+
@redis.hget("whale", "noexist")
|
90
|
+
end
|
91
|
+
|
92
|
+
traces = get_all_traces
|
93
|
+
traces.count.must_equal 6
|
94
|
+
traces[2]['KVOp'].must_equal "hget"
|
95
|
+
traces[2]['KVKey'].must_equal "whale"
|
96
|
+
traces[2]['KVHit'].must_equal 1
|
97
|
+
traces[2]['field'].must_equal "color"
|
98
|
+
traces[4]['KVHit'].must_equal 0
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should trace hgetall" do
|
102
|
+
min_server_version(2.0)
|
103
|
+
|
104
|
+
@redis.hset("whale", "color", "blue")
|
105
|
+
|
106
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
107
|
+
@redis.hgetall("whale")
|
108
|
+
end
|
109
|
+
|
110
|
+
traces = get_all_traces
|
111
|
+
traces.count.must_equal 4
|
112
|
+
traces[2]['KVOp'].must_equal "hgetall"
|
113
|
+
traces[2]['KVKey'].must_equal "whale"
|
114
|
+
end
|
115
|
+
|
116
|
+
it "should trace hincrby" do
|
117
|
+
min_server_version(2.0)
|
118
|
+
|
119
|
+
@redis.hset("whale", "age", 32)
|
120
|
+
|
121
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
122
|
+
@redis.hincrby("whale", "age", 1)
|
123
|
+
end
|
124
|
+
|
125
|
+
traces = get_all_traces
|
126
|
+
traces.count.must_equal 4
|
127
|
+
traces[2]['KVOp'].must_equal "hincrby"
|
128
|
+
traces[2]['KVKey'].must_equal "whale"
|
129
|
+
traces[2]['field'].must_equal "age"
|
130
|
+
traces[2]['increment'].must_equal 1
|
131
|
+
end
|
132
|
+
|
133
|
+
it "should trace hincrbyfloat" do
|
134
|
+
min_server_version(2.6)
|
135
|
+
|
136
|
+
@redis.hset("whale", "age", 32)
|
137
|
+
|
138
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
139
|
+
@redis.hincrbyfloat("whale", "age", 1.3)
|
140
|
+
end
|
141
|
+
|
142
|
+
traces = get_all_traces
|
143
|
+
traces.count.must_equal 4
|
144
|
+
traces[2]['KVOp'].must_equal "hincrbyfloat"
|
145
|
+
traces[2]['KVKey'].must_equal "whale"
|
146
|
+
traces[2]['field'].must_equal "age"
|
147
|
+
traces[2]['increment'].must_equal 1.3
|
148
|
+
end
|
149
|
+
|
150
|
+
it "should trace hkeys" do
|
151
|
+
min_server_version(2.0)
|
152
|
+
|
153
|
+
@redis.hset("whale", "age", 32)
|
154
|
+
|
155
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
156
|
+
@redis.hkeys("whale")
|
157
|
+
end
|
158
|
+
|
159
|
+
traces = get_all_traces
|
160
|
+
traces.count.must_equal 4
|
161
|
+
traces[2]['KVOp'].must_equal "hkeys"
|
162
|
+
traces[2]['KVKey'].must_equal "whale"
|
163
|
+
end
|
164
|
+
|
165
|
+
it "should trace hlen" do
|
166
|
+
min_server_version(2.0)
|
167
|
+
|
168
|
+
@redis.hset("whale", "age", 32)
|
169
|
+
|
170
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
171
|
+
@redis.hlen("whale")
|
172
|
+
end
|
173
|
+
|
174
|
+
traces = get_all_traces
|
175
|
+
traces.count.must_equal 4
|
176
|
+
traces[2]['KVOp'].must_equal "hlen"
|
177
|
+
traces[2]['KVKey'].must_equal "whale"
|
178
|
+
end
|
179
|
+
|
180
|
+
it "should trace hmget" do
|
181
|
+
min_server_version(2.0)
|
182
|
+
|
183
|
+
@redis.hset("whale", "color", "blue")
|
184
|
+
@redis.hset("whale", "size", "big")
|
185
|
+
@redis.hset("whale", "eyes", "green")
|
186
|
+
|
187
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
188
|
+
@redis.hmget("whale", "color", "size", "blah", "brown")
|
189
|
+
end
|
190
|
+
|
191
|
+
traces = get_all_traces
|
192
|
+
traces.count.must_equal 4
|
193
|
+
traces[2]['KVOp'].must_equal "hmget"
|
194
|
+
traces[2]['KVKey'].must_equal "whale"
|
195
|
+
traces[2]['KVKeyCount'].must_equal 4
|
196
|
+
traces[2]['KVHitCount'].must_equal 2
|
197
|
+
end
|
198
|
+
|
199
|
+
it "should trace hmset" do
|
200
|
+
min_server_version(2.0)
|
201
|
+
|
202
|
+
@redis.hset("whale", "color", "blue")
|
203
|
+
@redis.hset("whale", "size", "big")
|
204
|
+
@redis.hset("whale", "eyes", "green")
|
205
|
+
|
206
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
207
|
+
@redis.hmset("whale", ["color", "red", "size", "very big"])
|
208
|
+
end
|
209
|
+
|
210
|
+
traces = get_all_traces
|
211
|
+
traces.count.must_equal 4
|
212
|
+
traces[2]['KVOp'].must_equal "hmset"
|
213
|
+
traces[2]['KVKey'].must_equal "whale"
|
214
|
+
end
|
215
|
+
|
216
|
+
it "should trace hset" do
|
217
|
+
min_server_version(2.0)
|
218
|
+
|
219
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
220
|
+
@redis.hset("whale", "eyes", "green")
|
221
|
+
end
|
222
|
+
|
223
|
+
traces = get_all_traces
|
224
|
+
traces.count.must_equal 4
|
225
|
+
traces[2]['KVOp'].must_equal "hset"
|
226
|
+
traces[2]['KVKey'].must_equal "whale"
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should trace hsetnx" do
|
230
|
+
min_server_version(2.0)
|
231
|
+
|
232
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
233
|
+
@redis.hsetnx("whale", "eyes", "green")
|
234
|
+
end
|
235
|
+
|
236
|
+
traces = get_all_traces
|
237
|
+
traces.count.must_equal 4
|
238
|
+
traces[2]['KVOp'].must_equal "hsetnx"
|
239
|
+
traces[2]['KVKey'].must_equal "whale"
|
240
|
+
end
|
241
|
+
|
242
|
+
it "should trace hvals" do
|
243
|
+
min_server_version(2.0)
|
244
|
+
|
245
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
246
|
+
@redis.hvals("whale")
|
247
|
+
end
|
248
|
+
|
249
|
+
traces = get_all_traces
|
250
|
+
traces.count.must_equal 4
|
251
|
+
traces[2]['KVOp'].must_equal "hvals"
|
252
|
+
traces[2]['KVKey'].must_equal "whale"
|
253
|
+
end
|
254
|
+
|
255
|
+
it "should trace hscan" do
|
256
|
+
min_server_version(2.8)
|
257
|
+
|
258
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
259
|
+
@redis.hscan("whale", 0)
|
260
|
+
end
|
261
|
+
|
262
|
+
traces = get_all_traces
|
263
|
+
traces.count.must_equal 4
|
264
|
+
traces[2]['KVOp'].must_equal "hscan"
|
265
|
+
traces[2]['KVKey'].must_equal "whale"
|
266
|
+
end
|
267
|
+
end
|
268
|
+
end
|
@@ -0,0 +1,321 @@
|
|
1
|
+
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'minitest_helper'
|
5
|
+
|
6
|
+
if defined?(::Redis)
|
7
|
+
describe "Redis Keys" do
|
8
|
+
attr_reader :entry_kvs, :exit_kvs, :redis, :redis_version
|
9
|
+
|
10
|
+
def min_server_version(version)
|
11
|
+
unless Gem::Version.new(@redis_version) >= Gem::Version.new(version.to_s)
|
12
|
+
skip "supported only on redis-server #{version} or greater"
|
13
|
+
end
|
14
|
+
end
|
15
|
+
|
16
|
+
before do
|
17
|
+
clear_all_traces
|
18
|
+
|
19
|
+
@redis ||= Redis.new(:host => ENV['APPOPTICS_REDIS_SERVER'] || '127.0.0.1')
|
20
|
+
|
21
|
+
@redis_version ||= @redis.info["redis_version"]
|
22
|
+
|
23
|
+
# These are standard entry/exit KVs that are passed up with all moped operations
|
24
|
+
@entry_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'entry' }
|
25
|
+
@exit_kvs ||= { 'Layer' => 'redis_test', 'Label' => 'exit' }
|
26
|
+
end
|
27
|
+
|
28
|
+
it 'Stock Redis should be loaded, defined and ready' do
|
29
|
+
defined?(::Redis).wont_match nil
|
30
|
+
end
|
31
|
+
|
32
|
+
it "should trace del" do
|
33
|
+
@redis.setex("del_test", 60, "blah")
|
34
|
+
|
35
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
36
|
+
@redis.del("del_test")
|
37
|
+
end
|
38
|
+
|
39
|
+
traces = get_all_traces
|
40
|
+
traces.count.must_equal 4
|
41
|
+
traces[2]['KVOp'].must_equal "del"
|
42
|
+
traces[2]['KVKey'].must_equal "del_test"
|
43
|
+
end
|
44
|
+
|
45
|
+
it "should trace del of multiple keys" do
|
46
|
+
@redis.setex("del_test", 60, "blah")
|
47
|
+
|
48
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
49
|
+
@redis.del(["del_test", "noexist", "maybe"])
|
50
|
+
end
|
51
|
+
|
52
|
+
traces = get_all_traces
|
53
|
+
traces.count.must_equal 4
|
54
|
+
traces[2]['KVOp'].must_equal "del"
|
55
|
+
traces[2].has_key?('KVKey').must_equal false
|
56
|
+
end
|
57
|
+
|
58
|
+
it "should trace dump" do
|
59
|
+
min_server_version(2.6)
|
60
|
+
|
61
|
+
@redis.setex("dump_test", 60, "blah")
|
62
|
+
|
63
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
64
|
+
@redis.dump("del_test")
|
65
|
+
end
|
66
|
+
|
67
|
+
traces = get_all_traces
|
68
|
+
traces.count.must_equal 4
|
69
|
+
traces[2]['KVOp'].must_equal "dump"
|
70
|
+
traces[2]['KVKey'].must_equal "del_test"
|
71
|
+
end
|
72
|
+
|
73
|
+
it "should trace exists" do
|
74
|
+
@redis.setex("talking_heads", 60, "burning down the house")
|
75
|
+
|
76
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
77
|
+
@it_exists = @redis.exists("talking_heads")
|
78
|
+
end
|
79
|
+
|
80
|
+
@it_exists.must_equal true
|
81
|
+
|
82
|
+
traces = get_all_traces
|
83
|
+
traces.count.must_equal 4
|
84
|
+
traces[2]['KVOp'].must_equal "exists"
|
85
|
+
traces[2]['KVKey'].must_equal "talking_heads"
|
86
|
+
end
|
87
|
+
|
88
|
+
it "should trace expire" do
|
89
|
+
@redis.set("expire_please", "burning down the house")
|
90
|
+
|
91
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
92
|
+
@redis.expire("expire_please", 120)
|
93
|
+
end
|
94
|
+
|
95
|
+
traces = get_all_traces
|
96
|
+
traces.count.must_equal 4
|
97
|
+
traces[2]['KVOp'].must_equal "expire"
|
98
|
+
traces[2]['KVKey'].must_equal "expire_please"
|
99
|
+
end
|
100
|
+
|
101
|
+
it "should trace expireat" do
|
102
|
+
@redis.set("expireat_please", "burning down the house")
|
103
|
+
|
104
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
105
|
+
@redis.expireat("expireat_please", Time.now.to_i)
|
106
|
+
end
|
107
|
+
|
108
|
+
traces = get_all_traces
|
109
|
+
traces.count.must_equal 4
|
110
|
+
traces[2]['KVOp'].must_equal "expireat"
|
111
|
+
traces[2]['KVKey'].must_equal "expireat_please"
|
112
|
+
end
|
113
|
+
|
114
|
+
it "should trace keys" do
|
115
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
116
|
+
@redis.keys("del*")
|
117
|
+
end
|
118
|
+
|
119
|
+
traces = get_all_traces
|
120
|
+
traces.count.must_equal 4
|
121
|
+
traces[2]['KVOp'].must_equal "keys"
|
122
|
+
traces[2]['pattern'].must_equal "del*"
|
123
|
+
end
|
124
|
+
|
125
|
+
it "should trace basic move" do
|
126
|
+
@redis.set("piano", Time.now)
|
127
|
+
|
128
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
129
|
+
@redis.move("piano", 1)
|
130
|
+
end
|
131
|
+
|
132
|
+
traces = get_all_traces
|
133
|
+
traces.count.must_equal 4
|
134
|
+
traces[2]['KVOp'].must_equal "move"
|
135
|
+
traces[2]['KVKey'].must_equal "piano"
|
136
|
+
traces[2]['db'].must_equal 1
|
137
|
+
end
|
138
|
+
|
139
|
+
it "should trace persist" do
|
140
|
+
min_server_version(2.2)
|
141
|
+
|
142
|
+
@redis.setex("mine", 60, "blah")
|
143
|
+
|
144
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
145
|
+
@redis.persist("mine")
|
146
|
+
end
|
147
|
+
|
148
|
+
traces = get_all_traces
|
149
|
+
traces.count.must_equal 4
|
150
|
+
traces[2]['KVOp'].must_equal "persist"
|
151
|
+
traces[2]['KVKey'].must_equal "mine"
|
152
|
+
end
|
153
|
+
|
154
|
+
it "should trace pexpire" do
|
155
|
+
min_server_version(2.6)
|
156
|
+
|
157
|
+
@redis.set("sand", "blah")
|
158
|
+
|
159
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
160
|
+
@rv = @redis.pexpire("sand", 8000)
|
161
|
+
end
|
162
|
+
|
163
|
+
@rv.must_equal true
|
164
|
+
|
165
|
+
traces = get_all_traces
|
166
|
+
traces.count.must_equal 4
|
167
|
+
traces[2]['KVOp'].must_equal "pexpire"
|
168
|
+
traces[2]['KVKey'].must_equal "sand"
|
169
|
+
traces[2]['milliseconds'].must_equal 8000
|
170
|
+
end
|
171
|
+
|
172
|
+
it "should trace pexpireat" do
|
173
|
+
min_server_version(2.6)
|
174
|
+
|
175
|
+
@redis.set("sand", "blah")
|
176
|
+
|
177
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
178
|
+
@rv = @redis.pexpireat("sand", 8000)
|
179
|
+
end
|
180
|
+
|
181
|
+
@rv.must_equal true
|
182
|
+
|
183
|
+
traces = get_all_traces
|
184
|
+
traces.count.must_equal 4
|
185
|
+
traces[2]['KVOp'].must_equal "pexpireat"
|
186
|
+
traces[2]['KVKey'].must_equal "sand"
|
187
|
+
traces[2]['milliseconds'].must_equal 8000
|
188
|
+
end
|
189
|
+
|
190
|
+
it "should trace pttl" do
|
191
|
+
min_server_version(2.6)
|
192
|
+
|
193
|
+
@redis.setex("sand", 120, "blah")
|
194
|
+
|
195
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
196
|
+
@redis.pttl("sand")
|
197
|
+
end
|
198
|
+
|
199
|
+
traces = get_all_traces
|
200
|
+
traces.count.must_equal 4
|
201
|
+
traces[2]['KVOp'].must_equal "pttl"
|
202
|
+
traces[2]['KVKey'].must_equal "sand"
|
203
|
+
end
|
204
|
+
|
205
|
+
it "should trace randomkey" do
|
206
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
207
|
+
@redis.randomkey()
|
208
|
+
end
|
209
|
+
|
210
|
+
traces = get_all_traces
|
211
|
+
traces.count.must_equal 4
|
212
|
+
traces[2]['KVOp'].must_equal "randomkey"
|
213
|
+
end
|
214
|
+
|
215
|
+
it "should trace rename" do
|
216
|
+
@redis.setex("sand", 120, "blah")
|
217
|
+
|
218
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
219
|
+
@redis.rename("sand", "sandy")
|
220
|
+
end
|
221
|
+
|
222
|
+
traces = get_all_traces
|
223
|
+
traces.count.must_equal 4
|
224
|
+
traces[2]['KVOp'].must_equal "rename"
|
225
|
+
traces[2]['KVKey'].must_equal "sand"
|
226
|
+
traces[2]['newkey'].must_equal "sandy"
|
227
|
+
end
|
228
|
+
|
229
|
+
it "should trace renamenx" do
|
230
|
+
@redis.setex("sand", 120, "blah")
|
231
|
+
|
232
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
233
|
+
@redis.renamenx("sand", "sandy")
|
234
|
+
end
|
235
|
+
|
236
|
+
traces = get_all_traces
|
237
|
+
traces.count.must_equal 4
|
238
|
+
traces[2]['KVOp'].must_equal "renamenx"
|
239
|
+
traces[2]['KVKey'].must_equal "sand"
|
240
|
+
traces[2]['newkey'].must_equal "sandy"
|
241
|
+
end
|
242
|
+
|
243
|
+
it "should trace restore" do
|
244
|
+
min_server_version(2.6)
|
245
|
+
|
246
|
+
@redis.setex("qubit", 60, "zero")
|
247
|
+
x = @redis.dump("qubit")
|
248
|
+
@redis.del "blue"
|
249
|
+
|
250
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
251
|
+
@redis.restore("blue", 0, x)
|
252
|
+
end
|
253
|
+
|
254
|
+
traces = get_all_traces
|
255
|
+
traces.count.must_equal 4
|
256
|
+
traces[2]['KVOp'].must_equal "restore"
|
257
|
+
traces[2]['KVKey'].must_equal "blue"
|
258
|
+
traces[2]['ttl'].must_equal 0
|
259
|
+
end
|
260
|
+
|
261
|
+
it "should trace sort" do
|
262
|
+
min_server_version(2.2)
|
263
|
+
|
264
|
+
@redis.rpush("penguin", "one")
|
265
|
+
@redis.rpush("penguin", "two")
|
266
|
+
@redis.rpush("penguin", "three")
|
267
|
+
@redis.rpush("penguin", "four")
|
268
|
+
|
269
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
270
|
+
@redis.sort("penguin", :order => "desc alpha", :store => "target")
|
271
|
+
end
|
272
|
+
|
273
|
+
traces = get_all_traces
|
274
|
+
traces.count.must_equal 4
|
275
|
+
traces[2]['KVOp'].must_equal "sort"
|
276
|
+
traces[2]['KVKey'].must_equal "penguin"
|
277
|
+
end
|
278
|
+
|
279
|
+
it "should trace ttl" do
|
280
|
+
min_server_version(2.6)
|
281
|
+
|
282
|
+
@redis.setex("sand", 120, "blah")
|
283
|
+
|
284
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
285
|
+
@redis.ttl("sand")
|
286
|
+
end
|
287
|
+
|
288
|
+
traces = get_all_traces
|
289
|
+
traces.count.must_equal 4
|
290
|
+
traces[2]['KVOp'].must_equal "ttl"
|
291
|
+
traces[2]['KVKey'].must_equal "sand"
|
292
|
+
end
|
293
|
+
|
294
|
+
it "should trace type" do
|
295
|
+
min_server_version(2.6)
|
296
|
+
|
297
|
+
@redis.setex("sand", 120, "blah")
|
298
|
+
|
299
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
300
|
+
@redis.type("sand")
|
301
|
+
end
|
302
|
+
|
303
|
+
traces = get_all_traces
|
304
|
+
traces.count.must_equal 4
|
305
|
+
traces[2]['KVOp'].must_equal "type"
|
306
|
+
traces[2]['KVKey'].must_equal "sand"
|
307
|
+
end
|
308
|
+
|
309
|
+
it "should trace scan" do
|
310
|
+
min_server_version(2.8)
|
311
|
+
|
312
|
+
AppOpticsAPM::API.start_trace('redis_test', '', {}) do
|
313
|
+
@redis.scan(0)
|
314
|
+
end
|
315
|
+
|
316
|
+
traces = get_all_traces
|
317
|
+
traces.count.must_equal 4
|
318
|
+
traces[2]['KVOp'].must_equal "scan"
|
319
|
+
end
|
320
|
+
end
|
321
|
+
end
|