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
@@ -179,7 +179,7 @@ module OneApm
|
|
179
179
|
|
180
180
|
def collect_explain_plans!
|
181
181
|
return unless Agent::Database.should_collect_explain_plans?
|
182
|
-
threshold =
|
182
|
+
threshold = OneApm::Manager.config[:'transaction_tracer.explain_threshold']
|
183
183
|
each_segment do |segment|
|
184
184
|
if segment[:sql] && segment.duration > threshold
|
185
185
|
segment[:explain_plan] = segment.explain_sql
|
@@ -62,7 +62,7 @@ module OneApm
|
|
62
62
|
end
|
63
63
|
|
64
64
|
def segment_limit
|
65
|
-
|
65
|
+
OneApm::Manager.config[:'transaction_tracer.limit_segments']
|
66
66
|
end
|
67
67
|
|
68
68
|
def trace_entry(time)
|
@@ -71,7 +71,7 @@ module OneApm
|
|
71
71
|
@current_segment.add_called_segment(segment)
|
72
72
|
@current_segment = segment
|
73
73
|
if @sample.count_segments == segment_limit()
|
74
|
-
|
74
|
+
OneApm::Manager.logger.debug("Segment limit of #{segment_limit} reached, ceasing collection.")
|
75
75
|
end
|
76
76
|
else
|
77
77
|
if @current_segment.is_a?(PlaceholderSegment)
|
@@ -100,7 +100,7 @@ module OneApm
|
|
100
100
|
# Should never get called twice, but in a rare case that we can't
|
101
101
|
# reproduce in house it does. log forensics and return gracefully
|
102
102
|
if @sample.finished
|
103
|
-
|
103
|
+
OneApm::Manager.logger.error "Unexpected double-finish_trace of Transaction Trace Object: \n#{@sample.to_s}"
|
104
104
|
return
|
105
105
|
end
|
106
106
|
@sample.root_segment.end_trace(time.to_f - @sample_start)
|
@@ -117,13 +117,13 @@ module OneApm
|
|
117
117
|
|
118
118
|
TT_THRESHOLD_KEY = :'transaction_tracer.transaction_threshold'
|
119
119
|
|
120
|
-
def transaction_trace_threshold
|
120
|
+
def transaction_trace_threshold
|
121
121
|
state = TransactionState.tl_get
|
122
|
-
source_class =
|
122
|
+
source_class = OneApm::Manager.config.source(TT_THRESHOLD_KEY).class
|
123
123
|
if source_class == Configuration::DefaultSource && state.current_transaction
|
124
124
|
state.current_transaction.apdex_t * 4
|
125
125
|
else
|
126
|
-
|
126
|
+
OneApm::Manager.config[TT_THRESHOLD_KEY]
|
127
127
|
end
|
128
128
|
end
|
129
129
|
|
@@ -144,7 +144,7 @@ module OneApm
|
|
144
144
|
end
|
145
145
|
|
146
146
|
def set_request_params(params)
|
147
|
-
if
|
147
|
+
if OneApm::Manager.config[:capture_params]
|
148
148
|
params = normalize_params(params)
|
149
149
|
@sample.params[:request_params].merge!(params)
|
150
150
|
@sample.params[:request_params].delete :controller
|
@@ -39,7 +39,7 @@ module OneApm
|
|
39
39
|
# This starts the timer for the transaction.
|
40
40
|
def reset(transaction=nil)
|
41
41
|
# We purposefully don't reset @untraced, @record_tt and @record_sql
|
42
|
-
# since those are managed by OneApm::
|
42
|
+
# since those are managed by OneApm::Manager.disable_* calls explicitly
|
43
43
|
# and (more importantly) outside the scope of a transaction
|
44
44
|
|
45
45
|
@timings = nil
|
data/lib/one_apm/version.rb
CHANGED
@@ -10,7 +10,7 @@ module Sequel
|
|
10
10
|
OneApm::Agent::Instrumentation::ActiveRecordHelper
|
11
11
|
|
12
12
|
# Instrument all queries that go through #execute_query.
|
13
|
-
def log_yield(sql, args=nil)
|
13
|
+
def log_yield(sql, args=nil)
|
14
14
|
state = OneApm::TransactionState.tl_get
|
15
15
|
return super unless state.is_execution_traced?
|
16
16
|
|
@@ -23,7 +23,7 @@ module Sequel
|
|
23
23
|
record_metrics(sql, args, duration)
|
24
24
|
notice_sql(state, sql, args, t0, t1)
|
25
25
|
rescue => err
|
26
|
-
OneApm::
|
26
|
+
OneApm::Manager.logger.debug "while recording metrics for Sequel", err
|
27
27
|
end
|
28
28
|
|
29
29
|
return rval
|
@@ -31,9 +31,9 @@ module Sequel
|
|
31
31
|
|
32
32
|
# Record metrics for the specified +sql+ and +args+ using the specified
|
33
33
|
# +duration+.
|
34
|
-
def record_metrics(sql, args, duration)
|
34
|
+
def record_metrics(sql, args, duration)
|
35
35
|
primary_metric = primary_metric_for(sql, args)
|
36
|
-
engine = OneApm::
|
36
|
+
engine = OneApm::Manager.agent.stats_engine
|
37
37
|
|
38
38
|
metrics = rollup_metrics_for(primary_metric)
|
39
39
|
metrics << remote_service_metric(*self.opts.values_at(:adapter, :host)) if self.opts.key?(:adapter)
|
@@ -49,7 +49,7 @@ module Sequel
|
|
49
49
|
# +finish+ times.
|
50
50
|
def notice_sql(state, sql, args, start, finish)
|
51
51
|
metric = primary_metric_for(sql, args)
|
52
|
-
agent = OneApm::
|
52
|
+
agent = OneApm::Manager.agent
|
53
53
|
duration = finish - start
|
54
54
|
stack = state.traced_method_stack
|
55
55
|
|
@@ -59,7 +59,7 @@ module Sequel
|
|
59
59
|
if THREAD_SAFE_CONNECTION_POOL_CLASSES.include?(self.pool.class)
|
60
60
|
self[ sql ].explain
|
61
61
|
else
|
62
|
-
OneApm::
|
62
|
+
OneApm::Manager.logger.log_once(:info, :sequel_explain_skipped, "Not running SQL explains because Sequel is not in recognized multi-threaded mode")
|
63
63
|
nil
|
64
64
|
end
|
65
65
|
end
|
@@ -78,7 +78,7 @@ module Sequel
|
|
78
78
|
|
79
79
|
end # module OneApmInstrumentation
|
80
80
|
|
81
|
-
OneApm::
|
81
|
+
OneApm::Manager.logger.debug "Registering the :oneapm_instrumentation extension."
|
82
82
|
Database.register_extension(:oneapm_instrumentation, OneApmInstrumentation)
|
83
83
|
|
84
84
|
end # module Sequel
|
data/oneapm.yml
CHANGED
@@ -1,20 +1,20 @@
|
|
1
1
|
#
|
2
|
-
# OneApm
|
2
|
+
# OneApm Ruby探针配置
|
3
3
|
#
|
4
4
|
|
5
5
|
common: &default_settings
|
6
6
|
|
7
7
|
license_key: 'please-paste-your-license-key-here'
|
8
8
|
|
9
|
-
#
|
9
|
+
# 您在这里填写的app_name会显示在OneAPM的管理后台界面中。
|
10
10
|
#
|
11
|
-
#
|
12
|
-
#
|
11
|
+
# 如果您修改了此处的app_name,一个新的应用会出现在后台,
|
12
|
+
# 数据会上传到这个新应用,并停止向旧的应用上传数据。
|
13
13
|
#
|
14
14
|
app_name: My Application
|
15
15
|
|
16
16
|
#
|
17
|
-
#
|
17
|
+
# 环境相关配置
|
18
18
|
#
|
19
19
|
|
20
20
|
production:
|
@@ -23,7 +23,7 @@ production:
|
|
23
23
|
|
24
24
|
development:
|
25
25
|
<<: *default_settings
|
26
|
-
#
|
26
|
+
# development模式下,探针开启并上传性能数据
|
27
27
|
monitor_mode: true
|
28
28
|
app_name: My Application (Development)
|
29
29
|
|
@@ -31,7 +31,6 @@ test:
|
|
31
31
|
<<: *default_settings
|
32
32
|
monitor_mode: false
|
33
33
|
|
34
|
-
# Staging environment which behaves identically to production.
|
35
34
|
staging:
|
36
35
|
<<: *default_settings
|
37
36
|
monitor_mode: true
|
metadata
CHANGED
@@ -1,14 +1,14 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: oneapm_rpm
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.1.
|
4
|
+
version: 1.1.3
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- oneapm
|
8
8
|
autorequire:
|
9
9
|
bindir: bin
|
10
10
|
cert_chain: []
|
11
|
-
date: 2015-06-
|
11
|
+
date: 2015-06-18 00:00:00.000000000 Z
|
12
12
|
dependencies:
|
13
13
|
- !ruby/object:Gem::Dependency
|
14
14
|
name: rake
|
@@ -224,7 +224,6 @@ files:
|
|
224
224
|
- lib/initializers/other.rb
|
225
225
|
- lib/initializers/rails.rb
|
226
226
|
- lib/one_apm/agent.rb
|
227
|
-
- lib/one_apm/agent/agent.rb
|
228
227
|
- lib/one_apm/agent/agent/connect.rb
|
229
228
|
- lib/one_apm/agent/agent/container_data_manager.rb
|
230
229
|
- lib/one_apm/agent/agent/forkable_dispatcher_functions.rb
|
@@ -245,15 +244,9 @@ files:
|
|
245
244
|
- lib/one_apm/agent/datastores/mongo/metric_translator.rb
|
246
245
|
- lib/one_apm/agent/datastores/mongo/obfuscator.rb
|
247
246
|
- lib/one_apm/agent/datastores/mongo/statement_formatter.rb
|
248
|
-
- lib/one_apm/agent/event/event_listener.rb
|
249
|
-
- lib/one_apm/agent/event/event_loop.rb
|
250
|
-
- lib/one_apm/agent/event/timer.rb
|
251
|
-
- lib/one_apm/agent/event/worker_loop.rb
|
252
247
|
- lib/one_apm/agent/harvester.rb
|
253
248
|
- lib/one_apm/agent/inbound_request_monitor.rb
|
254
249
|
- lib/one_apm/agent/javascript_instrumentor.rb
|
255
|
-
- lib/one_apm/agent/pipe/pipe_channel_manager.rb
|
256
|
-
- lib/one_apm/agent/pipe/pipe_service.rb
|
257
250
|
- lib/one_apm/agent/sampler.rb
|
258
251
|
- lib/one_apm/agent/sampler_collection.rb
|
259
252
|
- lib/one_apm/agent/samplers/cpu_sampler.rb
|
@@ -282,6 +275,7 @@ files:
|
|
282
275
|
- lib/one_apm/collector/containers/transaction_event_aggregator.rb
|
283
276
|
- lib/one_apm/collector/containers/transaction_sampler.rb
|
284
277
|
- lib/one_apm/collector/containers/utilization_data.rb
|
278
|
+
- lib/one_apm/collector/forked_process_service.rb
|
285
279
|
- lib/one_apm/collector/stats_engine/gc_profiler.rb
|
286
280
|
- lib/one_apm/collector/stats_engine/metric_stats.rb
|
287
281
|
- lib/one_apm/collector/stats_engine/stats_hash.rb
|
@@ -313,6 +307,7 @@ files:
|
|
313
307
|
- lib/one_apm/inst/background_job/resque.rb
|
314
308
|
- lib/one_apm/inst/background_job/sidekiq.rb
|
315
309
|
- lib/one_apm/inst/dispatcher/passenger.rb
|
310
|
+
- lib/one_apm/inst/dispatcher/puma.rb
|
316
311
|
- lib/one_apm/inst/dispatcher/rainbows.rb
|
317
312
|
- lib/one_apm/inst/framework/grape.rb
|
318
313
|
- lib/one_apm/inst/framework/padrino.rb
|
@@ -356,6 +351,7 @@ files:
|
|
356
351
|
- lib/one_apm/logger/audit_logger.rb
|
357
352
|
- lib/one_apm/logger/memory_logger.rb
|
358
353
|
- lib/one_apm/logger/null_logger.rb
|
354
|
+
- lib/one_apm/manager.rb
|
359
355
|
- lib/one_apm/metrics/metric_data.rb
|
360
356
|
- lib/one_apm/metrics/metric_spec.rb
|
361
357
|
- lib/one_apm/metrics/stats.rb
|
@@ -374,10 +370,15 @@ files:
|
|
374
370
|
- lib/one_apm/support/dotted_hash.rb
|
375
371
|
- lib/one_apm/support/encoders.rb
|
376
372
|
- lib/one_apm/support/environment_report.rb
|
373
|
+
- lib/one_apm/support/event/event_listener.rb
|
374
|
+
- lib/one_apm/support/event/event_loop.rb
|
375
|
+
- lib/one_apm/support/event/timer.rb
|
376
|
+
- lib/one_apm/support/event/worker_loop.rb
|
377
377
|
- lib/one_apm/support/event_buffer.rb
|
378
378
|
- lib/one_apm/support/event_buffer/sampled_buffer.rb
|
379
379
|
- lib/one_apm/support/event_buffer/sized_buffer.rb
|
380
380
|
- lib/one_apm/support/event_buffer/synthetics_event_buffer.rb
|
381
|
+
- lib/one_apm/support/forked_process_channel.rb
|
381
382
|
- lib/one_apm/support/helper.rb
|
382
383
|
- lib/one_apm/support/hostname.rb
|
383
384
|
- lib/one_apm/support/http_clients/curb_wrappers.rb
|
data/lib/one_apm/agent/agent.rb
DELETED
@@ -1,283 +0,0 @@
|
|
1
|
-
# encoding: utf-8
|
2
|
-
|
3
|
-
require 'socket'
|
4
|
-
require 'net/https'
|
5
|
-
require 'net/http'
|
6
|
-
require 'logger'
|
7
|
-
require 'zlib'
|
8
|
-
require 'stringio'
|
9
|
-
|
10
|
-
require 'one_apm/support/event_buffer/sampled_buffer'
|
11
|
-
require 'one_apm/configuration/autostart'
|
12
|
-
require 'one_apm/agent/harvester'
|
13
|
-
|
14
|
-
require 'one_apm/support/hostname'
|
15
|
-
require 'one_apm/support/environment_report'
|
16
|
-
|
17
|
-
require 'one_apm/configuration'
|
18
|
-
|
19
|
-
require 'one_apm/collector/collector_service'
|
20
|
-
require 'one_apm/collector/containers/agent_command_router'
|
21
|
-
require 'one_apm/collector/containers/transaction_event_aggregator'
|
22
|
-
require 'one_apm/collector/containers/custom_event_aggregator'
|
23
|
-
require 'one_apm/collector/containers/utilization_data'
|
24
|
-
|
25
|
-
require 'one_apm/agent/pipe/pipe_service'
|
26
|
-
require 'one_apm/agent/database'
|
27
|
-
require 'one_apm/agent/event/event_listener'
|
28
|
-
require 'one_apm/agent/cross_app/cross_app_monitor'
|
29
|
-
require 'one_apm/agent/synthetics_monitor'
|
30
|
-
require 'one_apm/support/event_buffer/synthetics_event_buffer'
|
31
|
-
require 'one_apm/agent/sampler_collection'
|
32
|
-
require 'one_apm/agent/javascript_instrumentor'
|
33
|
-
require 'one_apm/support/vm/monotonic_gc_profiler'
|
34
|
-
|
35
|
-
require 'one_apm/agent/agent/start'
|
36
|
-
require 'one_apm/agent/agent/start_worker_thread'
|
37
|
-
require 'one_apm/agent/agent/connect'
|
38
|
-
require 'one_apm/agent/agent/helpers'
|
39
|
-
require 'one_apm/agent/agent/container_data_manager'
|
40
|
-
require 'one_apm/agent/agent/forkable_dispatcher_functions'
|
41
|
-
|
42
|
-
module OneApm
|
43
|
-
module Agent
|
44
|
-
class Agent
|
45
|
-
include OneApm::Agent::Agent::Start
|
46
|
-
include OneApm::Agent::Agent::StartWorkerThread
|
47
|
-
include OneApm::Agent::Agent::Connect
|
48
|
-
include OneApm::Agent::Agent::Helpers
|
49
|
-
include OneApm::Agent::Agent::ContainerDataManager
|
50
|
-
include OneApm::Agent::Agent::ForkableDispatcherFunctions
|
51
|
-
|
52
|
-
# whether we should record raw, obfuscated, or no sql
|
53
|
-
attr_reader :record_sql
|
54
|
-
# builder for JS agent scripts to inject
|
55
|
-
attr_reader :javascript_instrumentor
|
56
|
-
# cross application tracing ids and encoding
|
57
|
-
attr_reader :cross_process_id
|
58
|
-
attr_reader :cross_app_encoding_bytes
|
59
|
-
attr_reader :cross_app_monitor
|
60
|
-
# service for communicating with collector
|
61
|
-
attr_accessor :service
|
62
|
-
# Global events dispatcher. This will provides our primary mechanism
|
63
|
-
# for agent-wide events, such as finishing configuration, error notification
|
64
|
-
# and request before/after from Rack.
|
65
|
-
attr_reader :events
|
66
|
-
# Transaction and metric renaming rules as provided by the
|
67
|
-
# collector on connect. The former are applied during txns,
|
68
|
-
# the latter during harvest.
|
69
|
-
attr_reader :transaction_rules
|
70
|
-
# Responsbile for restarting the harvest thread
|
71
|
-
attr_reader :harvester
|
72
|
-
attr_reader :harvest_samplers
|
73
|
-
attr_reader :harvest_lock
|
74
|
-
# GC::Profiler.total_time is not monotonic so we wrap it.
|
75
|
-
attr_reader :monotonic_gc_profiler
|
76
|
-
|
77
|
-
def self.instance
|
78
|
-
@instance ||= self.new
|
79
|
-
end
|
80
|
-
|
81
|
-
def self.config
|
82
|
-
OneApm::Agent.config
|
83
|
-
end
|
84
|
-
|
85
|
-
def initialize
|
86
|
-
# This should be handled with a configuration callback
|
87
|
-
start_service_if_needed
|
88
|
-
|
89
|
-
@events = OneApm::Agent::EventListener.new
|
90
|
-
|
91
|
-
init_containers @events
|
92
|
-
OneApm::Agent::SyntheticsMonitor.new @events
|
93
|
-
|
94
|
-
@cross_app_monitor = OneApm::Agent::CrossAppMonitor.new(@events)
|
95
|
-
@transaction_rules = OneApm::Support::RulesEngine.new
|
96
|
-
@harvest_samplers = OneApm::Agent::SamplerCollection.new(@events)
|
97
|
-
@monotonic_gc_profiler = OneApm::Support::VM::MonotonicGCProfiler.new
|
98
|
-
@javascript_instrumentor = OneApm::Agent::JavascriptInstrumentor.new(@events)
|
99
|
-
|
100
|
-
@harvester = OneApm::Agent::Harvester.new(@events)
|
101
|
-
@after_fork_lock = Mutex.new
|
102
|
-
|
103
|
-
@connect_state = :pending
|
104
|
-
@connect_attempts = 0
|
105
|
-
@environment_report = nil
|
106
|
-
|
107
|
-
@harvest_lock = Mutex.new
|
108
|
-
end
|
109
|
-
|
110
|
-
def probe
|
111
|
-
OneApm::Probe.instance
|
112
|
-
end
|
113
|
-
|
114
|
-
def start_service_if_needed
|
115
|
-
if Agent.config[:monitor_mode] && !@service
|
116
|
-
@service = OneApm::Collector::CollectorService.new
|
117
|
-
end
|
118
|
-
end
|
119
|
-
|
120
|
-
def start
|
121
|
-
return unless agent_should_start?
|
122
|
-
|
123
|
-
log_startup
|
124
|
-
check_config_and_start_agent
|
125
|
-
log_version_and_pid
|
126
|
-
|
127
|
-
events.subscribe(:finished_configuring) do
|
128
|
-
log_ignore_url_regexes
|
129
|
-
end
|
130
|
-
end
|
131
|
-
|
132
|
-
# Attempt a graceful shutdown of the agent, running the worker
|
133
|
-
# loop if it exists and is running.
|
134
|
-
#
|
135
|
-
# Options:
|
136
|
-
# :force_send => (true/false) # force the agent to send data
|
137
|
-
def shutdown(options={})
|
138
|
-
return if not started?
|
139
|
-
::OneApm::Agent.logger.info "Starting Agent shutdown"
|
140
|
-
|
141
|
-
stop_event_loop
|
142
|
-
untraced_graceful_disconnect
|
143
|
-
OneApm::Agent.revert_to_default_configuration
|
144
|
-
|
145
|
-
@started = nil
|
146
|
-
OneApm::Probe.reset
|
147
|
-
end
|
148
|
-
|
149
|
-
# Check to see if the agent should start, returning +true+ if it should.
|
150
|
-
def agent_should_start?
|
151
|
-
return false if already_started? || disabled? || defer_for_background_jobs?
|
152
|
-
|
153
|
-
unless app_name_configured?
|
154
|
-
OneApm::Agent.logger.error "No application name configured.",
|
155
|
-
"The Agent cannot start without at least one. Please check your ",
|
156
|
-
"oneapm.yml and ensure that it is valid and has at least one ",
|
157
|
-
"value set for app_name in the #{probe.env} ",
|
158
|
-
"environment."
|
159
|
-
return false
|
160
|
-
end
|
161
|
-
|
162
|
-
true
|
163
|
-
end
|
164
|
-
|
165
|
-
# Connect to the server and validate the license. If successful,
|
166
|
-
# connected? returns true when finished. If not successful, you can
|
167
|
-
# keep calling this. Return false if we could not establish a
|
168
|
-
# connection with the server and we should not retry, such as if
|
169
|
-
# there's a bad license key.
|
170
|
-
#
|
171
|
-
# Set keep_retrying=false to disable retrying and return asap, such as when
|
172
|
-
# invoked in the foreground. Otherwise this runs until a successful
|
173
|
-
# connection is made, or the server rejects us.
|
174
|
-
#
|
175
|
-
# * <tt>:keep_retrying => false</tt> to only try to connect once, and
|
176
|
-
# return with the connection set to nil. This ensures we may try again
|
177
|
-
# later (default true).
|
178
|
-
# * <tt>force_reconnect => true</tt> if you want to establish a new connection
|
179
|
-
# to the server before running the worker loop. This means you get a separate
|
180
|
-
# agent run and OneApm sees it as a separate instance (default is false).
|
181
|
-
def connect(options={})
|
182
|
-
begin
|
183
|
-
defaults = {
|
184
|
-
:keep_retrying => Agent.config[:keep_retrying],
|
185
|
-
:force_reconnect => Agent.config[:force_reconnect]
|
186
|
-
}
|
187
|
-
opts = defaults.merge(options)
|
188
|
-
|
189
|
-
return unless should_connect?(opts[:force_reconnect])
|
190
|
-
|
191
|
-
::OneApm::Agent.logger.debug "Connecting Process to OneApm: #$0"
|
192
|
-
query_server_for_configuration
|
193
|
-
@connected_pid = Process.pid
|
194
|
-
@connect_state = :connected
|
195
|
-
rescue OneApm::ForceDisconnectException => e
|
196
|
-
handle_force_disconnect(e)
|
197
|
-
rescue OneApm::LicenseException => e
|
198
|
-
handle_license_error(e)
|
199
|
-
rescue OneApm::UnrecoverableAgentException => e
|
200
|
-
handle_unrecoverable_agent_error(e)
|
201
|
-
rescue StandardError, Timeout::Error, OneApm::ServerConnectionException => e
|
202
|
-
log_error(e)
|
203
|
-
if opts[:keep_retrying]
|
204
|
-
note_connect_failure
|
205
|
-
::OneApm::Agent.logger.info "Will re-attempt in #{connect_retry_period} seconds"
|
206
|
-
sleep connect_retry_period
|
207
|
-
retry
|
208
|
-
else
|
209
|
-
disconnect
|
210
|
-
end
|
211
|
-
rescue Exception => e
|
212
|
-
::OneApm::Agent.logger.error "Exception of unexpected type during Agent#connect():", e
|
213
|
-
|
214
|
-
raise
|
215
|
-
end
|
216
|
-
end
|
217
|
-
|
218
|
-
# This method contacts the server to send remaining data and
|
219
|
-
# let the server know that the agent is shutting down - this
|
220
|
-
# allows us to do things like accurately set the end of the
|
221
|
-
# lifetime of the process
|
222
|
-
#
|
223
|
-
# If this process comes from a parent process, it will not
|
224
|
-
# disconnect, so that the parent process can continue to send data
|
225
|
-
def graceful_disconnect
|
226
|
-
if connected?
|
227
|
-
begin
|
228
|
-
@service.request_timeout = 10
|
229
|
-
|
230
|
-
@events.notify(:before_shutdown)
|
231
|
-
transmit_data
|
232
|
-
transmit_event_data
|
233
|
-
transmit_utilization_data if OneApm::Agent.config[:collect_utilization]
|
234
|
-
|
235
|
-
if @connected_pid == $$ && !@service.kind_of?(OneApm::Collector::CollectorService)
|
236
|
-
::OneApm::Agent.logger.debug "Sending OneApm service agent run shutdown message"
|
237
|
-
@service.shutdown(Time.now.to_f)
|
238
|
-
else
|
239
|
-
::OneApm::Agent.logger.debug "This agent connected from parent process #{@connected_pid}--not sending shutdown"
|
240
|
-
end
|
241
|
-
::OneApm::Agent.logger.debug "Graceful disconnect complete"
|
242
|
-
rescue Timeout::Error, StandardError => e
|
243
|
-
::OneApm::Agent.logger.debug "Error when disconnecting #{e.class.name}: #{e.message}"
|
244
|
-
end
|
245
|
-
else
|
246
|
-
::OneApm::Agent.logger.debug "Bypassing graceful disconnect - agent not connected"
|
247
|
-
end
|
248
|
-
end
|
249
|
-
|
250
|
-
def untraced_graceful_disconnect
|
251
|
-
begin
|
252
|
-
OneApm::Agent.disable_all_tracing do
|
253
|
-
graceful_disconnect
|
254
|
-
end
|
255
|
-
rescue => e
|
256
|
-
::OneApm::Agent.logger.error e
|
257
|
-
end
|
258
|
-
end
|
259
|
-
end
|
260
|
-
|
261
|
-
class ShimAgent < OneApm::Agent::Agent
|
262
|
-
def self.instance
|
263
|
-
@instance ||= self.new
|
264
|
-
end
|
265
|
-
|
266
|
-
def initialize
|
267
|
-
super
|
268
|
-
@stats_engine.extend OneApm::Collector::StatsEngine::Shim
|
269
|
-
@transaction_sampler.extend OneApm::Collector::TransactionSampler::Shim
|
270
|
-
@sql_sampler.extend OneApm::Collector::SqlSampler::Shim
|
271
|
-
@error_collector.extend OneApm::Collector::ErrorCollector::Shim
|
272
|
-
end
|
273
|
-
|
274
|
-
def after_fork *args; end
|
275
|
-
def start *args; end
|
276
|
-
def shutdown *args; end
|
277
|
-
def merge_data_for_endpoint *args; end
|
278
|
-
def push_trace_execution_flag *args; end
|
279
|
-
def pop_trace_execution_flag *args; end
|
280
|
-
def browser_timing_header; "" end
|
281
|
-
end
|
282
|
-
end
|
283
|
-
end
|