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
@@ -2,18 +2,18 @@
|
|
2
2
|
|
3
3
|
module OneApm
|
4
4
|
module Agent
|
5
|
-
class
|
5
|
+
class ForkedProcessService
|
6
6
|
attr_reader :channel_id, :buffer, :pipe
|
7
7
|
attr_accessor :request_timeout, :agent_id, :collector
|
8
8
|
|
9
9
|
def initialize(channel_id)
|
10
10
|
@channel_id = channel_id
|
11
11
|
@collector = OneApm::Support::Server.new(:name => 'parent', :port => 0)
|
12
|
-
@pipe = OneApm::
|
12
|
+
@pipe = OneApm::Support::ForkedProcessChannel.channels[@channel_id]
|
13
13
|
if @pipe && @pipe.parent_pid != $$
|
14
14
|
@pipe.after_fork_in_child
|
15
15
|
else
|
16
|
-
OneApm::
|
16
|
+
OneApm::Manager.logger.error("No communication channel to parent process.")
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
@@ -42,8 +42,8 @@ module OneApm
|
|
42
42
|
end
|
43
43
|
end
|
44
44
|
|
45
|
-
def self.record_gc_metric(call_count, elapsed)
|
46
|
-
OneApm::
|
45
|
+
def self.record_gc_metric(call_count, elapsed)
|
46
|
+
OneApm::Manager.agent.stats_engine.tl_record_scoped_and_unscoped_metrics(gc_metric_name, GC_ROLLUP) do |stats|
|
47
47
|
stats.call_count += call_count
|
48
48
|
stats.total_call_time += elapsed
|
49
49
|
stats.total_exclusive_time += elapsed
|
@@ -86,7 +86,7 @@ module OneApm
|
|
86
86
|
end
|
87
87
|
|
88
88
|
def call_time_s
|
89
|
-
OneApm::
|
89
|
+
OneApm::Manager.agent.monotonic_gc_profiler.total_time_s
|
90
90
|
end
|
91
91
|
|
92
92
|
def call_count
|
@@ -13,7 +13,7 @@ module OneApm
|
|
13
13
|
# metric_names may be either a single name, or an array of names.
|
14
14
|
#
|
15
15
|
# This is an internal method, subject to change at any time. Client apps
|
16
|
-
# and gems should use the public API (OneApm::
|
16
|
+
# and gems should use the public API (OneApm::Manager.record_metric)
|
17
17
|
# instead.
|
18
18
|
#
|
19
19
|
# There are four ways to use this method:
|
@@ -65,7 +65,7 @@ module OneApm
|
|
65
65
|
# Like tl_record_unscoped_metrics, but records a scoped metric as well.
|
66
66
|
#
|
67
67
|
# This is an internal method, subject to change at any time. Client apps
|
68
|
-
# and gems should use the public API (OneApm::
|
68
|
+
# and gems should use the public API (OneApm::Manager.record_metric)
|
69
69
|
# instead.
|
70
70
|
#
|
71
71
|
# The given scoped_metric will be recoded as both a scoped *and* an
|
@@ -106,7 +106,7 @@ module OneApm
|
|
106
106
|
end
|
107
107
|
|
108
108
|
# This method is deprecated and not thread safe, and should not be used
|
109
|
-
# by any new client code. Use OneApm::
|
109
|
+
# by any new client code. Use OneApm::Manager.record_metric instead.
|
110
110
|
#
|
111
111
|
# Lookup the Stats object for a given unscoped metric, returning a new
|
112
112
|
# Stats object if one did not exist previously.
|
@@ -119,7 +119,7 @@ module OneApm
|
|
119
119
|
end
|
120
120
|
|
121
121
|
# This method is deprecated and not thread safe, and should not be used
|
122
|
-
# by any new client code. Use OneApm::
|
122
|
+
# by any new client code. Use OneApm::Manager.record_metric instead.
|
123
123
|
#
|
124
124
|
# If scoped_metric_only is true, only a scoped metric is created (used
|
125
125
|
# by rendering metrics which by definition are per controller only)
|
@@ -1,6 +1,6 @@
|
|
1
1
|
# encoding: utf-8
|
2
2
|
|
3
|
-
# A Hash-descended class for storing metric data in the OneApm
|
3
|
+
# A Hash-descended class for storing metric data in the OneApm OneApm::Manager.
|
4
4
|
#
|
5
5
|
# Keys are OneApm::MetricSpec objects.
|
6
6
|
# Values are OneApm::Metrics::Stats objects.
|
@@ -56,7 +56,7 @@ module OneApm
|
|
56
56
|
rescue NoMethodError => e
|
57
57
|
# This only happen in the case of a corrupted default_proc
|
58
58
|
# Side-step it manually, notice the issue, and carry on....
|
59
|
-
OneApm::
|
59
|
+
OneApm::Manager.agent.error_collector. \
|
60
60
|
notice_agent_error(StatsHashLookupError.new(e, self, metric_spec))
|
61
61
|
|
62
62
|
stats = OneApm::Metrics::Stats.new
|
@@ -99,7 +99,7 @@ module OneApm
|
|
99
99
|
when YamlSource then @yaml_source = source
|
100
100
|
when DefaultSource then @default_source = source
|
101
101
|
else
|
102
|
-
OneApm::
|
102
|
+
OneApm::Manager.logger.warn("Invalid config format; config will be ignored: #{source}")
|
103
103
|
end
|
104
104
|
|
105
105
|
reset_cache
|
@@ -148,7 +148,7 @@ module OneApm
|
|
148
148
|
begin
|
149
149
|
transform.call(value)
|
150
150
|
rescue => e
|
151
|
-
|
151
|
+
OneApm::Manager.logger.error("Error applying transformation for #{key}, falling back to #{value}.", e)
|
152
152
|
raise e
|
153
153
|
end
|
154
154
|
else
|
@@ -182,7 +182,7 @@ module OneApm
|
|
182
182
|
end
|
183
183
|
|
184
184
|
def notify_finished_configuring
|
185
|
-
OneApm::
|
185
|
+
OneApm::Manager.agent.events.notify(:finished_configuring)
|
186
186
|
end
|
187
187
|
|
188
188
|
def finished_configuring?
|
@@ -196,7 +196,7 @@ module OneApm
|
|
196
196
|
begin
|
197
197
|
thawed_layer[k] = instance_eval(&v) if v.respond_to?(:call)
|
198
198
|
rescue => e
|
199
|
-
|
199
|
+
OneApm::Manager.logger.debug("#{e.class.name} : #{e.message} - when accessing config key #{k}")
|
200
200
|
thawed_layer[k] = nil
|
201
201
|
end
|
202
202
|
thawed_layer.delete(:config)
|
@@ -227,9 +227,9 @@ module OneApm
|
|
227
227
|
end
|
228
228
|
|
229
229
|
def app_names
|
230
|
-
case OneApm::
|
231
|
-
when Array then OneApm::
|
232
|
-
when String then OneApm::
|
230
|
+
case OneApm::Manager.config[:app_name]
|
231
|
+
when Array then OneApm::Manager.config[:app_name]
|
232
|
+
when String then OneApm::Manager.config[:app_name].split(';')
|
233
233
|
else []
|
234
234
|
end
|
235
235
|
end
|
@@ -241,19 +241,19 @@ module OneApm
|
|
241
241
|
MAX_LABEL_LENGTH = 255
|
242
242
|
|
243
243
|
def parsed_labels
|
244
|
-
case OneApm::
|
244
|
+
case OneApm::Manager.config[:labels]
|
245
245
|
when String
|
246
246
|
parse_labels_from_string
|
247
247
|
else
|
248
248
|
parse_labels_from_dictionary
|
249
249
|
end
|
250
250
|
rescue => e
|
251
|
-
OneApm::
|
251
|
+
OneApm::Manager.logger.error(PARSING_LABELS_FAILURE, e)
|
252
252
|
[]
|
253
253
|
end
|
254
254
|
|
255
255
|
def parse_labels_from_string
|
256
|
-
labels = OneApm::
|
256
|
+
labels = OneApm::Manager.config[:labels]
|
257
257
|
label_pairs = break_label_string_into_pairs(labels)
|
258
258
|
make_label_hash(label_pairs, labels)
|
259
259
|
end
|
@@ -286,7 +286,7 @@ module OneApm
|
|
286
286
|
pairs = Array(pairs)
|
287
287
|
|
288
288
|
unless valid_label_pairs?(pairs)
|
289
|
-
OneApm::
|
289
|
+
OneApm::Manager.logger.warn("#{MALFORMED_LABELS_WARNING}: #{labels||pairs}")
|
290
290
|
return []
|
291
291
|
end
|
292
292
|
|
@@ -307,7 +307,7 @@ module OneApm
|
|
307
307
|
else
|
308
308
|
msg = "Label name longer than the allowed #{MAX_LABEL_LENGTH} will be truncated. Name = '#{text}'"
|
309
309
|
end
|
310
|
-
OneApm::
|
310
|
+
OneApm::Manager.logger.warn(msg)
|
311
311
|
text[0..MAX_LABEL_LENGTH-1]
|
312
312
|
else
|
313
313
|
text
|
@@ -316,7 +316,7 @@ module OneApm
|
|
316
316
|
|
317
317
|
def limit_number_of_labels(pairs)
|
318
318
|
if pairs.length > MAX_LABEL_COUNT
|
319
|
-
OneApm::
|
319
|
+
OneApm::Manager.logger.warn("Too many labels defined. Only taking first #{MAX_LABEL_COUNT}")
|
320
320
|
pairs[0...64]
|
321
321
|
else
|
322
322
|
pairs
|
@@ -330,7 +330,7 @@ module OneApm
|
|
330
330
|
end
|
331
331
|
|
332
332
|
def parse_labels_from_dictionary
|
333
|
-
make_label_hash(OneApm::
|
333
|
+
make_label_hash(OneApm::Manager.config[:labels])
|
334
334
|
end
|
335
335
|
|
336
336
|
# Generally only useful during initial construction and tests
|
@@ -356,7 +356,7 @@ module OneApm
|
|
356
356
|
# flattened.inspect) is expensive enough that we don't want to do it
|
357
357
|
# unless we're actually going to be logging the message based on our
|
358
358
|
# current log level.
|
359
|
-
|
359
|
+
OneApm::Manager.logger.debug do
|
360
360
|
"Updating config (#{direction}) from #{source.class}. Results: #{flattened.inspect}"
|
361
361
|
end
|
362
362
|
end
|
@@ -409,7 +409,7 @@ module OneApm
|
|
409
409
|
const = constantize(class_name)
|
410
410
|
|
411
411
|
unless const
|
412
|
-
OneApm::
|
412
|
+
OneApm::Manager.logger.warn "Configuration referenced undefined constant: #{class_name}"
|
413
413
|
end
|
414
414
|
|
415
415
|
const
|
@@ -12,13 +12,13 @@ module OneApm
|
|
12
12
|
end
|
13
13
|
|
14
14
|
def blacklisted_constants?
|
15
|
-
blacklisted?(OneApm::
|
15
|
+
blacklisted?(OneApm::Manager.config[:'autostart.blacklisted_constants']) do |name|
|
16
16
|
OneApm::LanguageSupport.constant_is_defined?(name)
|
17
17
|
end
|
18
18
|
end
|
19
19
|
|
20
20
|
def blacklisted_executables?
|
21
|
-
blacklisted?(OneApm::
|
21
|
+
blacklisted?(OneApm::Manager.config[:'autostart.blacklisted_executables']) do |bin|
|
22
22
|
File.basename($0) == bin
|
23
23
|
end
|
24
24
|
end
|
@@ -31,10 +31,10 @@ module OneApm
|
|
31
31
|
tasks = begin
|
32
32
|
::Rake.application.top_level_tasks
|
33
33
|
rescue => e
|
34
|
-
|
34
|
+
OneApm::Manager.logger.debug("Not in Rake environment so skipping blacklisted_rake_tasks check: #{e}")
|
35
35
|
[]
|
36
36
|
end
|
37
|
-
!(tasks &
|
37
|
+
!(tasks & OneApm::Manager.config[:'autostart.blacklisted_rake_tasks'].split(/\s*,\s*/)).empty?
|
38
38
|
end
|
39
39
|
end
|
40
40
|
end
|
@@ -6,7 +6,7 @@ module OneApm
|
|
6
6
|
# Helper since default Procs are evaluated in the context of this module
|
7
7
|
def self.value_of(key)
|
8
8
|
Proc.new do
|
9
|
-
OneApm::
|
9
|
+
OneApm::Manager.config[key]
|
10
10
|
end
|
11
11
|
end
|
12
12
|
|
@@ -51,7 +51,7 @@ module OneApm
|
|
51
51
|
|
52
52
|
def self.config_path
|
53
53
|
Proc.new {
|
54
|
-
found_path = OneApm::
|
54
|
+
found_path = OneApm::Manager.config[:config_search_paths].detect do |file|
|
55
55
|
File.expand_path(file) if File.exists? file
|
56
56
|
end
|
57
57
|
found_path || ""
|
@@ -71,7 +71,7 @@ module OneApm
|
|
71
71
|
when 4
|
72
72
|
:rails4
|
73
73
|
else
|
74
|
-
|
74
|
+
OneApm::Manager.logger.error "Detected unsupported Rails version #{Rails::VERSION::STRING}"
|
75
75
|
end
|
76
76
|
when defined?(::Sinatra) && defined?(::Sinatra::Base) then :sinatra
|
77
77
|
when defined?(::OneApm::IA) then :external
|
@@ -82,15 +82,15 @@ module OneApm
|
|
82
82
|
|
83
83
|
def self.agent_enabled
|
84
84
|
Proc.new {
|
85
|
-
OneApm::
|
86
|
-
OneApm::
|
85
|
+
OneApm::Manager.config[:enabled] &&
|
86
|
+
OneApm::Manager.config[:monitor_mode] &&
|
87
87
|
OneApm::Configuration::Autostart.agent_should_start?
|
88
88
|
}
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.audit_log_path
|
92
92
|
Proc.new {
|
93
|
-
File.join(OneApm::
|
93
|
+
File.join(OneApm::Manager.config[:log_file_path], 'oneapm_audit.log')
|
94
94
|
}
|
95
95
|
end
|
96
96
|
|
@@ -121,15 +121,15 @@ module OneApm
|
|
121
121
|
# set. Once JS errors are GA, browser_monitoring.loader can stop
|
122
122
|
# being dynamic.
|
123
123
|
def self.browser_monitoring_loader
|
124
|
-
Proc.new { OneApm::
|
124
|
+
Proc.new { OneApm::Manager.config[:js_errors_beta] ? "full" : "rum"}
|
125
125
|
end
|
126
126
|
|
127
127
|
def self.transaction_tracer_transaction_threshold
|
128
|
-
Proc.new { OneApm::
|
128
|
+
Proc.new { OneApm::Manager.config[:apdex_t] * 4 }
|
129
129
|
end
|
130
130
|
|
131
131
|
def self.port
|
132
|
-
Proc.new { OneApm::
|
132
|
+
Proc.new { OneApm::Manager.config[:ssl] ? 443 : 80 }
|
133
133
|
end
|
134
134
|
|
135
135
|
def self.rules_ignore
|
@@ -93,7 +93,7 @@ module OneApm
|
|
93
93
|
self[config_key] = true
|
94
94
|
end
|
95
95
|
else
|
96
|
-
OneApm::
|
96
|
+
OneApm::Manager.logger.info("#{environment_key} does not have a corresponding configuration setting (#{config_key} does not exist).")
|
97
97
|
self[config_key] = value
|
98
98
|
end
|
99
99
|
end
|
@@ -46,7 +46,7 @@ module OneApm
|
|
46
46
|
end
|
47
47
|
|
48
48
|
if result != original_value
|
49
|
-
OneApm::
|
49
|
+
OneApm::Manager.logger.info("Disabling setting #{key}='#{original_value}' because high security mode is enabled. Value will be '#{result}'")
|
50
50
|
end
|
51
51
|
|
52
52
|
result
|
@@ -17,12 +17,12 @@ module OneApm
|
|
17
17
|
@file_path = validate_config_file_path(path)
|
18
18
|
return unless @file_path
|
19
19
|
|
20
|
-
OneApm::
|
20
|
+
OneApm::Manager.logger.info("Reading configuration from #{path} (#{Dir.pwd})")
|
21
21
|
raw_file = File.read(@file_path)
|
22
22
|
erb_file = process_erb(raw_file)
|
23
23
|
config = process_yaml(erb_file, env, config, @file_path)
|
24
24
|
rescue ScriptError, StandardError => e
|
25
|
-
|
25
|
+
OneApm::Manager.logger.error("Failed to read or parse configuration file at #{path}", e)
|
26
26
|
end
|
27
27
|
|
28
28
|
substitute_transaction_threshold(config)
|
@@ -46,13 +46,13 @@ module OneApm
|
|
46
46
|
|
47
47
|
def warn_missing_config_file(path)
|
48
48
|
based_on = 'unknown'
|
49
|
-
source =
|
49
|
+
source = OneApm::Manager.config.source(:config_path)
|
50
50
|
candidate_paths = [path]
|
51
51
|
|
52
52
|
case source
|
53
53
|
when DefaultSource
|
54
54
|
based_on = 'defaults'
|
55
|
-
candidate_paths = OneApm::
|
55
|
+
candidate_paths = OneApm::Manager.config[:config_search_paths].map do |p|
|
56
56
|
File.expand_path(p)
|
57
57
|
end
|
58
58
|
when EnvironmentSource
|
@@ -61,7 +61,7 @@ module OneApm
|
|
61
61
|
based_on = 'API call'
|
62
62
|
end
|
63
63
|
|
64
|
-
OneApm::
|
64
|
+
OneApm::Manager.logger.warn(
|
65
65
|
"No configuration file found. Working directory = #{Dir.pwd}",
|
66
66
|
"Looked in these locations (based on #{based_on}): #{candidate_paths.join(", ")}"
|
67
67
|
)
|
@@ -81,7 +81,7 @@ module OneApm
|
|
81
81
|
|
82
82
|
ERB.new(file).result(binding)
|
83
83
|
rescue ScriptError, StandardError => e
|
84
|
-
|
84
|
+
OneApm::Manager.logger.error("Failed ERB processing configuration file. This is typically caused by a Ruby error in <% %> templating blocks in your oneapm.yml file.", e)
|
85
85
|
nil
|
86
86
|
end
|
87
87
|
end
|
@@ -89,7 +89,7 @@ module OneApm
|
|
89
89
|
def process_yaml(file, env, config, path)
|
90
90
|
if file
|
91
91
|
confighash = with_yaml_engine { YAML.load(file) }
|
92
|
-
|
92
|
+
OneApm::Manager.logger.error("Config file at #{path} doesn't include a '#{env}' section!") unless confighash.key?(env)
|
93
93
|
|
94
94
|
config = confighash[env] || {}
|
95
95
|
end
|
@@ -47,7 +47,7 @@ class OneApm::NoticedError
|
|
47
47
|
@message = @message[0..4095] if @message.length > 4096
|
48
48
|
|
49
49
|
# replace error message if enabled
|
50
|
-
if OneApm::
|
50
|
+
if OneApm::Manager.config[:'strip_exception_messages.enabled'] &&
|
51
51
|
!self.class.passes_message_whitelist(exception.class)
|
52
52
|
@message = STRIPPED_EXCEPTION_REPLACEMENT_MESSAGE
|
53
53
|
end
|
@@ -64,7 +64,7 @@ class OneApm::NoticedError
|
|
64
64
|
end
|
65
65
|
|
66
66
|
def self.passes_message_whitelist(exception_class)
|
67
|
-
OneApm::
|
67
|
+
OneApm::Manager.config.stripped_exceptions_whitelist.any? do |klass|
|
68
68
|
exception_class <= klass
|
69
69
|
end
|
70
70
|
end
|
@@ -11,10 +11,6 @@ module OneApm
|
|
11
11
|
@env ||= RAILS_ENV.dup
|
12
12
|
end
|
13
13
|
|
14
|
-
# Rails can return an empty string from this method, causing
|
15
|
-
# the agent not to start even when it is properly in a rails 3
|
16
|
-
# application, so we test the value to make sure it actually
|
17
|
-
# has contents, and bail to the parent class if it is empty.
|
18
14
|
def root
|
19
15
|
root = rails_root.to_s
|
20
16
|
if !root.empty?
|
@@ -36,23 +32,17 @@ module OneApm
|
|
36
32
|
end
|
37
33
|
end
|
38
34
|
|
39
|
-
|
40
|
-
# the init.rb, so it had to be passed on from there. This is a best effort to
|
41
|
-
# find a config and use that.
|
42
|
-
def init_config(options={})
|
35
|
+
def init_config(options = {})
|
43
36
|
@config = options[:config]
|
44
37
|
|
45
38
|
if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
|
46
39
|
rails_config.after_initialize do
|
47
|
-
# This will insure we load all the instrumentation as late as possible.
|
48
40
|
LibraryDetection.detect!
|
49
41
|
end
|
50
42
|
end
|
51
43
|
|
52
|
-
if !
|
53
|
-
|
54
|
-
# is running, if it thinks it's a rake task, or if the agent_enabled is false.
|
55
|
-
::OneApm::Agent.logger.info("OneApm Agent not running.")
|
44
|
+
if !Manager.config[:agent_enabled]
|
45
|
+
OneApm::Manager.logger.info("OneApm Agent not running.")
|
56
46
|
else
|
57
47
|
install_browser_monitoring(rails_config)
|
58
48
|
install_agent_hooks(rails_config)
|
@@ -67,22 +57,22 @@ module OneApm
|
|
67
57
|
require 'one_apm/rack/middleware_hooks'
|
68
58
|
return unless OneApm::Rack::MiddlewareHooks.needed?
|
69
59
|
config.middleware.use OneApm::Rack::MiddlewareHooks
|
70
|
-
|
60
|
+
OneApm::Manager.logger.debug("Installed OneApm Agent Hooks middleware")
|
71
61
|
rescue => e
|
72
|
-
|
62
|
+
OneApm::Manager.logger.warn("Error installing OneApm Agent Hooks middleware", e)
|
73
63
|
end
|
74
64
|
end
|
75
65
|
|
76
66
|
def install_browser_monitoring(config)
|
77
67
|
return if @browser_monitoring_installed
|
78
68
|
@browser_monitoring_installed = true
|
79
|
-
return if config.nil? || !config.respond_to?(:middleware) || !
|
69
|
+
return if config.nil? || !config.respond_to?(:middleware) || !Manager.config[:'browser_monitoring.auto_instrument']
|
80
70
|
begin
|
81
71
|
require 'one_apm/rack/browser_monitoring'
|
82
72
|
config.middleware.use OneApm::Rack::BrowserMonitoring
|
83
|
-
|
73
|
+
OneApm::Manager.logger.debug("Installed OneApm Browser Monitoring middleware")
|
84
74
|
rescue => e
|
85
|
-
|
75
|
+
OneApm::Manager.logger.warn("Error installing OneApm Browser Monitoring middleware", e)
|
86
76
|
end
|
87
77
|
end
|
88
78
|
|