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,424 @@
|
|
1
|
+
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
+
# All rights reserved.
|
3
|
+
|
4
|
+
require 'minitest_helper'
|
5
|
+
|
6
|
+
unless ENV['APPOPTICS_CASSANDRA_SERVER']
|
7
|
+
ENV['APPOPTICS_CASSANDRA_SERVER'] = "127.0.0.1:9160"
|
8
|
+
end
|
9
|
+
|
10
|
+
# The cassandra-rb client doesn't support JRuby
|
11
|
+
# https://github.com/cassandra-rb/cassandra
|
12
|
+
|
13
|
+
# exclude cassandra tests for now
|
14
|
+
# TODO: they need refactoring to use the 'cassandra-driver' gem instead of the 'cassandra' gem,
|
15
|
+
# ____ which hasn't had a commit since 09/2014
|
16
|
+
|
17
|
+
if defined?(::Cassandra) and !defined?(JRUBY_VERSION)
|
18
|
+
describe "Cassandra" do
|
19
|
+
before do
|
20
|
+
clear_all_traces
|
21
|
+
|
22
|
+
@client = Cassandra.new("system", ENV['APPOPTICS_CASSANDRA_SERVER'], { :timeout => 10 })
|
23
|
+
@client.disable_node_auto_discovery!
|
24
|
+
|
25
|
+
@ks_name = "AppNetaCassandraTest"
|
26
|
+
|
27
|
+
ks_def = CassandraThrift::KsDef.new(:name => @ks_name,
|
28
|
+
:strategy_class => "SimpleStrategy",
|
29
|
+
:strategy_options => { 'replication_factor' => '2' },
|
30
|
+
:cf_defs => [])
|
31
|
+
|
32
|
+
@client.add_keyspace(ks_def) unless @client.keyspaces.include? @ks_name
|
33
|
+
@client.keyspace = @ks_name
|
34
|
+
|
35
|
+
unless @client.column_families.include? "Users"
|
36
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Users")
|
37
|
+
@client.add_column_family(cf_def)
|
38
|
+
end
|
39
|
+
|
40
|
+
unless @client.column_families.include? "Statuses"
|
41
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => "Statuses")
|
42
|
+
@client.add_column_family(cf_def)
|
43
|
+
end
|
44
|
+
|
45
|
+
# These are standard entry/exit KVs that are passed up with all mongo operations
|
46
|
+
@entry_kvs = {
|
47
|
+
'Layer' => 'cassandra',
|
48
|
+
'Label' => 'entry',
|
49
|
+
'RemoteHost' => ENV['APPOPTICS_CASSANDRA_SERVER'].split(':')[0],
|
50
|
+
'RemotePort' => ENV['APPOPTICS_CASSANDRA_SERVER'].split(':')[1] }
|
51
|
+
|
52
|
+
@exit_kvs = { 'Layer' => 'cassandra', 'Label' => 'exit' }
|
53
|
+
@collect_backtraces = AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
54
|
+
end
|
55
|
+
|
56
|
+
after do
|
57
|
+
AppOpticsAPM::Config[:cassandra][:collect_backtraces] = @collect_backtraces
|
58
|
+
@client.disconnect!
|
59
|
+
end
|
60
|
+
|
61
|
+
it 'Stock Cassandra should be loaded, defined and ready' do
|
62
|
+
defined?(::Cassandra).wont_match nil
|
63
|
+
end
|
64
|
+
|
65
|
+
it 'Cassandra should have appoptics_apm methods defined' do
|
66
|
+
[ :insert, :remove, :count_columns, :get_columns, :multi_get_columns, :get,
|
67
|
+
:multi_get, :get_range_single, :get_range_batch, :get_indexed_slices,
|
68
|
+
:create_index, :drop_index, :add_column_family, :drop_column_family,
|
69
|
+
:add_keyspace, :drop_keyspace ].each do |m|
|
70
|
+
::Cassandra.method_defined?("#{m}_with_appoptics").must_equal true
|
71
|
+
end
|
72
|
+
# Special 'exists?' case
|
73
|
+
::Cassandra.method_defined?("exists_with_appoptics?").must_equal true
|
74
|
+
end
|
75
|
+
|
76
|
+
it 'shouldn\'t break when NOT tracing' do
|
77
|
+
begin
|
78
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
79
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
80
|
+
@client.remove(:Users, '5', 'blah')
|
81
|
+
@client.count_columns(:Statuses, '12', :count => 50)
|
82
|
+
@client.get_columns(:Statuses, '12', ['body'])
|
83
|
+
@client.multi_get_columns(:Users, ['12', '5'], ['body'])
|
84
|
+
@client.get(:Statuses, '12', :reversed => true)
|
85
|
+
@client.get_range_keys(:Statuses, :key_count => 4)
|
86
|
+
@client.create_index(@ks_name, 'Statuses', 'x', 'LongType')
|
87
|
+
expressions = [
|
88
|
+
{ :column_name => 'x',
|
89
|
+
:value => [0,20].pack("NN"),
|
90
|
+
:comparison => "=="},
|
91
|
+
{ :column_name => 'non_indexed',
|
92
|
+
:value => [5].pack("N*"),
|
93
|
+
:comparison => ">"} ]
|
94
|
+
@client.get_indexed_slices(:Statuses, expressions).length
|
95
|
+
@client.exists?(:Statuses, '12')
|
96
|
+
@client.exists?(:Statuses, '12', 'body')
|
97
|
+
@client.drop_index(@ks_name, 'Statuses', 'column_name')
|
98
|
+
@client.drop_keyspace(@ks_name)
|
99
|
+
rescue => e
|
100
|
+
# My crappy way to detect and fail if an exception
|
101
|
+
# was raised. I swear there was a Minitest assertion for
|
102
|
+
# this but can't find it.
|
103
|
+
e.must_equal nil, "broken when NOT tracing"
|
104
|
+
raise
|
105
|
+
end
|
106
|
+
end
|
107
|
+
|
108
|
+
it 'should trace insert' do
|
109
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
110
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
111
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
112
|
+
end
|
113
|
+
|
114
|
+
traces = get_all_traces
|
115
|
+
|
116
|
+
traces.count.must_equal 4
|
117
|
+
validate_outer_layers(traces, 'cassandra_test')
|
118
|
+
|
119
|
+
validate_event_keys(traces[1], @entry_kvs)
|
120
|
+
traces[1]['Op'].must_equal "insert"
|
121
|
+
traces[1]['Cf'].must_equal "Users"
|
122
|
+
traces[1]['Key'].must_equal "\"5\""
|
123
|
+
traces[1]['Consistency'].must_equal 1
|
124
|
+
traces[1]['Ttl'].must_equal 600
|
125
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
126
|
+
validate_event_keys(traces[2], @exit_kvs)
|
127
|
+
end
|
128
|
+
|
129
|
+
it 'should trace remove' do
|
130
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
131
|
+
@client.remove(:Users, '5', 'blah')
|
132
|
+
end
|
133
|
+
|
134
|
+
traces = get_all_traces
|
135
|
+
|
136
|
+
traces.count.must_equal 4
|
137
|
+
validate_outer_layers(traces, 'cassandra_test')
|
138
|
+
|
139
|
+
validate_event_keys(traces[1], @entry_kvs)
|
140
|
+
traces[1]['Op'].must_equal "remove"
|
141
|
+
traces[1]['Cf'].must_equal "Users"
|
142
|
+
traces[1]['Key'].must_equal "\"5\""
|
143
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
144
|
+
validate_event_keys(traces[2], @exit_kvs)
|
145
|
+
end
|
146
|
+
|
147
|
+
it 'should trace count_columns' do
|
148
|
+
@client.insert(:Statuses, '12', {'body' => 'v1', 'user' => 'v2'})
|
149
|
+
|
150
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
151
|
+
@client.count_columns(:Statuses, '12', :count => 50)
|
152
|
+
end
|
153
|
+
|
154
|
+
traces = get_all_traces
|
155
|
+
|
156
|
+
traces.count.must_equal 4
|
157
|
+
validate_outer_layers(traces, 'cassandra_test')
|
158
|
+
|
159
|
+
validate_event_keys(traces[1], @entry_kvs)
|
160
|
+
traces[1]['Op'].must_equal "count_columns"
|
161
|
+
traces[1]['Cf'].must_equal "Statuses"
|
162
|
+
traces[1]['Key'].must_equal "\"12\""
|
163
|
+
traces[1]['Count'].must_equal 50
|
164
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
165
|
+
validate_event_keys(traces[2], @exit_kvs)
|
166
|
+
end
|
167
|
+
|
168
|
+
it 'should trace get_columns' do
|
169
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
170
|
+
@client.get_columns(:Statuses, '12', ['body'])
|
171
|
+
end
|
172
|
+
|
173
|
+
traces = get_all_traces
|
174
|
+
|
175
|
+
traces.count.must_equal 4
|
176
|
+
validate_outer_layers(traces, 'cassandra_test')
|
177
|
+
|
178
|
+
validate_event_keys(traces[1], @entry_kvs)
|
179
|
+
traces[1]['Op'].must_equal "get_columns"
|
180
|
+
traces[1]['Cf'].must_equal "Statuses"
|
181
|
+
traces[1]['Key'].must_equal "\"12\""
|
182
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
183
|
+
validate_event_keys(traces[2], @exit_kvs)
|
184
|
+
end
|
185
|
+
|
186
|
+
it 'should trace multi_get_columns' do
|
187
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
188
|
+
@client.multi_get_columns(:Users, ['12', '5'], ['body'])
|
189
|
+
end
|
190
|
+
|
191
|
+
traces = get_all_traces
|
192
|
+
|
193
|
+
traces.count.must_equal 4
|
194
|
+
validate_outer_layers(traces, 'cassandra_test')
|
195
|
+
|
196
|
+
validate_event_keys(traces[1], @entry_kvs)
|
197
|
+
traces[1]['Op'].must_equal "multi_get_columns"
|
198
|
+
traces[1]['Cf'].must_equal "Users"
|
199
|
+
traces[1]['Key'].must_equal "[\"12\", \"5\"]"
|
200
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
201
|
+
validate_event_keys(traces[2], @exit_kvs)
|
202
|
+
end
|
203
|
+
|
204
|
+
it 'should trace get' do
|
205
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
206
|
+
@client.get(:Statuses, '12', :reversed => true)
|
207
|
+
end
|
208
|
+
|
209
|
+
traces = get_all_traces
|
210
|
+
|
211
|
+
traces.count.must_equal 4
|
212
|
+
validate_outer_layers(traces, 'cassandra_test')
|
213
|
+
|
214
|
+
validate_event_keys(traces[1], @entry_kvs)
|
215
|
+
traces[1]['Op'].must_equal "get"
|
216
|
+
traces[1]['Cf'].must_equal "Statuses"
|
217
|
+
traces[1]['Key'].must_equal "\"12\""
|
218
|
+
traces[1]['Reversed'].must_equal "true"
|
219
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
220
|
+
validate_event_keys(traces[2], @exit_kvs)
|
221
|
+
end
|
222
|
+
|
223
|
+
it 'should trace exists?' do
|
224
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
225
|
+
@client.exists?(:Statuses, '12')
|
226
|
+
@client.exists?(:Statuses, '12', 'body')
|
227
|
+
end
|
228
|
+
|
229
|
+
traces = get_all_traces
|
230
|
+
|
231
|
+
traces.count.must_equal 6
|
232
|
+
validate_outer_layers(traces, 'cassandra_test')
|
233
|
+
|
234
|
+
validate_event_keys(traces[1], @entry_kvs)
|
235
|
+
traces[1]['Op'].must_equal "exists?"
|
236
|
+
traces[1]['Cf'].must_equal "Statuses"
|
237
|
+
traces[1]['Key'].must_equal "\"12\""
|
238
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
239
|
+
validate_event_keys(traces[2], @exit_kvs)
|
240
|
+
|
241
|
+
traces[3]['Op'].must_equal "exists?"
|
242
|
+
traces[3]['Cf'].must_equal "Statuses"
|
243
|
+
traces[3]['Key'].must_equal "\"12\""
|
244
|
+
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
245
|
+
end
|
246
|
+
|
247
|
+
it 'should trace get_range_keys' do
|
248
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
249
|
+
@client.get_range_keys(:Statuses, :key_count => 4)
|
250
|
+
end
|
251
|
+
|
252
|
+
traces = get_all_traces
|
253
|
+
|
254
|
+
traces.count.must_equal 4
|
255
|
+
validate_outer_layers(traces, 'cassandra_test')
|
256
|
+
|
257
|
+
validate_event_keys(traces[1], @entry_kvs)
|
258
|
+
traces[1]['Op'].must_equal "get_range_batch"
|
259
|
+
traces[1]['Cf'].must_equal "Statuses"
|
260
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
261
|
+
validate_event_keys(traces[2], @exit_kvs)
|
262
|
+
end
|
263
|
+
|
264
|
+
it 'should trace create_index' do
|
265
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
266
|
+
@client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
|
267
|
+
end
|
268
|
+
|
269
|
+
traces = get_all_traces
|
270
|
+
|
271
|
+
traces.count.must_equal 4
|
272
|
+
validate_outer_layers(traces, 'cassandra_test')
|
273
|
+
|
274
|
+
validate_event_keys(traces[1], @entry_kvs)
|
275
|
+
traces[1]['Op'].must_equal "create_index"
|
276
|
+
traces[1]['Cf'].must_equal "Statuses"
|
277
|
+
traces[1]['Keyspace'].must_equal @ks_name
|
278
|
+
traces[1]['Column_name'].must_equal "column_name"
|
279
|
+
traces[1]['Validation_class'].must_equal "LongType"
|
280
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
281
|
+
validate_event_keys(traces[2], @exit_kvs)
|
282
|
+
|
283
|
+
# Clean up
|
284
|
+
@client.drop_index(@ks_name, 'Statuses', 'column_name')
|
285
|
+
end
|
286
|
+
|
287
|
+
it 'should trace drop_index' do
|
288
|
+
# Prep
|
289
|
+
@client.create_index(@ks_name, 'Statuses', 'column_name', 'LongType')
|
290
|
+
|
291
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
292
|
+
@client.drop_index(@ks_name, 'Statuses', 'column_name')
|
293
|
+
end
|
294
|
+
|
295
|
+
traces = get_all_traces
|
296
|
+
|
297
|
+
traces.count.must_equal 4
|
298
|
+
validate_outer_layers(traces, 'cassandra_test')
|
299
|
+
|
300
|
+
validate_event_keys(traces[1], @entry_kvs)
|
301
|
+
traces[1]['Op'].must_equal "drop_index"
|
302
|
+
traces[1]['Cf'].must_equal "Statuses"
|
303
|
+
traces[1]['Keyspace'].must_equal @ks_name
|
304
|
+
traces[1]['Column_name'].must_equal "column_name"
|
305
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
306
|
+
validate_event_keys(traces[2], @exit_kvs)
|
307
|
+
end
|
308
|
+
|
309
|
+
it 'should trace get_indexed_slices' do
|
310
|
+
@client.create_index(@ks_name, 'Statuses', 'x', 'LongType')
|
311
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
312
|
+
expressions = [
|
313
|
+
{ :column_name => 'x',
|
314
|
+
:value => [0,20].pack("NN"),
|
315
|
+
:comparison => "=="},
|
316
|
+
{ :column_name => 'non_indexed',
|
317
|
+
:value => [5].pack("N*"),
|
318
|
+
:comparison => ">"} ]
|
319
|
+
@client.get_indexed_slices(:Statuses, expressions).length
|
320
|
+
end
|
321
|
+
|
322
|
+
traces = get_all_traces
|
323
|
+
|
324
|
+
traces.count.must_equal 4
|
325
|
+
validate_outer_layers(traces, 'cassandra_test')
|
326
|
+
|
327
|
+
validate_event_keys(traces[1], @entry_kvs)
|
328
|
+
traces[1]['Op'].must_equal "get_indexed_slices"
|
329
|
+
traces[1]['Cf'].must_equal "Statuses"
|
330
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
331
|
+
validate_event_keys(traces[2], @exit_kvs)
|
332
|
+
end
|
333
|
+
|
334
|
+
it 'should trace add and remove of column family' do
|
335
|
+
cf_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
336
|
+
cf_def = CassandraThrift::CfDef.new(:keyspace => @ks_name, :name => cf_name)
|
337
|
+
|
338
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
339
|
+
@client.add_column_family(cf_def)
|
340
|
+
@client.drop_column_family(cf_name)
|
341
|
+
end
|
342
|
+
|
343
|
+
traces = get_all_traces
|
344
|
+
|
345
|
+
traces.count.must_equal 6
|
346
|
+
validate_outer_layers(traces, 'cassandra_test')
|
347
|
+
|
348
|
+
validate_event_keys(traces[1], @entry_kvs)
|
349
|
+
traces[1]['Op'].must_equal "add_column_family"
|
350
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
351
|
+
validate_event_keys(traces[2], @exit_kvs)
|
352
|
+
|
353
|
+
traces[3]['Op'].must_equal "drop_column_family"
|
354
|
+
traces[3]['Cf'].must_equal cf_name
|
355
|
+
traces[3].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
356
|
+
end
|
357
|
+
|
358
|
+
it 'should trace adding a keyspace' do
|
359
|
+
ks_name = (0...10).map{ ('a'..'z').to_a[rand(26)] }.join
|
360
|
+
ks_def = CassandraThrift::KsDef.new(:name => ks_name,
|
361
|
+
:strategy_class => "org.apache.cassandra.locator.SimpleStrategy",
|
362
|
+
:strategy_options => { 'replication_factor' => '2' },
|
363
|
+
:cf_defs => [])
|
364
|
+
|
365
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
366
|
+
@client.add_keyspace(ks_def)
|
367
|
+
@client.keyspace = ks_name
|
368
|
+
end
|
369
|
+
|
370
|
+
traces = get_all_traces
|
371
|
+
|
372
|
+
traces.count.must_equal 4
|
373
|
+
validate_outer_layers(traces, 'cassandra_test')
|
374
|
+
|
375
|
+
validate_event_keys(traces[1], @entry_kvs)
|
376
|
+
traces[1]['Op'].must_equal "add_keyspace"
|
377
|
+
traces[1]['Name'].must_equal ks_name
|
378
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
379
|
+
validate_event_keys(traces[2], @exit_kvs)
|
380
|
+
end
|
381
|
+
|
382
|
+
it 'should trace the removal of a keyspace' do
|
383
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
384
|
+
@client.drop_keyspace(@ks_name)
|
385
|
+
end
|
386
|
+
|
387
|
+
traces = get_all_traces
|
388
|
+
|
389
|
+
traces.count.must_equal 4
|
390
|
+
validate_outer_layers(traces, 'cassandra_test')
|
391
|
+
|
392
|
+
validate_event_keys(traces[1], @entry_kvs)
|
393
|
+
traces[1]['Op'].must_equal "drop_keyspace"
|
394
|
+
traces[1]['Name'].must_equal @ks_name
|
395
|
+
traces[1].has_key?('Backtrace').must_equal AppOpticsAPM::Config[:cassandra][:collect_backtraces]
|
396
|
+
validate_event_keys(traces[2], @exit_kvs)
|
397
|
+
end
|
398
|
+
|
399
|
+
it "should obey :collect_backtraces setting when true" do
|
400
|
+
AppOpticsAPM::Config[:cassandra][:collect_backtraces] = true
|
401
|
+
|
402
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
403
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
404
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
405
|
+
end
|
406
|
+
|
407
|
+
traces = get_all_traces
|
408
|
+
layer_has_key(traces, 'cassandra', 'Backtrace')
|
409
|
+
end
|
410
|
+
|
411
|
+
it "should obey :collect_backtraces setting when false" do
|
412
|
+
AppOpticsAPM::Config[:cassandra][:collect_backtraces] = false
|
413
|
+
|
414
|
+
AppOpticsAPM::API.start_trace('cassandra_test', '', {}) do
|
415
|
+
user = {'screen_name' => 'larry', "blah" => "ok"}
|
416
|
+
@client.insert(:Users, '5', user, { :ttl => 600, :consistency => 1})
|
417
|
+
end
|
418
|
+
|
419
|
+
traces = get_all_traces
|
420
|
+
layer_doesnt_have_key(traces, 'cassandra', 'Backtrace')
|
421
|
+
end
|
422
|
+
|
423
|
+
end
|
424
|
+
end
|