appoptics_apm 4.0.3 → 4.0.4

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. checksums.yaml +4 -4
  2. data/Dockerfile_test +6 -7
  3. data/README.md +3 -3
  4. data/Rakefile +3 -2
  5. data/appoptics_apm.gemspec +2 -2
  6. data/docker-compose.yml +0 -22
  7. data/ext/oboe_metal/extconf.rb +4 -0
  8. data/lib/appoptics_apm/config.rb +11 -6
  9. data/lib/appoptics_apm/version.rb +1 -1
  10. metadata +3 -202
  11. data/gemfiles/delayed_job.gemfile +0 -36
  12. data/gemfiles/frameworks.gemfile +0 -44
  13. data/gemfiles/instrumentation_mocked.gemfile +0 -29
  14. data/gemfiles/libraries.gemfile +0 -85
  15. data/gemfiles/noop.gemfile +0 -17
  16. data/gemfiles/rails23.gemfile +0 -39
  17. data/gemfiles/rails30.gemfile +0 -42
  18. data/gemfiles/rails31.gemfile +0 -44
  19. data/gemfiles/rails32.gemfile +0 -54
  20. data/gemfiles/rails40.gemfile +0 -27
  21. data/gemfiles/rails41.gemfile +0 -27
  22. data/gemfiles/rails42.gemfile +0 -35
  23. data/gemfiles/rails50.gemfile +0 -44
  24. data/gemfiles/rails51.gemfile +0 -44
  25. data/test/benchmark/README.md +0 -65
  26. data/test/benchmark/logging_bench.rb +0 -54
  27. data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
  28. data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
  29. data/test/frameworks/apps/grape_nested.rb +0 -33
  30. data/test/frameworks/apps/grape_simple.rb +0 -80
  31. data/test/frameworks/apps/padrino_simple.rb +0 -80
  32. data/test/frameworks/apps/sinatra_simple.rb +0 -55
  33. data/test/frameworks/grape_test.rb +0 -286
  34. data/test/frameworks/padrino_test.rb +0 -222
  35. data/test/frameworks/rails3x_test.rb +0 -554
  36. data/test/frameworks/rails4x_test.rb +0 -570
  37. data/test/frameworks/rails5x_api_test.rb +0 -210
  38. data/test/frameworks/rails5x_test.rb +0 -376
  39. data/test/frameworks/rails_shared_tests.rb +0 -172
  40. data/test/frameworks/sinatra_test.rb +0 -140
  41. data/test/instrumentation/bunny_client_test.rb +0 -276
  42. data/test/instrumentation/bunny_consumer_test.rb +0 -204
  43. data/test/instrumentation/curb_test.rb +0 -398
  44. data/test/instrumentation/dalli_test.rb +0 -177
  45. data/test/instrumentation/em_http_request_test.rb +0 -89
  46. data/test/instrumentation/excon_test.rb +0 -231
  47. data/test/instrumentation/faraday_test.rb +0 -228
  48. data/test/instrumentation/http_test.rb +0 -143
  49. data/test/instrumentation/httpclient_test.rb +0 -304
  50. data/test/instrumentation/memcache_test.rb +0 -260
  51. data/test/instrumentation/memcached_test.rb +0 -229
  52. data/test/instrumentation/mongo_v1_test.rb +0 -479
  53. data/test/instrumentation/mongo_v2_index_test.rb +0 -124
  54. data/test/instrumentation/mongo_v2_test.rb +0 -584
  55. data/test/instrumentation/mongo_v2_view_test.rb +0 -435
  56. data/test/instrumentation/moped_test.rb +0 -517
  57. data/test/instrumentation/rack_test.rb +0 -165
  58. data/test/instrumentation/redis_hashes_test.rb +0 -268
  59. data/test/instrumentation/redis_keys_test.rb +0 -321
  60. data/test/instrumentation/redis_lists_test.rb +0 -310
  61. data/test/instrumentation/redis_misc_test.rb +0 -163
  62. data/test/instrumentation/redis_sets_test.rb +0 -296
  63. data/test/instrumentation/redis_sortedsets_test.rb +0 -328
  64. data/test/instrumentation/redis_strings_test.rb +0 -349
  65. data/test/instrumentation/resque_test.rb +0 -185
  66. data/test/instrumentation/rest-client_test.rb +0 -288
  67. data/test/instrumentation/sequel_mysql2_test.rb +0 -353
  68. data/test/instrumentation/sequel_mysql_test.rb +0 -334
  69. data/test/instrumentation/sequel_pg_test.rb +0 -336
  70. data/test/instrumentation/sidekiq-client_test.rb +0 -159
  71. data/test/instrumentation/sidekiq-worker_test.rb +0 -180
  72. data/test/instrumentation/twitter-cassandra_test.rb +0 -424
  73. data/test/instrumentation/typhoeus_test.rb +0 -284
  74. data/test/jobs/delayed_job/db_worker_job.rb +0 -29
  75. data/test/jobs/delayed_job/error_worker_job.rb +0 -10
  76. data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
  77. data/test/jobs/resque/db_worker_job.rb +0 -29
  78. data/test/jobs/resque/error_worker_job.rb +0 -10
  79. data/test/jobs/resque/remote_call_worker_job.rb +0 -20
  80. data/test/jobs/sidekiq/db_worker_job.rb +0 -29
  81. data/test/jobs/sidekiq/error_worker_job.rb +0 -10
  82. data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
  83. data/test/minitest_helper.rb +0 -277
  84. data/test/mocked/curb_mocked_test.rb +0 -324
  85. data/test/mocked/excon_mocked_test.rb +0 -174
  86. data/test/mocked/faraday_mocked_test.rb +0 -97
  87. data/test/mocked/http_mocked_test.rb +0 -135
  88. data/test/mocked/httpclient_mocked_test.rb +0 -258
  89. data/test/mocked/rest_client_mocked_test.rb +0 -109
  90. data/test/mocked/typhoeus_mocked_test.rb +0 -207
  91. data/test/models/widget.rb +0 -36
  92. data/test/noop/noop_test.rb +0 -145
  93. data/test/profiling/legacy_method_profiling_test.rb +0 -201
  94. data/test/profiling/method_profiling_test.rb +0 -631
  95. data/test/queues/delayed_job-client_test.rb +0 -95
  96. data/test/queues/delayed_job-worker_test.rb +0 -91
  97. data/test/reporter/reporter_test.rb +0 -14
  98. data/test/servers/delayed_job.rb +0 -107
  99. data/test/servers/rackapp_8101.rb +0 -29
  100. data/test/servers/rails3x_8140.rb +0 -96
  101. data/test/servers/rails4x_8140.rb +0 -96
  102. data/test/servers/rails5x_8140.rb +0 -95
  103. data/test/servers/rails5x_api_8150.rb +0 -78
  104. data/test/servers/sidekiq.rb +0 -29
  105. data/test/servers/sidekiq.yml +0 -7
  106. data/test/servers/sidekiq_initializer.rb +0 -25
  107. data/test/settings +0 -0
  108. data/test/support/auto_tracing_test.rb +0 -50
  109. data/test/support/backcompat_test.rb +0 -276
  110. data/test/support/config_test.rb +0 -149
  111. data/test/support/dnt_test.rb +0 -98
  112. data/test/support/init_report_test.rb +0 -25
  113. data/test/support/liboboe_settings_test.rb +0 -110
  114. data/test/support/logging_test.rb +0 -130
  115. data/test/support/sql_sanitize_test.rb +0 -55
  116. data/test/support/tracing_mode_test.rb +0 -33
  117. data/test/support/tvalias_test.rb +0 -15
  118. data/test/support/xtrace_test.rb +0 -41
@@ -1,109 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- unless defined?(JRUBY_VERSION)
5
- require 'minitest_helper'
6
- require 'webmock/minitest'
7
- require 'mocha/mini_test'
8
-
9
- class RestClientMockedTest < Minitest::Test
10
-
11
- def setup
12
- AppOpticsAPM::Context.clear
13
- WebMock.enable!
14
- WebMock.reset!
15
- WebMock.disable_net_connect!
16
- AppOpticsAPM.config_lock.synchronize do
17
- @sample_rate = AppOpticsAPM::Config[:sample_rate]
18
- end
19
- end
20
-
21
- def teardown
22
- AppOpticsAPM.config_lock.synchronize do
23
- AppOpticsAPM::Config[:sample_rate] = @sample_rate
24
- AppOpticsAPM::Config[:blacklist] = []
25
- end
26
- WebMock.reset!
27
- WebMock.allow_net_connect!
28
- WebMock.disable!
29
- end
30
-
31
- def test_tracing_sampling
32
- stub_request(:get, "http://127.0.0.1:8101/").to_return(status: 200, body: "", headers: {})
33
-
34
- AppOpticsAPM::API.start_trace('rest_client_tests') do
35
- RestClient::Resource.new('http://127.0.0.1:8101').get
36
- end
37
-
38
- assert_requested :get, "http://127.0.0.1:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*01$/}, times: 1
39
- refute AppOpticsAPM::Context.isValid
40
- end
41
-
42
- def test_tracing_not_sampling
43
- stub_request(:get, "http://127.0.0.2:8101/").to_return(status: 200, body: "", headers: {})
44
-
45
- AppOpticsAPM.config_lock.synchronize do
46
- AppOpticsAPM::Config[:sample_rate] = 0
47
- AppOpticsAPM::API.start_trace('rest_client_tests') do
48
- RestClient::Resource.new('http://127.0.0.2:8101').get
49
- end
50
- end
51
-
52
- assert_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B[0-9,A-F]*00$/}, times: 1
53
- assert_not_requested :get, "http://127.0.0.2:8101/", headers: {'X-Trace'=>/^2B0*$/}
54
- refute AppOpticsAPM::Context.isValid
55
- end
56
-
57
- def test_no_xtrace
58
- stub_request(:get, "http://127.0.0.3:8101/").to_return(status: 200, body: "", headers: {})
59
-
60
- RestClient::Resource.new('http://127.0.0.3:8101').get
61
-
62
- assert_requested :get, "http://127.0.0.3:8101/", times: 1
63
- assert_not_requested :get, "http://127.0.0.3:8101/", headers: {'X-Trace'=>/^.*$/}
64
- end
65
-
66
- def test_blacklisted
67
- stub_request(:get, "http://127.0.0.4:8101/").to_return(status: 200, body: "", headers: {})
68
-
69
- AppOpticsAPM.config_lock.synchronize do
70
- AppOpticsAPM::Config.blacklist << '127.0.0.4'
71
- AppOpticsAPM::API.start_trace('rest_client_tests') do
72
- RestClient::Resource.new('http://127.0.0.4:8101').get
73
- end
74
- end
75
-
76
- assert_requested :get, "http://127.0.0.4:8101/", times: 1
77
- assert_not_requested :get, "http://127.0.0.4:8101/", headers: {'X-Trace'=>/^.*$/}
78
- refute AppOpticsAPM::Context.isValid
79
- end
80
-
81
- def test_not_sampling_blacklisted
82
- stub_request(:get, "http://127.0.0.5:8101/").to_return(status: 200, body: "", headers: {})
83
-
84
- AppOpticsAPM.config_lock.synchronize do
85
- AppOpticsAPM::Config[:sample_rate] = 0
86
- AppOpticsAPM::Config.blacklist << '127.0.0.5'
87
- AppOpticsAPM::API.start_trace('rest_client_tests') do
88
- RestClient::Resource.new('http://127.0.0.5:8101').get
89
- end
90
- end
91
-
92
- assert_requested :get, "http://127.0.0.5:8101/", times: 1
93
- assert_not_requested :get, "http://127.0.0.5:8101/", headers: {'X-Trace'=>/^.*$/}
94
- refute AppOpticsAPM::Context.isValid
95
- end
96
-
97
- def test_preserves_custom_headers
98
- stub_request(:get, "http://127.0.0.6:8101/").to_return(status: 200, body: "", headers: {})
99
-
100
- AppOpticsAPM::API.start_trace('rest_client_tests') do
101
- RestClient::Resource.new('http://127.0.0.6:8101', headers: { 'Custom' => 'specialvalue' }).get
102
- end
103
-
104
- assert_requested :get, "http://127.0.0.6:8101/", headers: {'Custom'=>'specialvalue'}, times: 1
105
- refute AppOpticsAPM::Context.isValid
106
- end
107
-
108
- end
109
- end
@@ -1,207 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
-
4
- unless defined?(JRUBY_VERSION)
5
- require 'minitest_helper'
6
- require 'mocha/mini_test'
7
-
8
- class TyphoeusMockedTest < Minitest::Test
9
-
10
- def setup
11
- AppOpticsAPM::Context.clear
12
- AppOpticsAPM.config_lock.synchronize do
13
- @sample_rate = AppOpticsAPM::Config[:sample_rate]
14
- end
15
- end
16
-
17
- def teardown
18
- AppOpticsAPM::Context.clear
19
- AppOpticsAPM.config_lock.synchronize do
20
- AppOpticsAPM::Config[:sample_rate] = @sample_rate
21
- AppOpticsAPM::Config[:blacklist] = []
22
- end
23
- end
24
-
25
- ############# Typhoeus::Request ##############################################
26
-
27
- def test_tracing_sampling
28
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
29
- request = Typhoeus::Request.new("http://127.0.0.2:8101/", {:method=>:get})
30
- request.run
31
-
32
- assert request.options[:headers]['X-Trace']
33
- assert_match /^2B[0-9,A-F]*01$/,request.options[:headers]['X-Trace']
34
- end
35
-
36
- refute AppOpticsAPM::Context.isValid
37
- end
38
-
39
- def test_tracing_not_sampling
40
- AppOpticsAPM.config_lock.synchronize do
41
- AppOpticsAPM::Config[:sample_rate] = 0
42
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
43
- request = Typhoeus::Request.new("http://127.0.0.1:8101/", {:method=>:get})
44
- request.run
45
-
46
- assert request.options[:headers]['X-Trace']
47
- assert_match /^2B[0-9,A-F]*00$/, request.options[:headers]['X-Trace']
48
- refute_match /^2B0*$/, request.options[:headers]['X-Trace']
49
- end
50
- end
51
- refute AppOpticsAPM::Context.isValid
52
- end
53
-
54
- def test_no_xtrace
55
- request = Typhoeus::Request.new("http://127.0.0.1:8101/", {:method=>:get})
56
- request.run
57
-
58
- refute request.options[:headers]['X-Trace']
59
- refute AppOpticsAPM::Context.isValid
60
- end
61
-
62
- def test_blacklisted
63
- AppOpticsAPM.config_lock.synchronize do
64
- AppOpticsAPM::Config.blacklist << '127.0.0.1'
65
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
66
- request = Typhoeus::Request.new("http://127.0.0.1:8101/", {:method=>:get})
67
- request.run
68
-
69
- refute request.options[:headers]['X-Trace']
70
- end
71
- end
72
- refute AppOpticsAPM::Context.isValid
73
- end
74
-
75
- def test_not_sampling_blacklisted
76
- AppOpticsAPM.config_lock.synchronize do
77
- AppOpticsAPM::Config[:sample_rate] = 0
78
- AppOpticsAPM::Config.blacklist << '127.0.0.1'
79
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
80
- request = Typhoeus::Request.new("http://127.0.0.1:8101/", {:method=>:get})
81
- request.run
82
-
83
- refute request.options[:headers]['X-Trace']
84
- end
85
- end
86
- refute AppOpticsAPM::Context.isValid
87
- end
88
-
89
- def test_preserves_custom_headers
90
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
91
- request = Typhoeus::Request.new('http://127.0.0.6:8101', headers: { 'Custom' => 'specialvalue' }, :method => :get)
92
- request.run
93
-
94
- assert request.options[:headers]['Custom']
95
- assert_match /specialvalue/, request.options[:headers]['Custom']
96
- end
97
- refute AppOpticsAPM::Context.isValid
98
- end
99
-
100
-
101
- ############# Typhoeus::Hydra ##############################################
102
-
103
- def test_hydra_tracing_sampling
104
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
105
- hydra = Typhoeus::Hydra.hydra
106
- request_1 = Typhoeus::Request.new("http://127.0.0.2:8101/", {:method=>:get})
107
- request_2 = Typhoeus::Request.new("http://127.0.0.2:8101/counting_sheep", {:method=>:get})
108
- hydra.queue(request_1)
109
- hydra.queue(request_2)
110
- hydra.run
111
-
112
- assert request_1.options[:headers]['X-Trace'], "There is an X-Trace header"
113
- assert_match /^2B[0-9,A-F]*01$/, request_1.options[:headers]['X-Trace']
114
- assert request_2.options[:headers]['X-Trace'], "There is an X-Trace header"
115
- assert_match /^2B[0-9,A-F]*01$/, request_2.options[:headers]['X-Trace']
116
- end
117
- refute AppOpticsAPM::Context.isValid
118
- end
119
-
120
- def test_hydra_tracing_not_sampling
121
- AppOpticsAPM.config_lock.synchronize do
122
- AppOpticsAPM::Config[:sample_rate] = 0
123
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
124
- hydra = Typhoeus::Hydra.hydra
125
- request_1 = Typhoeus::Request.new("http://127.0.0.2:8101/", {:method=>:get})
126
- request_2 = Typhoeus::Request.new("http://127.0.0.2:8101/counting_sheep", {:method=>:get})
127
- hydra.queue(request_1)
128
- hydra.queue(request_2)
129
- hydra.run
130
-
131
- assert request_1.options[:headers]['X-Trace'], "There is an X-Trace header"
132
- assert_match /^2B[0-9,A-F]*00$/, request_1.options[:headers]['X-Trace']
133
- refute_match /^2B0*$/, request_1.options[:headers]['X-Trace']
134
- assert request_2.options[:headers]['X-Trace'], "There is an X-Trace header"
135
- assert_match /^2B[0-9,A-F]*00$/, request_2.options[:headers]['X-Trace']
136
- refute_match /^2B0*$/, request_2.options[:headers]['X-Trace']
137
- end
138
- end
139
- refute AppOpticsAPM::Context.isValid
140
- end
141
-
142
- def test_hydra_no_xtrace
143
- hydra = Typhoeus::Hydra.hydra
144
- request_1 = Typhoeus::Request.new("http://127.0.0.2:8101/", {:method=>:get})
145
- request_2 = Typhoeus::Request.new("http://127.0.0.2:8101/counting_sheep", {:method=>:get})
146
- hydra.queue(request_1)
147
- hydra.queue(request_2)
148
- hydra.run
149
-
150
- refute request_1.options[:headers]['X-Trace'], "There should not be an X-Trace header"
151
- refute request_2.options[:headers]['X-Trace'], "There should not be an X-Trace header"
152
- refute AppOpticsAPM::Context.isValid
153
- end
154
-
155
- def test_hydra_blacklisted
156
- AppOpticsAPM.config_lock.synchronize do
157
- AppOpticsAPM::Config.blacklist << '127.0.0.2'
158
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
159
- hydra = Typhoeus::Hydra.hydra
160
- request_1 = Typhoeus::Request.new("http://127.0.0.2:8101/", {:method=>:get})
161
- request_2 = Typhoeus::Request.new("http://127.0.0.2:8101/counting_sheep", {:method=>:get})
162
- hydra.queue(request_1)
163
- hydra.queue(request_2)
164
- hydra.run
165
-
166
- refute request_1.options[:headers]['X-Trace'], "There should not be an X-Trace header"
167
- refute request_2.options[:headers]['X-Trace'], "There should not be an X-Trace header"
168
- end
169
- end
170
- refute AppOpticsAPM::Context.isValid
171
- end
172
-
173
- def test_hydra_not_sampling_blacklisted
174
- AppOpticsAPM.config_lock.synchronize do
175
- AppOpticsAPM::Config[:sample_rate] = 0
176
- AppOpticsAPM::Config.blacklist << '127.0.0.2'
177
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
178
- hydra = Typhoeus::Hydra.hydra
179
- request_1 = Typhoeus::Request.new("http://127.0.0.2:8101/", {:method=>:get})
180
- request_2 = Typhoeus::Request.new("http://127.0.0.2:8101/counting_sheep", {:method=>:get})
181
- hydra.queue(request_1)
182
- hydra.queue(request_2)
183
- hydra.run
184
-
185
- refute request_1.options[:headers]['X-Trace'], "There should not be an X-Trace header"
186
- refute request_2.options[:headers]['X-Trace'], "There should not be an X-Trace header"
187
- end
188
- end
189
- refute AppOpticsAPM::Context.isValid
190
- end
191
-
192
-
193
- def test_hydra_preserves_custom_headers
194
- AppOpticsAPM::API.start_trace('typhoeus_tests') do
195
- hydra = Typhoeus::Hydra.hydra
196
- request = Typhoeus::Request.new('http://127.0.0.6:8101', headers: { 'Custom' => 'specialvalue' }, :method => :get)
197
- hydra.queue(request)
198
- hydra.run
199
-
200
- assert request.options[:headers]['Custom']
201
- assert_match /specialvalue/, request.options[:headers]['Custom']
202
- end
203
- refute AppOpticsAPM::Context.isValid
204
- end
205
-
206
- end
207
- end
@@ -1,36 +0,0 @@
1
- # Somehow the Padrino::Reloader v14 is detecting and loading
2
- # this file when it shouldn't. Block it from loading for
3
- # Padrino for now.
4
- unless defined?(Padrino)
5
- class Widget < ActiveRecord::Base
6
- def do_work(*args)
7
- Widget.first
8
- end
9
-
10
- def do_error(*args)
11
- raise "FakeTestError"
12
- end
13
- end
14
-
15
- if Rails.version >= '5.1'
16
- class CreateWidgets < ActiveRecord::Migration[5.1]
17
- def change
18
- create_table :widgets do |t|
19
- t.string :name
20
- t.text :description
21
- t.timestamps
22
- end
23
- end
24
- end
25
- else
26
- class CreateWidgets < ActiveRecord::Migration
27
- def change
28
- create_table :widgets do |t|
29
- t.string :name
30
- t.text :description
31
- t.timestamps
32
- end
33
- end
34
- end
35
- end
36
- end
@@ -1,145 +0,0 @@
1
- # Copyright (c) 2016 SolarWinds, LLC.
2
- # All rights reserved.
3
- #
4
-
5
- # Force noop by setting the platform to something we don't support
6
- RUBY_PLATFORM = 'noop'
7
-
8
- # These tests assert:
9
- # - that there is no instrumentation nor tracing in noop mode
10
- # - that the 'official' SDK methods don't create
11
-
12
- require 'minitest_helper'
13
- require 'rack/lobster'
14
- require 'net/http'
15
-
16
- class NoopTest < Minitest::Test
17
- include Rack::Test::Methods
18
-
19
- class ArrayTest < Array; end
20
-
21
- def setup
22
- clear_all_traces
23
- end
24
-
25
- def app
26
- @app = Rack::Builder.new {
27
- use Rack::CommonLogger
28
- use Rack::ShowExceptions
29
- use AppOpticsAPM::Rack
30
- map '/lobster' do
31
- use Rack::Lint
32
- run Rack::Lobster.new
33
- end
34
- }
35
- end
36
-
37
- def test_requests_still_work
38
- get '/lobster'
39
- traces = get_all_traces
40
- assert_equal 0, traces.count, 'generate no traces'
41
- assert AppOpticsAPM::Rack.noop?, 'This is not running in noop mode.'
42
- end
43
-
44
- def test_appoptics_config_doesnt_barf
45
- tm = AppOpticsAPM::Config[:tracing_mode]
46
- vb = AppOpticsAPM::Config[:verbose]
47
- la = AppOpticsAPM::Config[:rack][:log_args]
48
-
49
- # Test that we can set various things into AppOpticsAPM::Config still
50
- AppOpticsAPM::Config[:tracing_mode] = :always
51
- AppOpticsAPM::Config[:verbose] = false
52
- AppOpticsAPM::Config[:rack][:log_args] = true
53
-
54
- assert_equal :always, AppOpticsAPM::Config[:tracing_mode]
55
- assert_equal false, AppOpticsAPM::Config[:verbose]
56
- assert_equal true, AppOpticsAPM::Config[:rack][:log_args]
57
-
58
- # Restore the originals
59
- AppOpticsAPM::Config[:tracing_mode] = tm
60
- AppOpticsAPM::Config[:verbose] = vb
61
- AppOpticsAPM::Config[:rack][:log_args] = la
62
- end
63
-
64
- # ===== Make sure the AppOpticsAPM::Inst module does not exist ============================
65
- # this is the module in which all the instrumented methods are defined
66
- def test_not_instrumented
67
- refute ::AppOpticsAPM.const_defined?('Inst'), 'This should be noop mode, but instrumentation was found.'
68
- end
69
-
70
- # ===== Make sure the frameworks are not instrumented =====================================
71
- def test_rails_not_instrumented
72
- refute ::AppOpticsAPM.const_defined?('Rails'), 'This should be noop mode, but Rails is instrumented.'
73
- end
74
-
75
- def test_sinatra_not_instrumented
76
- refute ::AppOpticsAPM.const_defined?('Sinatra'), 'This should be noop mode, but Sinatra is instrumented.'
77
- end
78
-
79
- def test_grape_not_instrumented
80
- refute ::AppOpticsAPM.const_defined?('Grape'), 'This should be noop mode, but Grape is instrumented.'
81
- end
82
-
83
- def test_padrino_not_instrumented
84
- refute ::AppOpticsAPM.const_defined?('Padrino'), 'This should be noop mode, but Padrino is instrumented.'
85
- end
86
-
87
- # ===== Make sure the methods we document as SDK don't barf in noop mode ==================
88
-
89
- def test_start_trace_doesnt_barf
90
- AppOpticsAPM::API.start_trace('noop_test') do
91
- AppOpticsAPM::API.trace('blah_block') do
92
- "this block should not be traced"
93
- end
94
- end
95
-
96
- traces = get_all_traces
97
- assert_equal 0, traces.count, "generate no traces"
98
- end
99
-
100
- def test_trace_doesnt_barf
101
- AppOpticsAPM::API.trace('noop_test') do
102
- "this block should not be traced"
103
- end
104
-
105
- traces = get_all_traces
106
- assert_equal 0, traces.count, "generate no traces"
107
- end
108
-
109
- def test_method_profiling_doesnt_barf
110
- AppOpticsAPM::API.profile_method(ArrayTest, :sort)
111
-
112
- x = ArrayTest.new
113
- x.push(1).push(3).push(2)
114
- assert_equal [1, 2, 3], x.sort
115
-
116
- traces = get_all_traces
117
- assert_equal 0, traces.count, "generate no traces" end
118
-
119
- def test_profile_doesnt_barf
120
- def fib(n)
121
- return n if n <= 1
122
- n + fib(n-1)
123
- end
124
-
125
- def computation(n)
126
- AppOpticsAPM::API.profile('fib', { :n => n }) do
127
- fib(n)
128
- end
129
- end
130
-
131
- result = computation(4)
132
- assert_equal 10, result
133
-
134
-
135
- traces = get_all_traces
136
- assert_equal 0, traces.count, "generate no traces" end
137
-
138
- def test_log_info_doesnt_barf
139
- AppOpticsAPM::API.log_info(nil, {:ok => :yeah })
140
-
141
- traces = get_all_traces
142
- assert_equal 0, traces.count, "generate no traces"
143
- end
144
- end
145
-