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.
- checksums.yaml +4 -4
- data/Dockerfile_test +6 -7
- data/README.md +3 -3
- data/Rakefile +3 -2
- data/appoptics_apm.gemspec +2 -2
- data/docker-compose.yml +0 -22
- data/ext/oboe_metal/extconf.rb +4 -0
- data/lib/appoptics_apm/config.rb +11 -6
- data/lib/appoptics_apm/version.rb +1 -1
- metadata +3 -202
- data/gemfiles/delayed_job.gemfile +0 -36
- data/gemfiles/frameworks.gemfile +0 -44
- data/gemfiles/instrumentation_mocked.gemfile +0 -29
- data/gemfiles/libraries.gemfile +0 -85
- data/gemfiles/noop.gemfile +0 -17
- data/gemfiles/rails23.gemfile +0 -39
- data/gemfiles/rails30.gemfile +0 -42
- data/gemfiles/rails31.gemfile +0 -44
- data/gemfiles/rails32.gemfile +0 -54
- data/gemfiles/rails40.gemfile +0 -27
- data/gemfiles/rails41.gemfile +0 -27
- data/gemfiles/rails42.gemfile +0 -35
- data/gemfiles/rails50.gemfile +0 -44
- data/gemfiles/rails51.gemfile +0 -44
- data/test/benchmark/README.md +0 -65
- data/test/benchmark/logging_bench.rb +0 -54
- data/test/benchmark/with_libraries_gemfile/bunny_bench.rb +0 -69
- data/test/benchmark/with_rails5x_gemfile/action_controller5x_bench.rb +0 -43
- data/test/frameworks/apps/grape_nested.rb +0 -33
- data/test/frameworks/apps/grape_simple.rb +0 -80
- data/test/frameworks/apps/padrino_simple.rb +0 -80
- data/test/frameworks/apps/sinatra_simple.rb +0 -55
- data/test/frameworks/grape_test.rb +0 -286
- data/test/frameworks/padrino_test.rb +0 -222
- data/test/frameworks/rails3x_test.rb +0 -554
- data/test/frameworks/rails4x_test.rb +0 -570
- data/test/frameworks/rails5x_api_test.rb +0 -210
- data/test/frameworks/rails5x_test.rb +0 -376
- data/test/frameworks/rails_shared_tests.rb +0 -172
- data/test/frameworks/sinatra_test.rb +0 -140
- data/test/instrumentation/bunny_client_test.rb +0 -276
- data/test/instrumentation/bunny_consumer_test.rb +0 -204
- data/test/instrumentation/curb_test.rb +0 -398
- data/test/instrumentation/dalli_test.rb +0 -177
- data/test/instrumentation/em_http_request_test.rb +0 -89
- data/test/instrumentation/excon_test.rb +0 -231
- data/test/instrumentation/faraday_test.rb +0 -228
- data/test/instrumentation/http_test.rb +0 -143
- data/test/instrumentation/httpclient_test.rb +0 -304
- data/test/instrumentation/memcache_test.rb +0 -260
- data/test/instrumentation/memcached_test.rb +0 -229
- data/test/instrumentation/mongo_v1_test.rb +0 -479
- data/test/instrumentation/mongo_v2_index_test.rb +0 -124
- data/test/instrumentation/mongo_v2_test.rb +0 -584
- data/test/instrumentation/mongo_v2_view_test.rb +0 -435
- data/test/instrumentation/moped_test.rb +0 -517
- data/test/instrumentation/rack_test.rb +0 -165
- data/test/instrumentation/redis_hashes_test.rb +0 -268
- data/test/instrumentation/redis_keys_test.rb +0 -321
- data/test/instrumentation/redis_lists_test.rb +0 -310
- data/test/instrumentation/redis_misc_test.rb +0 -163
- data/test/instrumentation/redis_sets_test.rb +0 -296
- data/test/instrumentation/redis_sortedsets_test.rb +0 -328
- data/test/instrumentation/redis_strings_test.rb +0 -349
- data/test/instrumentation/resque_test.rb +0 -185
- data/test/instrumentation/rest-client_test.rb +0 -288
- data/test/instrumentation/sequel_mysql2_test.rb +0 -353
- data/test/instrumentation/sequel_mysql_test.rb +0 -334
- data/test/instrumentation/sequel_pg_test.rb +0 -336
- data/test/instrumentation/sidekiq-client_test.rb +0 -159
- data/test/instrumentation/sidekiq-worker_test.rb +0 -180
- data/test/instrumentation/twitter-cassandra_test.rb +0 -424
- data/test/instrumentation/typhoeus_test.rb +0 -284
- data/test/jobs/delayed_job/db_worker_job.rb +0 -29
- data/test/jobs/delayed_job/error_worker_job.rb +0 -10
- data/test/jobs/delayed_job/remote_call_worker_job.rb +0 -20
- data/test/jobs/resque/db_worker_job.rb +0 -29
- data/test/jobs/resque/error_worker_job.rb +0 -10
- data/test/jobs/resque/remote_call_worker_job.rb +0 -20
- data/test/jobs/sidekiq/db_worker_job.rb +0 -29
- data/test/jobs/sidekiq/error_worker_job.rb +0 -10
- data/test/jobs/sidekiq/remote_call_worker_job.rb +0 -20
- data/test/minitest_helper.rb +0 -277
- data/test/mocked/curb_mocked_test.rb +0 -324
- data/test/mocked/excon_mocked_test.rb +0 -174
- data/test/mocked/faraday_mocked_test.rb +0 -97
- data/test/mocked/http_mocked_test.rb +0 -135
- data/test/mocked/httpclient_mocked_test.rb +0 -258
- data/test/mocked/rest_client_mocked_test.rb +0 -109
- data/test/mocked/typhoeus_mocked_test.rb +0 -207
- data/test/models/widget.rb +0 -36
- data/test/noop/noop_test.rb +0 -145
- data/test/profiling/legacy_method_profiling_test.rb +0 -201
- data/test/profiling/method_profiling_test.rb +0 -631
- data/test/queues/delayed_job-client_test.rb +0 -95
- data/test/queues/delayed_job-worker_test.rb +0 -91
- data/test/reporter/reporter_test.rb +0 -14
- data/test/servers/delayed_job.rb +0 -107
- data/test/servers/rackapp_8101.rb +0 -29
- data/test/servers/rails3x_8140.rb +0 -96
- data/test/servers/rails4x_8140.rb +0 -96
- data/test/servers/rails5x_8140.rb +0 -95
- data/test/servers/rails5x_api_8150.rb +0 -78
- data/test/servers/sidekiq.rb +0 -29
- data/test/servers/sidekiq.yml +0 -7
- data/test/servers/sidekiq_initializer.rb +0 -25
- data/test/settings +0 -0
- data/test/support/auto_tracing_test.rb +0 -50
- data/test/support/backcompat_test.rb +0 -276
- data/test/support/config_test.rb +0 -149
- data/test/support/dnt_test.rb +0 -98
- data/test/support/init_report_test.rb +0 -25
- data/test/support/liboboe_settings_test.rb +0 -110
- data/test/support/logging_test.rb +0 -130
- data/test/support/sql_sanitize_test.rb +0 -55
- data/test/support/tracing_mode_test.rb +0 -33
- data/test/support/tvalias_test.rb +0 -15
- data/test/support/xtrace_test.rb +0 -41
@@ -1,95 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'minitest_helper'
|
5
|
-
require_relative "../jobs/delayed_job/remote_call_worker_job"
|
6
|
-
require_relative "../jobs/delayed_job/db_worker_job"
|
7
|
-
require_relative "../jobs/delayed_job/error_worker_job"
|
8
|
-
require_relative '../models/widget'
|
9
|
-
|
10
|
-
# Delete all pre-existing jobs before we start
|
11
|
-
Delayed::Job.delete_all
|
12
|
-
|
13
|
-
class DelayedJobClientTest < Minitest::Test
|
14
|
-
def setup
|
15
|
-
clear_all_traces
|
16
|
-
@collect_backtraces = AppOpticsAPM::Config[:delayed_jobclient][:collect_backtraces]
|
17
|
-
@log_args = AppOpticsAPM::Config[:delayed_jobclient][:log_args]
|
18
|
-
end
|
19
|
-
|
20
|
-
def teardown
|
21
|
-
AppOpticsAPM::Config[:delayed_jobclient][:collect_backtraces] = @collect_backtraces
|
22
|
-
AppOpticsAPM::Config[:delayed_jobclient][:log_args] = @log_args
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_delay
|
26
|
-
w = Widget.new(:name => 'blah', :description => 'This is a wonderful widget.')
|
27
|
-
w.save
|
28
|
-
|
29
|
-
AppOpticsAPM::API.start_trace('dj_delay') do
|
30
|
-
w.delay.do_work(1, 2, 3)
|
31
|
-
end
|
32
|
-
|
33
|
-
sleep 15
|
34
|
-
|
35
|
-
traces = get_all_traces
|
36
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
37
|
-
|
38
|
-
assert_equal 'dj_delay', traces[0]['Layer']
|
39
|
-
assert_equal 'entry', traces[0]['Label']
|
40
|
-
assert_equal 'delayed_job-client', traces[1]['Layer']
|
41
|
-
assert_equal 'entry', traces[1]['Label']
|
42
|
-
assert_equal 'pushq', traces[1]['Spec']
|
43
|
-
assert_equal 'DelayedJob', traces[1]['Flavor']
|
44
|
-
assert_equal 'Widget#do_work', traces[1]['JobName']
|
45
|
-
assert_equal 'delayed_job-client', traces[2]['Layer']
|
46
|
-
assert_equal 'exit', traces[2]['Label']
|
47
|
-
assert_equal 'dj_delay', traces[3]['Layer']
|
48
|
-
assert_equal 'exit', traces[3]['Label']
|
49
|
-
|
50
|
-
end
|
51
|
-
|
52
|
-
def test_collect_backtraces_default_value
|
53
|
-
assert_equal AppOpticsAPM::Config[:delayed_jobclient][:collect_backtraces], false, "default backtrace collection"
|
54
|
-
end
|
55
|
-
|
56
|
-
def test_log_args_default_value
|
57
|
-
assert_equal AppOpticsAPM::Config[:delayed_jobclient][:log_args], true, "log_args default "
|
58
|
-
end
|
59
|
-
|
60
|
-
def test_obey_collect_backtraces_when_false
|
61
|
-
AppOpticsAPM::Config[:delayed_jobclient][:collect_backtraces] = false
|
62
|
-
|
63
|
-
w = Widget.new(:name => 'blah', :description => 'This is a wonderful widget.')
|
64
|
-
w.save
|
65
|
-
|
66
|
-
AppOpticsAPM::API.start_trace('dj_delay') do
|
67
|
-
w.delay.do_work(1, 2, 3)
|
68
|
-
end
|
69
|
-
|
70
|
-
traces = get_all_traces
|
71
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
72
|
-
|
73
|
-
assert_equal 'delayed_job-client', traces[1]['Layer']
|
74
|
-
assert_equal 'entry', traces[1]['Label']
|
75
|
-
assert_equal false, traces[1].key?('Backtrace')
|
76
|
-
end
|
77
|
-
|
78
|
-
def test_obey_collect_backtraces_when_true
|
79
|
-
AppOpticsAPM::Config[:delayed_jobclient][:collect_backtraces] = true
|
80
|
-
|
81
|
-
w = Widget.new(:name => 'blah', :description => 'This is a wonderful widget.')
|
82
|
-
w.save
|
83
|
-
|
84
|
-
AppOpticsAPM::API.start_trace('dj_delay') do
|
85
|
-
w.delay.do_work(1, 2, 3)
|
86
|
-
end
|
87
|
-
|
88
|
-
traces = get_all_traces
|
89
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
90
|
-
|
91
|
-
assert_equal 'delayed_job-client', traces[1]['Layer']
|
92
|
-
assert_equal 'entry', traces[1]['Label']
|
93
|
-
assert_equal true, traces[1].key?('Backtrace')
|
94
|
-
end
|
95
|
-
end
|
@@ -1,91 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'minitest_helper'
|
5
|
-
require_relative '../jobs/delayed_job/remote_call_worker_job'
|
6
|
-
require_relative '../jobs/delayed_job/db_worker_job'
|
7
|
-
require_relative '../jobs/delayed_job/error_worker_job'
|
8
|
-
require_relative '../models/widget'
|
9
|
-
|
10
|
-
class DelayedJobWorkerTest < Minitest::Test
|
11
|
-
def setup
|
12
|
-
# Delete all pre-existing jobs before we start
|
13
|
-
Delayed::Job.delete_all
|
14
|
-
|
15
|
-
clear_all_traces
|
16
|
-
@collect_backtraces = AppOpticsAPM::Config[:delayed_jobworker][:collect_backtraces]
|
17
|
-
@log_args = AppOpticsAPM::Config[:delayed_jobworker][:log_args]
|
18
|
-
end
|
19
|
-
|
20
|
-
def teardown
|
21
|
-
AppOpticsAPM::Config[:delayed_jobworker][:collect_backtraces] = @collect_backtraces
|
22
|
-
AppOpticsAPM::Config[:delayed_jobworker][:log_args] = @log_args
|
23
|
-
end
|
24
|
-
|
25
|
-
def test_reports_version_init
|
26
|
-
init_kvs = ::AppOpticsAPM::Util.build_init_report
|
27
|
-
assert init_kvs.key?('Ruby.delayed_job.Version')
|
28
|
-
assert_equal Gem.loaded_specs['delayed_job'].version.to_s, init_kvs['Ruby.delayed_job.Version']
|
29
|
-
end
|
30
|
-
|
31
|
-
def test_job_run
|
32
|
-
w = Widget.new(:name => 'blah', :description => 'This is a wonderful wonderful widget.')
|
33
|
-
w.save
|
34
|
-
|
35
|
-
w.delay.do_work(1, 2, 3)
|
36
|
-
|
37
|
-
sleep 15
|
38
|
-
|
39
|
-
traces = get_all_traces
|
40
|
-
assert_equal 2, traces.count, "Trace count"
|
41
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
42
|
-
|
43
|
-
assert_equal 'delayed_job-worker', traces[0]['Layer']
|
44
|
-
assert_equal 'entry', traces[0]['Label']
|
45
|
-
assert_equal 'job', traces[0]['Spec']
|
46
|
-
assert_equal 'DelayedJob', traces[0]['Flavor']
|
47
|
-
assert_equal 'Widget#do_work', traces[0]['JobName']
|
48
|
-
assert_equal 0, traces[0]['priority']
|
49
|
-
assert_equal 0, traces[0]['attempts']
|
50
|
-
assert traces[0].key?('WorkerName'), "Worker Name"
|
51
|
-
assert traces[0].key?('SampleRate')
|
52
|
-
assert traces[0].key?('SampleSource')
|
53
|
-
assert_equal false, traces[0].key?('Backtrace')
|
54
|
-
|
55
|
-
assert_equal 'delayed_job-worker', traces[1]['Layer']
|
56
|
-
assert_equal 'exit', traces[1]['Label']
|
57
|
-
end
|
58
|
-
|
59
|
-
def test_jobs_with_errors
|
60
|
-
w = Widget.new(:name => 'blah', :description => 'This is a wonderful wonderful widget.')
|
61
|
-
w.save
|
62
|
-
|
63
|
-
w.delay.do_error(1, 2, 3)
|
64
|
-
|
65
|
-
sleep 15
|
66
|
-
|
67
|
-
traces = get_all_traces
|
68
|
-
assert_equal 3, traces.count, "Trace count"
|
69
|
-
assert valid_edges?(traces), "Invalid edge in traces"
|
70
|
-
|
71
|
-
assert_equal 'delayed_job-worker', traces[0]['Layer']
|
72
|
-
assert_equal 'entry', traces[0]['Label']
|
73
|
-
|
74
|
-
assert_equal 'error', traces[1]['Label']
|
75
|
-
assert_equal 'FakeTestError', traces[1]['ErrorMsg']
|
76
|
-
assert traces[1].key?('Backtrace')
|
77
|
-
assert traces[1].key?('ErrorClass')
|
78
|
-
|
79
|
-
assert_equal 'delayed_job-worker', traces[2]['Layer']
|
80
|
-
assert_equal 'exit', traces[2]['Label']
|
81
|
-
|
82
|
-
end
|
83
|
-
|
84
|
-
def test_collect_backtraces_default_value
|
85
|
-
assert_equal AppOpticsAPM::Config[:delayed_jobworker][:collect_backtraces], false, "default backtrace collection"
|
86
|
-
end
|
87
|
-
|
88
|
-
def test_log_args_default_value
|
89
|
-
assert_equal AppOpticsAPM::Config[:delayed_jobworker][:log_args], true, "log_args default "
|
90
|
-
end
|
91
|
-
end
|
@@ -1,14 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
require 'minitest_helper'
|
5
|
-
|
6
|
-
class APPOPTICSReporterTest < Minitest::Test
|
7
|
-
def reporter_has_start_method
|
8
|
-
assert_equal true, AppOpticsAPM::Reporter.respond_to?(:start), "has restart method"
|
9
|
-
end
|
10
|
-
|
11
|
-
def reporter_has_restart_method
|
12
|
-
assert_equal true, AppOpticsAPM::Reporter.respond_to?(:restart), "has start method"
|
13
|
-
end
|
14
|
-
end
|
data/test/servers/delayed_job.rb
DELETED
@@ -1,107 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
# This is a Rails app that launches a DelayedJob worker
|
5
|
-
# in a background thread.
|
6
|
-
#
|
7
|
-
require "rails/all"
|
8
|
-
require "delayed_job"
|
9
|
-
require "action_controller/railtie"
|
10
|
-
require 'rack/handler/puma'
|
11
|
-
require File.expand_path(File.dirname(__FILE__) + '/../models/widget')
|
12
|
-
|
13
|
-
AppOpticsAPM.logger.level = Logger::DEBUG
|
14
|
-
AppOpticsAPM.logger.info "[appoptics_apm/info] Starting background utility rails app on localhost:8140."
|
15
|
-
|
16
|
-
AppOpticsAPM::Test.set_postgresql_env
|
17
|
-
|
18
|
-
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
19
|
-
|
20
|
-
unless ActiveRecord::Base.connection.table_exists? :delayed_jobs
|
21
|
-
AppOpticsAPM.logger.info "[appoptics_apm/servers] Creating DelayedJob DB table."
|
22
|
-
|
23
|
-
dj_dir = Gem::Specification.find_by_name('delayed_job_active_record').gem_dir
|
24
|
-
template = File.open(File.join(dj_dir, "lib/generators/delayed_job/templates/migration.rb"))
|
25
|
-
|
26
|
-
migration_context = Class.new do
|
27
|
-
def get_binding
|
28
|
-
binding
|
29
|
-
end
|
30
|
-
|
31
|
-
private
|
32
|
-
|
33
|
-
def migration_version
|
34
|
-
if ActiveRecord::VERSION::MAJOR >= 5
|
35
|
-
"[#{ActiveRecord::VERSION::MAJOR}.#{ActiveRecord::VERSION::MINOR}]"
|
36
|
-
end
|
37
|
-
end
|
38
|
-
end
|
39
|
-
migration_ruby = ERB.new(template.read).result(migration_context.new.get_binding)
|
40
|
-
eval migration_ruby
|
41
|
-
|
42
|
-
ActiveRecord::Migration.run(CreateDelayedJobs)
|
43
|
-
end
|
44
|
-
|
45
|
-
unless ActiveRecord::Base.connection.table_exists? 'widgets'
|
46
|
-
ActiveRecord::Migration.run(CreateWidgets)
|
47
|
-
end
|
48
|
-
|
49
|
-
class Rails40MetalStack < Rails::Application
|
50
|
-
routes.append do
|
51
|
-
get "/hello/world" => "hello#world"
|
52
|
-
get "/hello/metal" => "ferro#world"
|
53
|
-
end
|
54
|
-
|
55
|
-
config.cache_classes = true
|
56
|
-
config.eager_load = false
|
57
|
-
config.active_support.deprecation = :stderr
|
58
|
-
config.middleware.delete "Rack::Lock"
|
59
|
-
config.middleware.delete "ActionDispatch::Flash"
|
60
|
-
config.middleware.delete "ActionDispatch::BestStandardsSupport"
|
61
|
-
config.secret_token = "49837489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yrpiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
|
62
|
-
config.secret_key_base = "2048671-96803948"
|
63
|
-
end
|
64
|
-
|
65
|
-
#################################################
|
66
|
-
# Controllers
|
67
|
-
#################################################
|
68
|
-
|
69
|
-
class HelloController < ActionController::Base
|
70
|
-
def world
|
71
|
-
render :text => "Hello world!"
|
72
|
-
end
|
73
|
-
end
|
74
|
-
|
75
|
-
class FerroController < ActionController::Metal
|
76
|
-
include AbstractController::Rendering
|
77
|
-
|
78
|
-
def world
|
79
|
-
render :text => "Hello world!"
|
80
|
-
end
|
81
|
-
end
|
82
|
-
|
83
|
-
Delayed::Job.delete_all
|
84
|
-
|
85
|
-
@worker_options = {
|
86
|
-
:min_priority => ENV['MIN_PRIORITY'],
|
87
|
-
:max_priority => ENV['MAX_PRIORITY'],
|
88
|
-
:queues => (ENV['QUEUES'] || ENV['QUEUE'] || '').split(','),
|
89
|
-
:quiet => ENV['QUIET']
|
90
|
-
}
|
91
|
-
|
92
|
-
@worker_options[:sleep_delay] = ENV['SLEEP_DELAY'].to_i if ENV['SLEEP_DELAY']
|
93
|
-
@worker_options[:read_ahead] = ENV['READ_AHEAD'].to_i if ENV['READ_AHEAD']
|
94
|
-
|
95
|
-
AppOpticsAPM.logger.info "[appoptics_apm/servers] Starting up background DelayedJob."
|
96
|
-
|
97
|
-
#Delayed::Worker.delay_jobs = false
|
98
|
-
Delayed::Worker.max_attempts = 1
|
99
|
-
Delayed::Worker.sleep_delay = 10
|
100
|
-
|
101
|
-
Thread.new do
|
102
|
-
Delayed::Worker.new(@worker_options).start
|
103
|
-
end
|
104
|
-
|
105
|
-
# Allow it to boot
|
106
|
-
AppOpticsAPM.logger.info "[appoptics_apm/servers] Waiting 5 seconds for DJ to boot..."
|
107
|
-
sleep 5
|
@@ -1,29 +0,0 @@
|
|
1
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
2
|
-
# All rights reserved.
|
3
|
-
|
4
|
-
# This is a Rack application that is booted in a background
|
5
|
-
# thread and listens on port 8101.
|
6
|
-
#
|
7
|
-
require 'rack/handler/puma'
|
8
|
-
require 'appoptics_apm/inst/rack'
|
9
|
-
|
10
|
-
AppOpticsAPM.logger.info "[appoptics_apm/info] Starting background utility rack app on localhost:8101."
|
11
|
-
|
12
|
-
Thread.new do
|
13
|
-
app = Rack::Builder.new {
|
14
|
-
use AppOpticsAPM::Rack
|
15
|
-
map "/" do
|
16
|
-
run Proc.new { [200, {"Content-Type" => "text/html"}, ['Hello AppOpticsAPM!']] }
|
17
|
-
end
|
18
|
-
|
19
|
-
map "/redirectme" do
|
20
|
-
run Proc.new { [301, {"Location" => "/", "Content-Type" => "text/html"}, ['']] }
|
21
|
-
end
|
22
|
-
}
|
23
|
-
|
24
|
-
Rack::Handler::Puma.run(app, {:Host => '127.0.0.1', :Port => 8101})
|
25
|
-
end
|
26
|
-
|
27
|
-
# Allow Thin to boot.
|
28
|
-
sleep(2)
|
29
|
-
|
@@ -1,96 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
3
|
-
# All rights reserved.
|
4
|
-
|
5
|
-
# This is a Rails stack that launches on a background
|
6
|
-
# thread and listens on port 8140.
|
7
|
-
#
|
8
|
-
require "rails/all"
|
9
|
-
require "action_controller/railtie"
|
10
|
-
require 'rack/handler/puma'
|
11
|
-
require File.expand_path(File.dirname(__FILE__) + '/../models/widget')
|
12
|
-
|
13
|
-
AppOpticsAPM.logger.info "[appoptics_apm/info] Starting background utility rails app on localhost:8140."
|
14
|
-
|
15
|
-
if ENV['DBTYPE'] == 'mysql2'
|
16
|
-
AppOpticsAPM::Test.set_mysql2_env
|
17
|
-
elsif ENV['DBTYPE'] == 'mysql'
|
18
|
-
AppOpticsAPM::Test.set_mysql_env
|
19
|
-
else
|
20
|
-
AppOpticsAPM.logger.warn "Unidentified DBTYPE: #{ENV['DBTYPE']}" unless ENV['DBTYPE'] == "postgresql"
|
21
|
-
AppOpticsAPM.logger.debug "Defaulting to postgres DB for background Rails server."
|
22
|
-
AppOpticsAPM::Test.set_postgresql_env
|
23
|
-
end
|
24
|
-
|
25
|
-
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
26
|
-
|
27
|
-
unless ActiveRecord::Base.connection.table_exists? 'widgets'
|
28
|
-
CreateWidgets.migrate(:up)
|
29
|
-
end
|
30
|
-
|
31
|
-
class Rails32MetalStack < Rails::Application
|
32
|
-
routes.append do
|
33
|
-
get "/hello/world" => "hello#world"
|
34
|
-
get "/hello/:id/show" => "hello#show"
|
35
|
-
get "/hello/metal" => "ferro#world"
|
36
|
-
get "/hello/db" => "hello#db"
|
37
|
-
get "/hello/servererror" => "hello#servererror"
|
38
|
-
end
|
39
|
-
|
40
|
-
config.cache_classes = true
|
41
|
-
config.eager_load = false
|
42
|
-
config.active_support.deprecation = :stderr
|
43
|
-
config.middleware.delete "Rack::Lock"
|
44
|
-
config.middleware.delete "ActionDispatch::Flash"
|
45
|
-
config.middleware.delete "ActionDispatch::BestStandardsSupport"
|
46
|
-
config.secret_token = "498374i49qkuweoiuoqwehisuakshdhksadhaisdy78o34y138974xyqu9rmye8yrpiokeuioqwzyo8uxftoyqiuxrhm3iou1hrzmjk"
|
47
|
-
config.secret_key_base = "2048671-96803948"
|
48
|
-
end
|
49
|
-
|
50
|
-
#################################################
|
51
|
-
# Controllers
|
52
|
-
#################################################
|
53
|
-
|
54
|
-
class HelloController < ActionController::Base
|
55
|
-
def world
|
56
|
-
render :text => "Hello world!"
|
57
|
-
end
|
58
|
-
|
59
|
-
def show
|
60
|
-
render :text => "Hello Number #{params[:id]}"
|
61
|
-
end
|
62
|
-
|
63
|
-
def db
|
64
|
-
# Create a widget
|
65
|
-
w1 = Widget.new(:name => 'blah', :description => 'This is an amazing widget.')
|
66
|
-
w1.save
|
67
|
-
|
68
|
-
# query for that widget
|
69
|
-
w2 = Widget.where(:name => 'blah').first
|
70
|
-
w2.delete
|
71
|
-
|
72
|
-
render :text => "Hello database!"
|
73
|
-
end
|
74
|
-
|
75
|
-
def servererror
|
76
|
-
render :plain => "broken", :status => 500
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class FerroController < ActionController::Metal
|
81
|
-
include AbstractController::Rendering
|
82
|
-
|
83
|
-
def world
|
84
|
-
self.response_body = "Hello world!"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
AppOpticsAPM::API.profile_method(FerroController, :world)
|
89
|
-
|
90
|
-
Rails32MetalStack.initialize!
|
91
|
-
|
92
|
-
Thread.new do
|
93
|
-
Rack::Handler::Puma.run(Rails32MetalStack.to_app, {:Host => '127.0.0.1', :Port => 8140})
|
94
|
-
end
|
95
|
-
|
96
|
-
sleep(2)
|
@@ -1,96 +0,0 @@
|
|
1
|
-
##
|
2
|
-
# Copyright (c) 2016 SolarWinds, LLC.
|
3
|
-
# All rights reserved.
|
4
|
-
|
5
|
-
# This is a Rails stack that launches on a background
|
6
|
-
# thread and listens on port 8140.
|
7
|
-
#
|
8
|
-
require "rails/all"
|
9
|
-
require "action_controller/railtie"
|
10
|
-
require 'rack/handler/puma'
|
11
|
-
require File.expand_path(File.dirname(__FILE__) + '/../models/widget')
|
12
|
-
|
13
|
-
AppOpticsAPM.logger.info "[appoptics_apm/info] Starting background utility rails app on localhost:8140."
|
14
|
-
|
15
|
-
if ENV['DBTYPE'] == 'mysql2'
|
16
|
-
AppOpticsAPM::Test.set_mysql2_env
|
17
|
-
elsif ENV['DBTYPE'] == 'mysql'
|
18
|
-
AppOpticsAPM::Test.set_mysql_env
|
19
|
-
else
|
20
|
-
AppOpticsAPM.logger.warn "Unidentified DBTYPE: #{ENV['DBTYPE']}" unless ENV['DBTYPE'] == "postgresql"
|
21
|
-
AppOpticsAPM.logger.debug "Defaulting to postgres DB for background Rails server."
|
22
|
-
AppOpticsAPM::Test.set_postgresql_env
|
23
|
-
end
|
24
|
-
|
25
|
-
ActiveRecord::Base.establish_connection(ENV['DATABASE_URL'])
|
26
|
-
|
27
|
-
unless ActiveRecord::Base.connection.table_exists? 'widgets'
|
28
|
-
ActiveRecord::Migration.run(CreateWidgets)
|
29
|
-
end
|
30
|
-
|
31
|
-
class Rails40MetalStack < Rails::Application
|
32
|
-
routes.append do
|
33
|
-
get "/hello/world" => "hello#world"
|
34
|
-
get "/hello/:id/show" => "hello#show"
|
35
|
-
get "/hello/metal" => "ferro#world"
|
36
|
-
get "/hello/db" => "hello#db"
|
37
|
-
get "/hello/servererror" => "hello#servererror"
|
38
|
-
end
|
39
|
-
|
40
|
-
config.cache_classes = true
|
41
|
-
config.eager_load = false
|
42
|
-
config.active_support.deprecation = :stderr
|
43
|
-
config.middleware.delete "Rack::Lock"
|
44
|
-
config.middleware.delete "ActionDispatch::Flash"
|
45
|
-
config.middleware.delete "ActionDispatch::BestStandardsSupport"
|
46
|
-
config.secret_token = "49830489qkuweoiuoqwehisuakshdjksadhaisdy78o34y138974xyqp9rmye8yypiokeuioqwzyoiuxftoyqiuxrhm3iou1hrzmjk"
|
47
|
-
config.secret_key_base = "2048671-96803948"
|
48
|
-
end
|
49
|
-
|
50
|
-
#################################################
|
51
|
-
# Controllers
|
52
|
-
#################################################
|
53
|
-
|
54
|
-
class HelloController < ActionController::Base
|
55
|
-
def world
|
56
|
-
render :text => "Hello world!"
|
57
|
-
end
|
58
|
-
|
59
|
-
def show
|
60
|
-
render :text => "Hello Number #{params[:id]}"
|
61
|
-
end
|
62
|
-
|
63
|
-
def db
|
64
|
-
# Create a widget
|
65
|
-
w1 = Widget.new(:name => 'blah', :description => 'This is an amazing widget.')
|
66
|
-
w1.save
|
67
|
-
|
68
|
-
# query for that widget
|
69
|
-
w2 = Widget.where(:name => 'blah').first
|
70
|
-
w2.delete
|
71
|
-
|
72
|
-
render :text => "Hello database!"
|
73
|
-
end
|
74
|
-
|
75
|
-
def servererror
|
76
|
-
render :plain => "broken", :status => 500
|
77
|
-
end
|
78
|
-
end
|
79
|
-
|
80
|
-
class FerroController < ActionController::Metal
|
81
|
-
include AbstractController::Rendering
|
82
|
-
|
83
|
-
def world
|
84
|
-
self.response_body = "Hello world!"
|
85
|
-
end
|
86
|
-
end
|
87
|
-
|
88
|
-
AppOpticsAPM::API.profile_method(FerroController, :world)
|
89
|
-
|
90
|
-
Rails40MetalStack.initialize!
|
91
|
-
|
92
|
-
Thread.new do
|
93
|
-
Rack::Handler::Puma.run(Rails40MetalStack.to_app, {:Host => '127.0.0.1', :Port => 8140, :Threads => "0:1"})
|
94
|
-
end
|
95
|
-
|
96
|
-
sleep(2)
|