appoptics_apm 4.2.2 → 4.2.3
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.yardopts +1 -3
- data/Gemfile +0 -2
- data/README.md +119 -95
- data/examples/SDK/01_basic_tracing.rb +67 -0
- data/ext/oboe_metal/src/VERSION +1 -1
- data/lib/appoptics_apm/api.rb +10 -9
- data/lib/appoptics_apm/api/layerinit.rb +1 -1
- data/lib/appoptics_apm/api/logging.rb +41 -14
- data/lib/appoptics_apm/api/metrics.rb +34 -0
- data/lib/appoptics_apm/api/profiling.rb +5 -0
- data/lib/appoptics_apm/api/tracing.rb +33 -148
- data/lib/appoptics_apm/api/util.rb +3 -9
- data/lib/appoptics_apm/base.rb +11 -12
- data/lib/appoptics_apm/frameworks/padrino/templates.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils.rb +1 -1
- data/lib/appoptics_apm/frameworks/rails/inst/connection_adapters/utils5x.rb +1 -1
- data/lib/appoptics_apm/inst/bunny-consumer.rb +1 -2
- data/lib/appoptics_apm/inst/delayed_job.rb +4 -4
- data/lib/appoptics_apm/inst/em-http-request.rb +1 -1
- data/lib/appoptics_apm/inst/rack.rb +1 -0
- data/lib/appoptics_apm/inst/redis.rb +1 -1
- data/lib/appoptics_apm/inst/resque.rb +1 -1
- data/lib/appoptics_apm/inst/sidekiq-worker.rb +1 -3
- data/lib/appoptics_apm/loading.rb +3 -4
- data/lib/appoptics_apm/logger.rb +1 -1
- data/lib/appoptics_apm/sdk.rb +317 -0
- data/lib/appoptics_apm/support.rb +0 -17
- data/lib/appoptics_apm/test.rb +1 -1
- data/lib/appoptics_apm/util.rb +4 -3
- data/lib/appoptics_apm/version.rb +1 -1
- data/lib/appoptics_apm/xtrace.rb +3 -3
- data/lib/joboe_metal.rb +2 -4
- data/lib/oboe_metal.rb +5 -5
- data/lib/rails/generators/appoptics_apm/templates/appoptics_apm_initializer.rb +5 -4
- data/run_tests_docker.rb +6 -0
- metadata +5 -9
- data/examples/DNT.md +0 -35
- data/examples/instrumenting_metal_controller.rb +0 -8
- data/examples/puma_on_heroku_config.rb +0 -17
- data/examples/tracing_async_threads.rb +0 -124
- data/examples/tracing_background_jobs.rb +0 -53
- data/examples/tracing_forked_processes.rb +0 -99
- data/examples/unicorn_on_heroku_config.rb +0 -28
@@ -1,99 +0,0 @@
|
|
1
|
-
#
|
2
|
-
# This sample demonstrates how to instrument a main loop that
|
3
|
-
# retrieves work and calls fork to do the actual work
|
4
|
-
#
|
5
|
-
|
6
|
-
require 'math'
|
7
|
-
require 'oboe'
|
8
|
-
|
9
|
-
AppOpticsAPM::Config[:tracing_mode] = :always
|
10
|
-
AppOpticsAPM::Config[:verbose] = true
|
11
|
-
|
12
|
-
# The parent process/loop which collects data
|
13
|
-
Kernel.loop do
|
14
|
-
# For each loop, we instrument the work retrieval. These traces
|
15
|
-
# will show up as layer 'get_the_work'.
|
16
|
-
AppOpticsAPM::API.start_trace('get_the_work') do
|
17
|
-
work = get_the_work
|
18
|
-
|
19
|
-
# Loop through work and pass to `do_the_work` method
|
20
|
-
# that spawns a thread each time
|
21
|
-
work.each do |job|
|
22
|
-
fork do
|
23
|
-
# Since the context is copied from the parent process, we clear it
|
24
|
-
# and start a new trace via `AppOpticsAPM::API.start_trace`.
|
25
|
-
AppOpticsAPM::Context.clear
|
26
|
-
result = nil
|
27
|
-
|
28
|
-
AppOpticsAPM::API.start_trace('do_the_work', nil, :job_id => job.id) do
|
29
|
-
result = do_the_work(job)
|
30
|
-
end
|
31
|
-
|
32
|
-
result
|
33
|
-
end
|
34
|
-
end
|
35
|
-
end
|
36
|
-
end
|
37
|
-
|
38
|
-
##
|
39
|
-
# get_the_work
|
40
|
-
#
|
41
|
-
# Method to retrieve work to do
|
42
|
-
#
|
43
|
-
def get_the_work
|
44
|
-
# We'll just return random integers as a
|
45
|
-
# fake work load
|
46
|
-
w = []
|
47
|
-
w << rand(25)
|
48
|
-
w << rand(25)
|
49
|
-
w << rand(25)
|
50
|
-
end
|
51
|
-
|
52
|
-
##
|
53
|
-
# do_the_work
|
54
|
-
#
|
55
|
-
# The work-horse method
|
56
|
-
#
|
57
|
-
def do_the_work(job_to_do)
|
58
|
-
i = job_to_do
|
59
|
-
i * Math::PI
|
60
|
-
end
|
61
|
-
|
62
|
-
#########################################################################
|
63
|
-
# Notes
|
64
|
-
#########################################################################
|
65
|
-
|
66
|
-
# If your parent process only forks a small number of processes per loop (< 5..10),
|
67
|
-
# you may want to mark the child traces as asynchronous and have them directly
|
68
|
-
# linked to the parent tracing context.
|
69
|
-
#
|
70
|
-
# The benefit of this is that instead of having two independent traces (parent
|
71
|
-
# and child), you will have a single view of the parent trace showing the
|
72
|
-
# spawned child process and it's performance in the AppOptics dashboard.
|
73
|
-
#
|
74
|
-
# To do this:
|
75
|
-
# 1. Don't clear the context in the child process
|
76
|
-
# 2. Use `AppOpticsAPM::API.trace` instead
|
77
|
-
# 3. Pass the `Async` flag to mark this child as asynchronous
|
78
|
-
#
|
79
|
-
Kernel.loop do
|
80
|
-
AppOpticsAPM::API.start_trace('get_the_work') do
|
81
|
-
|
82
|
-
work = get_the_work
|
83
|
-
|
84
|
-
work.each do |job|
|
85
|
-
fork do
|
86
|
-
result = nil
|
87
|
-
# 1 Don't clear context
|
88
|
-
# 2 Use `AppOpticsAPM::API.trace` instead
|
89
|
-
# 3 Pass the Async flag
|
90
|
-
AppOpticsAPM::API.trace('do_the_work', {:job_id => job.id, :Async => 1 }) do
|
91
|
-
result = do_the_work(job)
|
92
|
-
end
|
93
|
-
|
94
|
-
result
|
95
|
-
end
|
96
|
-
end
|
97
|
-
end
|
98
|
-
sleep 5
|
99
|
-
end
|
@@ -1,28 +0,0 @@
|
|
1
|
-
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
|
2
|
-
timeout 15
|
3
|
-
preload_app true
|
4
|
-
|
5
|
-
before_fork do |server, worker|
|
6
|
-
Signal.trap 'TERM' do
|
7
|
-
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
|
8
|
-
Process.kill 'QUIT', Process.pid
|
9
|
-
end
|
10
|
-
|
11
|
-
defined?(ActiveRecord::Base) and
|
12
|
-
ActiveRecord::Base.connection.disconnect!
|
13
|
-
|
14
|
-
defined?(::AppOpticsAPM) and
|
15
|
-
::AppOpticsAPM.disconnect!
|
16
|
-
end
|
17
|
-
|
18
|
-
after_fork do |server, worker|
|
19
|
-
Signal.trap 'TERM' do
|
20
|
-
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
|
21
|
-
end
|
22
|
-
|
23
|
-
defined?(ActiveRecord::Base) and
|
24
|
-
ActiveRecord::Base.establish_connection
|
25
|
-
|
26
|
-
defined?(::AppOpticsAPM) and
|
27
|
-
::AppOpticsAPM.reconnect!
|
28
|
-
end
|