oneapm_rpm 1.1.2 → 1.1.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/lib/one_apm/agent.rb +185 -192
- data/lib/one_apm/agent/agent/connect.rb +17 -17
- data/lib/one_apm/agent/agent/container_data_manager.rb +14 -14
- data/lib/one_apm/agent/agent/forkable_dispatcher_functions.rb +6 -35
- data/lib/one_apm/agent/agent/helpers.rb +6 -17
- data/lib/one_apm/agent/agent/start.rb +27 -27
- data/lib/one_apm/agent/agent/start_worker_thread.rb +19 -51
- data/lib/one_apm/agent/busy_calculator.rb +8 -34
- data/lib/one_apm/agent/cross_app/cross_app_monitor.rb +10 -10
- data/lib/one_apm/agent/cross_app/cross_app_tracing.rb +14 -14
- data/lib/one_apm/agent/database.rb +8 -35
- data/lib/one_apm/agent/database/active_record_helper.rb +1 -1
- data/lib/one_apm/agent/datastores.rb +2 -109
- data/lib/one_apm/agent/datastores/metric_helper.rb +1 -1
- data/lib/one_apm/agent/datastores/mongo/metric_translator.rb +3 -3
- data/lib/one_apm/agent/datastores/mongo/statement_formatter.rb +2 -2
- data/lib/one_apm/agent/harvester.rb +3 -6
- data/lib/one_apm/agent/inbound_request_monitor.rb +2 -2
- data/lib/one_apm/agent/javascript_instrumentor.rb +28 -28
- data/lib/one_apm/agent/sampler.rb +1 -1
- data/lib/one_apm/agent/sampler_collection.rb +6 -9
- data/lib/one_apm/agent/samplers/cpu_sampler.rb +4 -4
- data/lib/one_apm/agent/samplers/delayed_job_sampler.rb +5 -5
- data/lib/one_apm/agent/samplers/memory_sampler.rb +5 -5
- data/lib/one_apm/agent/samplers/object_sampler.rb +1 -1
- data/lib/one_apm/agent/samplers/vm_sampler.rb +6 -6
- data/lib/one_apm/agent/synthetics_monitor.rb +2 -2
- data/lib/one_apm/agent/threading/agent_thread.rb +6 -6
- data/lib/one_apm/agent/threading/backtrace_service.rb +9 -9
- data/lib/one_apm/agent/threading/thread_profile.rb +3 -3
- data/lib/one_apm/collector/collector/helper.rb +10 -10
- data/lib/one_apm/collector/collector/http_connection.rb +14 -14
- data/lib/one_apm/collector/collector/server_methods.rb +12 -12
- data/lib/one_apm/collector/collector_service.rb +8 -8
- data/lib/one_apm/collector/commands/thread_profiler_session.rb +4 -4
- data/lib/one_apm/collector/commands/xray_session.rb +1 -1
- data/lib/one_apm/collector/commands/xray_session_collection.rb +10 -10
- data/lib/one_apm/collector/containers/agent_command_router.rb +7 -7
- data/lib/one_apm/collector/containers/custom_event_aggregator.rb +6 -6
- data/lib/one_apm/collector/containers/error_collector.rb +16 -16
- data/lib/one_apm/collector/containers/sql_sampler.rb +8 -11
- data/lib/one_apm/collector/containers/transaction_event_aggregator.rb +15 -15
- data/lib/one_apm/collector/containers/transaction_sampler.rb +14 -16
- data/lib/one_apm/{agent/pipe/pipe_service.rb → collector/forked_process_service.rb} +3 -3
- data/lib/one_apm/collector/stats_engine/gc_profiler.rb +3 -3
- data/lib/one_apm/collector/stats_engine/metric_stats.rb +4 -4
- data/lib/one_apm/collector/stats_engine/stats_hash.rb +2 -2
- data/lib/one_apm/configuration.rb +16 -16
- data/lib/one_apm/configuration/autostart.rb +4 -4
- data/lib/one_apm/configuration/default_source.rb +9 -9
- data/lib/one_apm/configuration/environment_source.rb +1 -1
- data/lib/one_apm/configuration/high_security_source.rb +1 -1
- data/lib/one_apm/configuration/yaml_source.rb +7 -7
- data/lib/one_apm/errors/noticed_error.rb +2 -2
- data/lib/one_apm/frameworks/external.rb +2 -0
- data/lib/one_apm/frameworks/rails.rb +8 -18
- data/lib/one_apm/frameworks/rails3.rb +1 -0
- data/lib/one_apm/frameworks/rails4.rb +2 -6
- data/lib/one_apm/frameworks/ruby.rb +7 -2
- data/lib/one_apm/frameworks/sinatra.rb +1 -2
- data/lib/one_apm/inst/3rd/active_merchant.rb +1 -1
- data/lib/one_apm/inst/3rd/acts_as_solr.rb +2 -2
- data/lib/one_apm/inst/3rd/authlogic.rb +1 -1
- data/lib/one_apm/inst/3rd/sunspot.rb +1 -1
- data/lib/one_apm/inst/background_job/active_job.rb +1 -1
- data/lib/one_apm/inst/background_job/delayed_job.rb +4 -4
- data/lib/one_apm/inst/background_job/event_machine_standalone.rb +2 -2
- data/lib/one_apm/inst/background_job/resque.rb +11 -11
- data/lib/one_apm/inst/background_job/sidekiq.rb +5 -5
- data/lib/one_apm/inst/dispatcher/passenger.rb +4 -4
- data/lib/one_apm/inst/dispatcher/puma.rb +23 -0
- data/lib/one_apm/inst/dispatcher/rainbows.rb +2 -2
- data/lib/one_apm/inst/framework/grape.rb +4 -4
- data/lib/one_apm/inst/framework/padrino.rb +2 -2
- data/lib/one_apm/inst/framework/sinatra.rb +9 -9
- data/lib/one_apm/inst/framework/sinatra/transaction_namer.rb +1 -1
- data/lib/one_apm/inst/http_clients/curb.rb +6 -6
- data/lib/one_apm/inst/http_clients/excon.rb +4 -4
- data/lib/one_apm/inst/http_clients/excon/middleware.rb +3 -3
- data/lib/one_apm/inst/http_clients/httpclient.rb +1 -1
- data/lib/one_apm/inst/http_clients/net.rb +2 -2
- data/lib/one_apm/inst/http_clients/typhoeus.rb +2 -2
- data/lib/one_apm/inst/nosql/memcache.rb +7 -7
- data/lib/one_apm/inst/nosql/mongo.rb +6 -6
- data/lib/one_apm/inst/nosql/mongo_moped.rb +2 -2
- data/lib/one_apm/inst/nosql/redis.rb +3 -3
- data/lib/one_apm/inst/orm/active_record.rb +4 -4
- data/lib/one_apm/inst/orm/active_record_4.rb +2 -2
- data/lib/one_apm/inst/orm/sequel.rb +4 -4
- data/lib/one_apm/inst/rack.rb +3 -3
- data/lib/one_apm/inst/rack/rack_builder.rb +4 -4
- data/lib/one_apm/inst/rails/action_controller.rb +7 -7
- data/lib/one_apm/inst/rails/action_web_service.rb +1 -1
- data/lib/one_apm/inst/rails/errors.rb +1 -1
- data/lib/one_apm/inst/rails3/action_controller.rb +6 -6
- data/lib/one_apm/inst/rails3/errors.rb +1 -1
- data/lib/one_apm/inst/rails4/action_controller.rb +1 -1
- data/lib/one_apm/inst/rails4/action_controller_subscriber.rb +4 -4
- data/lib/one_apm/inst/rails4/action_view.rb +2 -2
- data/lib/one_apm/inst/rails4/action_view_subscriber.rb +4 -4
- data/lib/one_apm/inst/rails4/active_record_subscriber.rb +7 -7
- data/lib/one_apm/inst/rails4/errors.rb +1 -1
- data/lib/one_apm/inst/rails_middleware.rb +2 -2
- data/lib/one_apm/inst/support/evented_subscriber.rb +2 -2
- data/lib/one_apm/inst/support/queue_time.rb +1 -1
- data/lib/one_apm/inst/transaction_base.rb +6 -6
- data/lib/one_apm/logger/agent_logger.rb +8 -8
- data/lib/one_apm/logger/audit_logger.rb +8 -8
- data/lib/one_apm/logger/memory_logger.rb +1 -1
- data/lib/one_apm/logger/null_logger.rb +1 -3
- data/lib/one_apm/manager.rb +249 -0
- data/lib/one_apm/metrics/metric_spec.rb +1 -1
- data/lib/one_apm/metrics/stats.rb +1 -1
- data/lib/one_apm/probe.rb +1 -1
- data/lib/one_apm/probe/framework_loader.rb +2 -2
- data/lib/one_apm/probe/instance_methods.rb +19 -19
- data/lib/one_apm/probe/instrumentation.rb +5 -5
- data/lib/one_apm/rack/browser_monitoring.rb +6 -6
- data/lib/one_apm/rack/middleware_hooks.rb +1 -1
- data/lib/one_apm/rack/middleware_tracing.rb +2 -2
- data/lib/one_apm/support/chained_call.rb +1 -1
- data/lib/one_apm/support/coerce.rb +1 -1
- data/lib/one_apm/support/collection_helper.rb +1 -1
- data/lib/one_apm/support/encoders.rb +1 -1
- data/lib/one_apm/support/environment_report.rb +10 -10
- data/lib/one_apm/{agent → support}/event/event_listener.rb +3 -3
- data/lib/one_apm/{agent → support}/event/event_loop.rb +8 -8
- data/lib/one_apm/{agent → support}/event/timer.rb +1 -1
- data/lib/one_apm/{agent → support}/event/worker_loop.rb +5 -19
- data/lib/one_apm/{agent/pipe/pipe_channel_manager.rb → support/forked_process_channel.rb} +13 -51
- data/lib/one_apm/support/json_marshaller.rb +6 -6
- data/lib/one_apm/support/json_wrapper.rb +2 -2
- data/lib/one_apm/support/language_support.rb +1 -1
- data/lib/one_apm/support/library_detection.rb +5 -5
- data/lib/one_apm/support/marshaller.rb +1 -1
- data/lib/one_apm/support/method_tracer.rb +12 -12
- data/lib/one_apm/support/method_tracer/helpers.rb +6 -6
- data/lib/one_apm/support/system_info.rb +2 -2
- data/lib/one_apm/support/traced_method_stack.rb +4 -4
- data/lib/one_apm/support/vm/monotonic_gc_profiler.rb +1 -1
- data/lib/one_apm/support/vm/mri_vm.rb +1 -1
- data/lib/one_apm/transaction.rb +3 -3
- data/lib/one_apm/transaction/class_methods.rb +3 -3
- data/lib/one_apm/transaction/instance_helpers.rb +3 -3
- data/lib/one_apm/transaction/sample_buffer/synthetics_sample_buffer.rb +1 -1
- data/lib/one_apm/transaction/sample_buffer/xray_sample_buffer.rb +5 -5
- data/lib/one_apm/transaction/thread_local_access.rb +2 -2
- data/lib/one_apm/transaction/transaction_apdex.rb +2 -2
- data/lib/one_apm/transaction/transaction_finish_append.rb +1 -1
- data/lib/one_apm/transaction/transaction_jruby_functions.rb +2 -2
- data/lib/one_apm/transaction/transaction_name.rb +2 -2
- data/lib/one_apm/transaction/transaction_sample.rb +1 -1
- data/lib/one_apm/transaction/transaction_sample_builder.rb +7 -7
- data/lib/one_apm/transaction/transaction_state.rb +1 -1
- data/lib/one_apm/version.rb +1 -1
- data/lib/sequel/extensions/oneapm_instrumentation.rb +7 -7
- data/oneapm.yml +6 -7
- metadata +10 -9
- data/lib/one_apm/agent/agent.rb +0 -283
@@ -67,7 +67,7 @@ module OneApm::Rack
|
|
67
67
|
|
68
68
|
result
|
69
69
|
rescue Exception => e
|
70
|
-
OneApm::
|
70
|
+
OneApm::Manager.notice_error(e)
|
71
71
|
raise e
|
72
72
|
ensure
|
73
73
|
OneApm::Transaction.stop(state)
|
@@ -75,7 +75,7 @@ module OneApm::Rack
|
|
75
75
|
end
|
76
76
|
|
77
77
|
def events
|
78
|
-
OneApm::
|
78
|
+
OneApm::Manager.agent.events
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# This class is used by OneApm::
|
3
|
+
# This class is used by OneApm::Manager.set_sql_obfuscator to chain multiple
|
4
4
|
# obfuscation blocks when not using the default :replace action
|
5
5
|
class OneApm::ChainedCall
|
6
6
|
def initialize(block1, block2)
|
@@ -75,7 +75,7 @@ module OneApm
|
|
75
75
|
def log_failure(value, type, context, error)
|
76
76
|
msg = "Unable to convert '#{value}' to #{type}"
|
77
77
|
msg += " in context '#{context}'" if context
|
78
|
-
OneApm::
|
78
|
+
OneApm::Manager.logger.warn(msg, error)
|
79
79
|
end
|
80
80
|
end
|
81
81
|
end
|
@@ -35,7 +35,7 @@ module OneApm
|
|
35
35
|
# Return nil if there is no backtrace
|
36
36
|
|
37
37
|
def strip_oa_from_backtrace(backtrace)
|
38
|
-
if backtrace && !
|
38
|
+
if backtrace && !Manager.config[:disable_backtrace_cleanup]
|
39
39
|
# this is for 1.9.1, where strings no longer have Enumerable
|
40
40
|
backtrace = backtrace.split("\n") if String === backtrace
|
41
41
|
backtrace = backtrace.map(&:to_s)
|
@@ -23,7 +23,7 @@ module OneApm
|
|
23
23
|
normalize_encodings = if opts[:skip_normalization]
|
24
24
|
false
|
25
25
|
else
|
26
|
-
|
26
|
+
OneApm::Manager.config[:normalize_json_string_encodings]
|
27
27
|
end
|
28
28
|
json = ::OneApm::JSONWrapper.dump(data, :normalize => normalize_encodings)
|
29
29
|
Base64.encode64(Compressed.encode(json))
|
@@ -69,8 +69,8 @@ module OneApm
|
|
69
69
|
report_on('Database adapter' ) do
|
70
70
|
ActiveRecord::Base.configurations[OneApm::Probe.instance.env]['adapter']
|
71
71
|
end
|
72
|
-
report_on('Framework' ) {
|
73
|
-
report_on('Dispatcher' ) {
|
72
|
+
report_on('Framework' ) { OneApm::Manager.config[:framework].to_s }
|
73
|
+
report_on('Dispatcher' ) { OneApm::Manager.config[:dispatcher].to_s }
|
74
74
|
report_on('Environment' ) { OneApm::Probe.instance.env }
|
75
75
|
report_on('Rails version' ) { ::Rails::VERSION::STRING }
|
76
76
|
report_on('Rails threadsafe') do
|
@@ -96,17 +96,17 @@ module OneApm
|
|
96
96
|
if value
|
97
97
|
data[key] = value
|
98
98
|
|
99
|
-
|
100
|
-
|
99
|
+
OneApm::Manager.record_metric("Supportability/EnvironmentReport/success", 0.0)
|
100
|
+
OneApm::Manager.record_metric("Supportability/EnvironmentReport/success/#{key}", 0.0)
|
101
101
|
else
|
102
|
-
|
103
|
-
|
104
|
-
|
102
|
+
OneApm::Manager.logger.debug("EnvironmentReport ignoring value for #{key.inspect} which came back falsey: #{value.inspect}")
|
103
|
+
OneApm::Manager.record_metric("Supportability/EnvironmentReport/empty", 0.0)
|
104
|
+
OneApm::Manager.record_metric("Supportability/EnvironmentReport/empty/#{key}", 0.0)
|
105
105
|
end
|
106
106
|
rescue => e
|
107
|
-
|
108
|
-
|
109
|
-
|
107
|
+
OneApm::Manager.logger.debug("EnvironmentReport failed to retrieve value for #{key.inspect}: #{e}")
|
108
|
+
OneApm::Manager.record_metric("Supportability/EnvironmentReport/error", 0.0)
|
109
|
+
OneApm::Manager.record_metric("Supportability/EnvironmentReport/error/#{key}", 0.0)
|
110
110
|
end
|
111
111
|
data
|
112
112
|
end
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
module OneApm::
|
3
|
+
module OneApm::Support
|
4
4
|
class EventListener
|
5
5
|
|
6
6
|
attr_accessor :runaway_threshold
|
@@ -18,7 +18,7 @@ module OneApm::Agent
|
|
18
18
|
|
19
19
|
def check_for_runaway_subscriptions(event)
|
20
20
|
count = @events[event].size
|
21
|
-
OneApm::
|
21
|
+
OneApm::Manager.logger.debug("Run-away event subscription on #{event}? Subscribed #{count}") if count > @runaway_threshold
|
22
22
|
end
|
23
23
|
|
24
24
|
def clear
|
@@ -32,7 +32,7 @@ module OneApm::Agent
|
|
32
32
|
begin
|
33
33
|
handler.call(*args)
|
34
34
|
rescue => err
|
35
|
-
OneApm::
|
35
|
+
OneApm::Manager.logger.debug("Failure during notify for #{event}", err)
|
36
36
|
end
|
37
37
|
end
|
38
38
|
end
|
@@ -1,10 +1,10 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'thread'
|
4
|
-
require 'one_apm/
|
4
|
+
require 'one_apm/support/event/timer'
|
5
5
|
|
6
6
|
module OneApm
|
7
|
-
module
|
7
|
+
module Support
|
8
8
|
class EventLoop
|
9
9
|
|
10
10
|
def initialize
|
@@ -47,7 +47,7 @@ module OneApm
|
|
47
47
|
end
|
48
48
|
|
49
49
|
def run
|
50
|
-
OneApm::
|
50
|
+
OneApm::Manager.logger.debug "Running event loop"
|
51
51
|
while !stopped?
|
52
52
|
run_once
|
53
53
|
end
|
@@ -93,7 +93,7 @@ module OneApm
|
|
93
93
|
end
|
94
94
|
|
95
95
|
def dispatch_event(event, args)
|
96
|
-
OneApm::
|
96
|
+
OneApm::Manager.logger.debug("EventLoop: Dispatching event '#{event}' with #{@subscriptions[event].size} callback(s).")
|
97
97
|
|
98
98
|
errors = []
|
99
99
|
@subscriptions[event].each do |s|
|
@@ -107,7 +107,7 @@ module OneApm
|
|
107
107
|
end
|
108
108
|
|
109
109
|
if !errors.empty?
|
110
|
-
OneApm::
|
110
|
+
OneApm::Manager.logger.error "#{errors.size} error(s) running task for event '#{event}' in Agent Event Loop:", *errors
|
111
111
|
end
|
112
112
|
end
|
113
113
|
|
@@ -125,19 +125,19 @@ module OneApm
|
|
125
125
|
end
|
126
126
|
|
127
127
|
def fire_every(interval, event)
|
128
|
-
OneApm::
|
128
|
+
OneApm::Manager.logger.debug "Firing event #{event} every #{interval} seconds."
|
129
129
|
fire(:__add_timer, Timer.new(interval, event, true))
|
130
130
|
end
|
131
131
|
|
132
132
|
def fire_after(interval, event)
|
133
|
-
OneApm::
|
133
|
+
OneApm::Manager.logger.debug "Firing event #{event} after #{interval} seconds."
|
134
134
|
fire(:__add_timer, Timer.new(interval, event, false))
|
135
135
|
end
|
136
136
|
|
137
137
|
def wakeup
|
138
138
|
@self_pipe_wr.write_nonblock '.'
|
139
139
|
rescue Errno::EAGAIN
|
140
|
-
OneApm::
|
140
|
+
OneApm::Manager.logger.debug "Failed to wakeup event loop"
|
141
141
|
end
|
142
142
|
end
|
143
143
|
end
|
@@ -1,19 +1,16 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
3
|
require 'thread'
|
4
|
+
|
4
5
|
module OneApm
|
5
|
-
module
|
6
|
+
module Support
|
6
7
|
|
7
|
-
# A worker loop executes a set of registered tasks on a single thread.
|
8
|
-
# A task is a proc or block with a specified call period in seconds.
|
9
8
|
class WorkerLoop
|
10
9
|
|
11
10
|
attr_accessor :period, :propagate_errors
|
12
11
|
attr_reader :iterations
|
13
12
|
|
14
|
-
|
15
|
-
# or :limit (integer) for max number of iterations
|
16
|
-
def initialize(opts={})
|
13
|
+
def initialize(opts = {})
|
17
14
|
@should_run = true
|
18
15
|
@next_invocation_time = Time.now
|
19
16
|
@period = 60.0
|
@@ -23,7 +20,6 @@ module OneApm
|
|
23
20
|
@propagate_errors = opts.fetch(:propagate_errors, false)
|
24
21
|
end
|
25
22
|
|
26
|
-
# Reset state that is changed by running the worker loop
|
27
23
|
def setup(period, task)
|
28
24
|
@task = task
|
29
25
|
@period = period if period
|
@@ -35,10 +31,7 @@ module OneApm
|
|
35
31
|
@next_invocation_time = (now + @period)
|
36
32
|
end
|
37
33
|
|
38
|
-
|
39
|
-
# call periods. The caller is responsible for creating the thread
|
40
|
-
# that runs this worker loop. This will run the task immediately.
|
41
|
-
def run(period=nil, &block)
|
34
|
+
def run(period = nil, &block)
|
42
35
|
setup(period, block)
|
43
36
|
while keep_running? do
|
44
37
|
sleep_time = schedule_next_invocation
|
@@ -56,7 +49,6 @@ module OneApm
|
|
56
49
|
@next_invocation_time - Time.now
|
57
50
|
end
|
58
51
|
|
59
|
-
# a simple accessor for @should_run
|
60
52
|
def keep_running?
|
61
53
|
@should_run && under_duration? && under_limit?
|
62
54
|
end
|
@@ -69,14 +61,10 @@ module OneApm
|
|
69
61
|
@limit.nil? || @iterations < @limit
|
70
62
|
end
|
71
63
|
|
72
|
-
# Sets @should_run to false. Returns false
|
73
64
|
def stop
|
74
65
|
@should_run = false
|
75
66
|
end
|
76
67
|
|
77
|
-
# Executes the block given to the worker loop, and handles many
|
78
|
-
# possible errors. Also updates the execution time so that the
|
79
|
-
# next run occurs on schedule, even if we execute at some odd time
|
80
68
|
def run_task
|
81
69
|
if @propagate_errors
|
82
70
|
@task.call
|
@@ -84,11 +72,9 @@ module OneApm
|
|
84
72
|
begin
|
85
73
|
@task.call
|
86
74
|
rescue OneApm::ForceRestartException, OneApm::ForceDisconnectException
|
87
|
-
# blow out the loop
|
88
75
|
raise
|
89
76
|
rescue => e
|
90
|
-
|
91
|
-
::OneApm::Agent.logger.error "Error running task in Agent Worker Loop:", e
|
77
|
+
OneApm::Manager.logger.error "Error running task in Agent Worker Loop:", e
|
92
78
|
end
|
93
79
|
end
|
94
80
|
end
|
@@ -3,13 +3,8 @@
|
|
3
3
|
require 'base64'
|
4
4
|
|
5
5
|
module OneApm
|
6
|
-
module
|
7
|
-
|
8
|
-
#--
|
9
|
-
# Manages the registering and servicing of pipes used by child
|
10
|
-
# processes to report data to their parent, rather than directly
|
11
|
-
# to the collector.
|
12
|
-
module PipeChannelManager
|
6
|
+
module Support
|
7
|
+
module ForkedProcessChannel
|
13
8
|
extend self
|
14
9
|
|
15
10
|
def register_report_channel(id)
|
@@ -24,36 +19,8 @@ module OneApm
|
|
24
19
|
@listener ||= Listener.new
|
25
20
|
end
|
26
21
|
|
27
|
-
# Expected initial sequence of events for Pipe usage:
|
28
|
-
#
|
29
|
-
# 1. Pipe is created in parent process (read and write ends open)
|
30
|
-
# 2. Parent process forks
|
31
|
-
# 3. An after_fork hook is invoked in the child
|
32
|
-
# 4. From after_fork hook, child closes read end of pipe, and
|
33
|
-
# writes a ready marker on the pipe (after_fork_in_child).
|
34
|
-
# 5. The parent receives the ready marker, and closes the write end of the
|
35
|
-
# pipe in response (after_fork_in_parent).
|
36
|
-
#
|
37
|
-
# After this sequence of steps, an exit (whether clean or not) of the
|
38
|
-
# child will result in the pipe being marked readable again, and giving an
|
39
|
-
# EOF marker (nil) when read. Note that closing of the unused ends of the
|
40
|
-
# pipe in the parent and child processes is essential in order for the EOF
|
41
|
-
# to be correctly triggered. The ready marker mechanism is used because
|
42
|
-
# there's no easy hook for after_fork in the parent process.
|
43
|
-
#
|
44
|
-
# This class provides message framing (separation of individual messages),
|
45
|
-
# but not serialization. Serialization / deserialization is the
|
46
|
-
# responsibility of clients.
|
47
|
-
#
|
48
|
-
# Message framing works like this:
|
49
|
-
#
|
50
|
-
# Each message sent across the pipe is preceded by a length tag that
|
51
|
-
# specifies the length of the message that immediately follows, in bytes.
|
52
|
-
# The length tags are serialized as unsigned big-endian long values, (4
|
53
|
-
# bytes each). This means that the maximum theoretical message size is
|
54
|
-
# 4 GB - much larger than we'd ever need or want for this application.
|
55
|
-
#
|
56
22
|
class Pipe
|
23
|
+
|
57
24
|
READY_MARKER = "READY"
|
58
25
|
NUM_LENGTH_BYTES = 4
|
59
26
|
|
@@ -98,11 +65,11 @@ module OneApm
|
|
98
65
|
@out.read(message_length)
|
99
66
|
else
|
100
67
|
length_hex = length_bytes.bytes.map { |b| b.to_s(16) }.join(' ')
|
101
|
-
OneApm::
|
68
|
+
OneApm::Manager.logger.error("Failed to deserialize message length from pipe. Bytes: [#{length_hex}]")
|
102
69
|
nil
|
103
70
|
end
|
104
71
|
else
|
105
|
-
OneApm::
|
72
|
+
OneApm::Manager.logger.error("Failed to read bytes for length from pipe.")
|
106
73
|
nil
|
107
74
|
end
|
108
75
|
end
|
@@ -123,17 +90,12 @@ module OneApm
|
|
123
90
|
def closed?
|
124
91
|
@out.closed? && @in.closed?
|
125
92
|
end
|
93
|
+
|
126
94
|
end
|
127
95
|
|
128
96
|
class Listener
|
129
|
-
attr_reader :thread
|
130
97
|
|
131
|
-
|
132
|
-
# @pipes hash. It is used to look up the write end of the pipe from
|
133
|
-
# within the Resque child process, and must be unsynchronized in order
|
134
|
-
# to avoid a potential deadlock in which the PipeChannelManager::Listener
|
135
|
-
# thread in the parent process is holding the @pipes_lock at the time of
|
136
|
-
# the fork.
|
98
|
+
attr_reader :thread
|
137
99
|
attr_accessor :pipes, :timeout, :select_timeout
|
138
100
|
|
139
101
|
def initialize
|
@@ -168,8 +130,7 @@ module OneApm
|
|
168
130
|
@pipes.values.map{|pipe| pipe.out} + [wake.out]
|
169
131
|
end
|
170
132
|
|
171
|
-
OneApm::
|
172
|
-
(Time.now - now).to_f) if now
|
133
|
+
OneApm::Manager.record_metric('Supportability/Listeners', (Time.now - now).to_f) if now
|
173
134
|
|
174
135
|
if ready = IO.select(pipes_to_listen_to, [], [], @select_timeout)
|
175
136
|
now = Time.now
|
@@ -185,7 +146,7 @@ module OneApm
|
|
185
146
|
break unless should_keep_listening?
|
186
147
|
end
|
187
148
|
end
|
188
|
-
sleep 0.001
|
149
|
+
sleep 0.001
|
189
150
|
end
|
190
151
|
|
191
152
|
def stop_listener_thread
|
@@ -231,7 +192,7 @@ module OneApm
|
|
231
192
|
payload = unmarshal(raw_payload)
|
232
193
|
if payload
|
233
194
|
endpoint, items = payload
|
234
|
-
OneApm::
|
195
|
+
OneApm::Manager.agent.merge_data_for_endpoint(endpoint, items)
|
235
196
|
end
|
236
197
|
end
|
237
198
|
end
|
@@ -244,8 +205,8 @@ module OneApm
|
|
244
205
|
Marshal.load(data)
|
245
206
|
end
|
246
207
|
rescue StandardError => e
|
247
|
-
|
248
|
-
|
208
|
+
OneApm::Manager.logger.error "Failure unmarshalling message from Resque child process", e
|
209
|
+
OneApm::Manager.logger.debug Base64.encode64(data)
|
249
210
|
nil
|
250
211
|
end
|
251
212
|
|
@@ -269,6 +230,7 @@ module OneApm
|
|
269
230
|
@pipes.values.find{|pipe| pipe.out == out_handle }
|
270
231
|
end
|
271
232
|
end
|
233
|
+
|
272
234
|
end
|
273
235
|
end
|
274
236
|
end
|
@@ -9,7 +9,7 @@ module OneApm
|
|
9
9
|
OK_YAJL_VERSION = OneApm::VersionNumber.new("1.2.1")
|
10
10
|
|
11
11
|
def initialize
|
12
|
-
|
12
|
+
OneApm::Manager.logger.info "Using JSON marshaller (#{OneApm::JSONWrapper.backend_name})"
|
13
13
|
warn_for_yajl
|
14
14
|
end
|
15
15
|
|
@@ -17,11 +17,11 @@ module OneApm
|
|
17
17
|
if defined?(::Yajl)
|
18
18
|
require 'yajl/version'
|
19
19
|
if OneApm::VersionNumber.new(::Yajl::VERSION) < OK_YAJL_VERSION
|
20
|
-
|
20
|
+
OneApm::Manager.logger.warn "Detected yajl-ruby version #{::Yajl::VERSION} which can cause segfaults with oneapm_rpm's thread profiling features. We strongly recommend you upgrade to the latest yajl-ruby version available."
|
21
21
|
end
|
22
22
|
end
|
23
23
|
rescue => err
|
24
|
-
|
24
|
+
OneApm::Manager.logger.warn "Failed trying to watch for problematic yajl-ruby version.", err
|
25
25
|
end
|
26
26
|
|
27
27
|
def dump(ruby, opts={})
|
@@ -30,7 +30,7 @@ module OneApm
|
|
30
30
|
if opts[:skip_normalization]
|
31
31
|
normalize_encodings = false
|
32
32
|
else
|
33
|
-
normalize_encodings =
|
33
|
+
normalize_encodings = OneApm::Manager.config[:normalize_json_string_encodings]
|
34
34
|
end
|
35
35
|
|
36
36
|
OneApm::JSONWrapper.dump prepared, :normalize => normalize_encodings
|
@@ -38,13 +38,13 @@ module OneApm
|
|
38
38
|
|
39
39
|
def load(data)
|
40
40
|
if data.nil? || data.empty?
|
41
|
-
|
41
|
+
OneApm::Manager.logger.error "Empty JSON response from collector: '#{data.inspect}'"
|
42
42
|
return nil
|
43
43
|
end
|
44
44
|
|
45
45
|
return_value OneApm::JSONWrapper.load(data)
|
46
46
|
rescue => e
|
47
|
-
|
47
|
+
OneApm::Manager.logger.debug "#{e.class.name} : #{e.message} encountered loading collector response: #{data}"
|
48
48
|
raise
|
49
49
|
end
|
50
50
|
|