newrelic_rpm 3.6.6.147 → 3.6.7.152
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/.gitignore +0 -1
- data/CHANGELOG +55 -17
- data/Guardfile +7 -0
- data/Rakefile +6 -0
- data/bin/mongrel_rpm +33 -0
- data/bin/newrelic +13 -0
- data/bin/newrelic_cmd +5 -0
- data/bin/nrdebug +273 -0
- data/install.rb +3 -3
- data/lib/new_relic/agent.rb +4 -6
- data/lib/new_relic/agent/agent.rb +76 -72
- data/lib/new_relic/agent/autostart.rb +18 -5
- data/lib/new_relic/agent/browser_monitoring.rb +41 -35
- data/lib/new_relic/agent/browser_token.rb +38 -0
- data/lib/new_relic/agent/busy_calculator.rb +7 -5
- data/lib/new_relic/agent/commands/agent_command.rb +19 -0
- data/lib/new_relic/agent/commands/agent_command_router.rb +88 -0
- data/lib/new_relic/agent/commands/thread_profiler.rb +80 -0
- data/lib/new_relic/agent/configuration/default_source.rb +700 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +83 -30
- data/lib/new_relic/agent/configuration/manager.rb +8 -8
- data/lib/new_relic/agent/configuration/mask_defaults.rb +2 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +10 -21
- data/lib/new_relic/agent/cross_app_tracing.rb +3 -3
- data/lib/new_relic/agent/error_collector.rb +7 -10
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +5 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +5 -12
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +4 -0
- data/lib/new_relic/agent/instrumentation/{rails4/active_record.rb → active_record_4.rb} +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +11 -11
- data/lib/new_relic/agent/instrumentation/authlogic.rb +8 -6
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +12 -6
- data/lib/new_relic/agent/instrumentation/curb.rb +11 -2
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +1 -3
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +11 -2
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +13 -4
- data/lib/new_relic/agent/instrumentation/puma.rb +2 -1
- data/lib/new_relic/agent/instrumentation/rack.rb +15 -17
- data/lib/new_relic/agent/method_tracer.rb +181 -191
- data/lib/new_relic/agent/new_relic_service.rb +16 -14
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -1
- data/lib/new_relic/agent/request_sampler.rb +32 -165
- data/lib/new_relic/agent/sampled_buffer.rb +79 -0
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -8
- data/lib/new_relic/agent/sql_sampler.rb +3 -3
- data/lib/new_relic/agent/stats_engine.rb +1 -1
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +1 -1
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +2 -3
- data/lib/new_relic/agent/stats_engine/transactions.rb +2 -22
- data/lib/new_relic/agent/threading/agent_thread.rb +41 -0
- data/lib/new_relic/agent/threading/backtrace_node.rb +71 -0
- data/lib/new_relic/agent/threading/thread_profile.rb +172 -0
- data/lib/new_relic/agent/transaction.rb +16 -4
- data/lib/new_relic/agent/transaction_sample_builder.rb +13 -3
- data/lib/new_relic/agent/transaction_sampler.rb +5 -8
- data/lib/new_relic/agent/transaction_state.rb +166 -0
- data/lib/new_relic/agent/transaction_timings.rb +53 -0
- data/lib/new_relic/cli/command.rb +91 -0
- data/lib/new_relic/{commands → cli}/deployments.rb +13 -9
- data/lib/new_relic/{commands → cli}/install.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -8
- data/lib/new_relic/control/instance_methods.rb +1 -2
- data/lib/new_relic/helper.rb +9 -0
- data/lib/new_relic/local_environment.rb +16 -63
- data/lib/new_relic/rack/browser_monitoring.rb +8 -5
- data/lib/new_relic/recipes.rb +44 -31
- data/lib/new_relic/transaction_sample.rb +6 -2
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/install.rake +21 -1
- data/newrelic_rpm.gemspec +5 -1
- data/test/agent_helper.rb +4 -9
- data/test/environments/.gitignore +16 -0
- data/test/environments/lib/environments/runner.rb +104 -0
- data/test/environments/norails/Gemfile +11 -0
- data/test/environments/norails/Rakefile +9 -0
- data/test/environments/rails21/Gemfile +24 -0
- data/test/environments/rails21/Rakefile +12 -0
- data/test/environments/rails21/app/controllers/application.rb +20 -0
- data/test/environments/rails21/config/boot.rb +113 -0
- data/test/environments/rails21/config/database.yml +31 -0
- data/test/environments/rails21/config/environment.rb +28 -0
- data/test/environments/rails21/config/environments/development.rb +16 -0
- data/test/environments/rails21/config/environments/production.rb +8 -0
- data/test/environments/rails21/config/environments/test.rb +10 -0
- data/test/environments/rails21/config/routes.rb +5 -0
- data/test/environments/rails21/db/schema.rb +5 -0
- data/test/environments/rails22/Gemfile +29 -0
- data/test/environments/rails22/Rakefile +12 -0
- data/test/environments/rails22/app/controllers/application.rb +20 -0
- data/test/environments/rails22/config/boot.rb +113 -0
- data/test/environments/rails22/config/database.yml +31 -0
- data/test/environments/rails22/config/environment.rb +27 -0
- data/test/environments/rails22/config/environments/development.rb +16 -0
- data/test/environments/rails22/config/environments/production.rb +8 -0
- data/test/environments/rails22/config/environments/test.rb +10 -0
- data/test/environments/rails22/config/routes.rb +5 -0
- data/test/environments/rails22/db/schema.rb +5 -0
- data/test/environments/rails23/Gemfile +22 -0
- data/test/environments/rails23/Rakefile +12 -0
- data/test/environments/rails23/app/controllers/application.rb +20 -0
- data/test/environments/rails23/config/boot.rb +127 -0
- data/test/environments/rails23/config/database.yml +31 -0
- data/test/environments/rails23/config/environment.rb +25 -0
- data/test/environments/rails23/config/environments/development.rb +16 -0
- data/test/environments/rails23/config/environments/production.rb +8 -0
- data/test/environments/rails23/config/environments/test.rb +10 -0
- data/test/environments/rails23/config/preinitializer.rb +25 -0
- data/test/environments/rails23/config/routes.rb +5 -0
- data/test/environments/rails23/db/schema.rb +5 -0
- data/test/environments/rails30/Gemfile +19 -0
- data/test/environments/rails30/Rakefile +9 -0
- data/test/environments/rails30/config/application.rb +17 -0
- data/test/environments/rails30/config/boot.rb +10 -0
- data/test/environments/rails30/config/database.yml +31 -0
- data/test/environments/rails30/config/environment.rb +6 -0
- data/test/environments/rails30/config/initializers/new_rails_defaults.rb +11 -0
- data/test/environments/rails30/db/schema.rb +5 -0
- data/test/environments/rails31/Gemfile +19 -0
- data/test/environments/rails31/Rakefile +9 -0
- data/test/environments/rails31/config/application.rb +18 -0
- data/test/environments/rails31/config/boot.rb +10 -0
- data/test/environments/rails31/config/database.yml +31 -0
- data/test/environments/rails31/config/environment.rb +6 -0
- data/test/environments/rails31/config/initializers/new_rails_defaults.rb +21 -0
- data/test/environments/rails31/db/schema.rb +5 -0
- data/test/environments/rails32/Gemfile +25 -0
- data/test/environments/rails32/Rakefile +9 -0
- data/test/environments/rails32/config/application.rb +19 -0
- data/test/environments/rails32/config/boot.rb +10 -0
- data/test/environments/rails32/config/database.yml +31 -0
- data/test/environments/rails32/config/environment.rb +6 -0
- data/test/environments/rails32/db/schema.rb +5 -0
- data/test/environments/rails40/Gemfile +25 -0
- data/test/environments/rails40/Rakefile +9 -0
- data/test/environments/rails40/config/application.rb +18 -0
- data/test/environments/rails40/config/boot.rb +10 -0
- data/test/environments/rails40/config/database.yml +31 -0
- data/test/environments/rails40/config/environment.rb +6 -0
- data/test/environments/rails40/db/schema.rb +5 -0
- data/test/multiverse/lib/multiverse/suite.rb +24 -12
- data/test/multiverse/suites/agent_only/logging_test.rb +18 -1
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +1 -8
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +10 -7
- data/test/multiverse/suites/curb/curb_test.rb +17 -3
- data/test/multiverse/suites/excon/Envfile +1 -1
- data/test/multiverse/suites/excon/excon_test.rb +18 -2
- data/test/multiverse/suites/httpclient/httpclient_test.rb +2 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +2 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +35 -8
- data/test/multiverse/suites/rails/ignore_test.rb +48 -0
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +44 -0
- data/test/multiverse/suites/sequel/sequel_test.rb +11 -0
- data/test/multiverse/suites/sinatra/ignoring_test.rb +2 -2
- data/test/multiverse/suites/typhoeus/Envfile +9 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -2
- data/test/new_relic/agent/agent/start_test.rb +3 -22
- data/test/new_relic/agent/agent_test.rb +6 -5
- data/test/new_relic/agent/autostart_test.rb +39 -1
- data/test/new_relic/agent/browser_monitoring_test.rb +43 -88
- data/test/new_relic/agent/browser_token_test.rb +52 -0
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/commands/agent_command_router_test.rb +98 -0
- data/test/new_relic/agent/commands/agent_command_test.rb +37 -0
- data/test/new_relic/agent/commands/thread_profiler_test.rb +177 -0
- data/test/new_relic/agent/configuration/default_source_test.rb +81 -0
- data/test/new_relic/agent/configuration/environment_source_test.rb +81 -7
- data/test/new_relic/agent/configuration/manager_test.rb +16 -1
- data/test/new_relic/agent/cross_app_monitor_test.rb +3 -5
- data/test/new_relic/agent/error_collector_test.rb +14 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +2 -3
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +29 -31
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +22 -0
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +2 -2
- data/test/new_relic/agent/method_tracer_test.rb +2 -2
- data/test/new_relic/agent/new_relic_service_test.rb +5 -49
- data/test/new_relic/agent/pipe_channel_manager_test.rb +1 -0
- data/test/new_relic/agent/request_sampler_test.rb +32 -95
- data/test/new_relic/agent/rpm_agent_test.rb +7 -5
- data/test/new_relic/agent/sampled_buffer_test.rb +178 -0
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +0 -1
- data/test/new_relic/agent/stats_engine_test.rb +10 -17
- data/test/new_relic/agent/threading/agent_thread_test.rb +107 -0
- data/test/new_relic/agent/threading/backtrace_node_test.rb +96 -0
- data/test/new_relic/agent/{threaded_test.rb → threading/fake_thread.rb} +0 -25
- data/test/new_relic/agent/threading/thread_profile_test.rb +308 -0
- data/test/new_relic/agent/threading/threaded_test_case.rb +33 -0
- data/test/new_relic/agent/transaction/pop_test.rb +0 -16
- data/test/new_relic/agent/transaction_sample_builder_test.rb +23 -4
- data/test/new_relic/agent/transaction_sampler_test.rb +14 -15
- data/test/new_relic/agent/transaction_state_test.rb +75 -0
- data/test/new_relic/agent/transaction_test.rb +15 -0
- data/test/new_relic/agent/transaction_timings_test.rb +81 -0
- data/test/new_relic/agent_test.rb +12 -14
- data/test/new_relic/{command → cli}/deployments_test.rb +41 -13
- data/test/new_relic/control/frameworks/rails_test.rb +1 -2
- data/test/new_relic/control_test.rb +1 -2
- data/test/new_relic/dependency_detection_test.rb +14 -0
- data/test/new_relic/fake_collector.rb +1 -0
- data/test/new_relic/helper_test.rb +7 -2
- data/test/new_relic/http_client_test_cases.rb +33 -1
- data/test/new_relic/local_environment_test.rb +0 -23
- data/test/new_relic/metric_data_test.rb +4 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +31 -30
- data/test/performance/lib/performance/result.rb +15 -4
- data/test/performance/lib/performance/timer.rb +7 -1
- data/test/performance/script/baselines +102 -0
- data/test/performance/suites/rum_autoinsertion.rb +57 -0
- data/test/rum/basic.result.html +10 -0
- data/test/rum/basic.source.html +10 -0
- data/test/rum/comments1.result.html +24 -0
- data/test/rum/comments1.source.html +24 -0
- data/test/rum/comments2.result.html +24 -0
- data/test/rum/comments2.source.html +24 -0
- data/test/rum/gt_in_quotes1.result.html +27 -0
- data/test/rum/gt_in_quotes1.source.html +27 -0
- data/test/rum/gt_in_quotes2.result.html +24 -0
- data/test/rum/gt_in_quotes2.source.html +24 -0
- data/test/rum/gt_in_quotes_mismatch.result.html +24 -0
- data/test/rum/gt_in_quotes_mismatch.source.html +24 -0
- data/test/rum/gt_in_single_quotes1.result.html +25 -0
- data/test/rum/gt_in_single_quotes1.source.html +25 -0
- data/test/rum/gt_in_single_quotes_mismatch.result.html +25 -0
- data/test/rum/gt_in_single_quotes_mismatch.source.html +25 -0
- data/test/rum/incomplete_non_meta_tags.result.html +10 -0
- data/test/rum/incomplete_non_meta_tags.source.html +10 -0
- data/test/rum/no_body.result.html +21 -0
- data/test/rum/no_body.source.html +21 -0
- data/test/rum/no_header.result.html +7 -0
- data/test/rum/no_header.source.html +7 -0
- data/test/rum/no_start_header.result.html +9 -0
- data/test/rum/no_start_header.source.html +9 -0
- data/test/rum/script1.result.html +19 -0
- data/test/rum/script1.source.html +19 -0
- data/test/rum/script2.result.html +17 -0
- data/test/rum/script2.source.html +17 -0
- data/test/rum/x_ua_meta_tag.result.html +10 -0
- data/test/rum/x_ua_meta_tag.source.html +10 -0
- data/test/rum/x_ua_meta_tag_multiline.result.html +11 -0
- data/test/rum/x_ua_meta_tag_multiline.source.html +11 -0
- data/test/rum/x_ua_meta_tag_with_others.result.html +11 -0
- data/test/rum/x_ua_meta_tag_with_others.source.html +11 -0
- data/test/rum/x_ua_meta_tag_with_spaces.result.html +10 -0
- data/test/rum/x_ua_meta_tag_with_spaces.source.html +10 -0
- data/test/script/ci.sh +1 -12
- data/test/test_helper.rb +1 -0
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +11 -0
- metadata +225 -32
- metadata.gz.sig +0 -0
- data/lib/new_relic/agent/configuration/defaults.rb +0 -157
- data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +0 -56
- data/lib/new_relic/agent/thread.rb +0 -37
- data/lib/new_relic/agent/thread_profiler.rb +0 -323
- data/lib/new_relic/agent/transaction_info.rb +0 -114
- data/lib/new_relic/command.rb +0 -89
- data/test/new_relic/agent/agent_test_controller_test.rb +0 -348
- data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +0 -70
- data/test/new_relic/agent/thread_profiler_test.rb +0 -586
- data/test/new_relic/agent/thread_test.rb +0 -93
- data/test/new_relic/agent/transaction_info_test.rb +0 -99
@@ -6,43 +6,44 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Configuration
|
8
8
|
class EnvironmentSource < DottedHash
|
9
|
+
SUPPORTED_PREFIXES = /^new_relic_|newrelic_/i
|
10
|
+
|
11
|
+
attr_accessor :alias_map, :type_map
|
12
|
+
|
9
13
|
def initialize
|
10
|
-
|
11
|
-
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
self[val] = ENV[key] if ENV[key]
|
14
|
+
set_log_file
|
15
|
+
set_config_file
|
16
|
+
|
17
|
+
@alias_map = {}
|
18
|
+
@type_map = {}
|
19
|
+
|
20
|
+
DEFAULTS.each do |config_setting, value|
|
21
|
+
self.type_map[config_setting] = value[:type]
|
22
|
+
set_aliases(config_setting, value)
|
20
23
|
end
|
21
24
|
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
25
|
+
set_values_from_new_relic_environment_variables
|
26
|
+
end
|
27
|
+
|
28
|
+
def set_aliases(config_setting, value)
|
29
|
+
set_dotted_alias(config_setting)
|
30
|
+
|
31
|
+
return unless value[:aliases]
|
32
|
+
value[:aliases].each do |config_alias|
|
33
|
+
self.alias_map[config_alias] = config_setting
|
29
34
|
end
|
35
|
+
end
|
30
36
|
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
'
|
36
|
-
|
37
|
-
'NEW_RELIC_DISABLE_HARVEST_THREAD' => :disable_harvest_thread
|
38
|
-
}.each do |key, val|
|
39
|
-
if ENV[key].to_s =~ /false|off|no/i
|
40
|
-
self[val] = false
|
41
|
-
elsif ENV[key] != nil
|
42
|
-
self[val] = true
|
43
|
-
end
|
37
|
+
def set_dotted_alias(original_config_setting)
|
38
|
+
config_setting = original_config_setting.to_s
|
39
|
+
|
40
|
+
if config_setting.include? '.'
|
41
|
+
config_alias = config_setting.gsub(/\./,'_').to_sym
|
42
|
+
self.alias_map[config_alias] = original_config_setting
|
44
43
|
end
|
44
|
+
end
|
45
45
|
|
46
|
+
def set_log_file
|
46
47
|
if ENV['NEW_RELIC_LOG']
|
47
48
|
if ENV['NEW_RELIC_LOG'].upcase == 'STDOUT'
|
48
49
|
self[:log_file_path] = self[:log_file_name] = 'STDOUT'
|
@@ -52,6 +53,58 @@ module NewRelic
|
|
52
53
|
end
|
53
54
|
end
|
54
55
|
end
|
56
|
+
|
57
|
+
def set_config_file
|
58
|
+
self[:config_path] = ENV['NRCONFIG'] if ENV['NRCONFIG']
|
59
|
+
end
|
60
|
+
|
61
|
+
def set_values_from_new_relic_environment_variables
|
62
|
+
nr_env_var_keys = collect_new_relic_environment_variable_keys
|
63
|
+
|
64
|
+
nr_env_var_keys.each do |key|
|
65
|
+
set_value_from_environment_variable(key)
|
66
|
+
end
|
67
|
+
end
|
68
|
+
|
69
|
+
def set_value_from_environment_variable(key)
|
70
|
+
config_key = convert_environment_key_to_config_key(key)
|
71
|
+
set_key_by_type(config_key, key)
|
72
|
+
end
|
73
|
+
|
74
|
+
def set_key_by_type(config_key, environment_key)
|
75
|
+
value = ENV[environment_key]
|
76
|
+
type = self.type_map[config_key]
|
77
|
+
|
78
|
+
if type == String
|
79
|
+
self[config_key] = value
|
80
|
+
elsif type == Fixnum
|
81
|
+
self[config_key] = value.to_i
|
82
|
+
elsif type == Float
|
83
|
+
self[config_key] = value.to_f
|
84
|
+
elsif type == Symbol
|
85
|
+
self[config_key] = value.to_sym
|
86
|
+
elsif type == NewRelic::Agent::Configuration::Boolean
|
87
|
+
if value =~ /false|off|no/i
|
88
|
+
self[config_key] = false
|
89
|
+
elsif value != nil
|
90
|
+
self[config_key] = true
|
91
|
+
end
|
92
|
+
else
|
93
|
+
::NewRelic::Agent.logger.info("#{environment_key} does not have a corresponding configuration setting (#{config_key} does not exist).")
|
94
|
+
::NewRelic::Agent.logger.info("Run `rake newrelic:config:docs` or visit https://newrelic.com/docs/ruby/ruby-agent-configuration to see a list of available configuration settings.")
|
95
|
+
self[config_key] = value
|
96
|
+
end
|
97
|
+
end
|
98
|
+
|
99
|
+
def convert_environment_key_to_config_key(key)
|
100
|
+
stripped_key = key.gsub(SUPPORTED_PREFIXES, '').downcase.to_sym
|
101
|
+
self.alias_map[stripped_key] || stripped_key
|
102
|
+
end
|
103
|
+
|
104
|
+
def collect_new_relic_environment_variable_keys
|
105
|
+
ENV.keys.select { |key| key.match(SUPPORTED_PREFIXES) }
|
106
|
+
end
|
107
|
+
|
55
108
|
end
|
56
109
|
end
|
57
110
|
end
|
@@ -3,9 +3,9 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'forwardable'
|
6
|
-
require 'new_relic/agent/configuration/defaults'
|
7
6
|
require 'new_relic/agent/configuration/mask_defaults'
|
8
7
|
require 'new_relic/agent/configuration/yaml_source'
|
8
|
+
require 'new_relic/agent/configuration/default_source'
|
9
9
|
require 'new_relic/agent/configuration/server_source'
|
10
10
|
require 'new_relic/agent/configuration/environment_source'
|
11
11
|
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
module Configuration
|
15
15
|
class Manager
|
16
16
|
extend Forwardable
|
17
|
-
def_delegators :@cache, :[], :has_key
|
17
|
+
def_delegators :@cache, :[], :has_key?, :keys
|
18
18
|
attr_reader :config_stack, :stripped_exceptions_whitelist
|
19
19
|
|
20
20
|
def initialize
|
@@ -53,9 +53,9 @@ module NewRelic
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def replace_or_add_config(source, level=0)
|
56
|
-
|
57
|
-
@config_stack.delete_at(
|
58
|
-
apply_config(source,
|
56
|
+
index = @config_stack.map{|s| s.class}.index(source.class)
|
57
|
+
@config_stack.delete_at(index) if index
|
58
|
+
apply_config(source, index || level)
|
59
59
|
end
|
60
60
|
|
61
61
|
def source(key)
|
@@ -111,7 +111,7 @@ module NewRelic
|
|
111
111
|
|
112
112
|
def flattened
|
113
113
|
@config_stack.reverse.inject({}) do |flat,layer|
|
114
|
-
thawed_layer = layer.dup
|
114
|
+
thawed_layer = layer.to_hash.dup
|
115
115
|
thawed_layer.each do |k,v|
|
116
116
|
begin
|
117
117
|
thawed_layer[k] = instance_eval(&v) if v.respond_to?(:call)
|
@@ -121,7 +121,7 @@ module NewRelic
|
|
121
121
|
end
|
122
122
|
thawed_layer.delete(:config)
|
123
123
|
end
|
124
|
-
flat.merge(thawed_layer)
|
124
|
+
flat.merge(thawed_layer.to_hash)
|
125
125
|
end
|
126
126
|
end
|
127
127
|
|
@@ -146,7 +146,7 @@ module NewRelic
|
|
146
146
|
|
147
147
|
# Generally only useful during initial construction and tests
|
148
148
|
def reset_to_defaults
|
149
|
-
@config_stack = [ EnvironmentSource.new,
|
149
|
+
@config_stack = [ EnvironmentSource.new, DefaultSource.new ]
|
150
150
|
reset_cache
|
151
151
|
end
|
152
152
|
|
@@ -6,8 +6,8 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Configuration
|
8
8
|
MASK_DEFAULTS = {
|
9
|
-
:'thread_profiler' => Proc.new { !NewRelic::Agent::ThreadProfiler.is_supported? },
|
10
|
-
:'thread_profiler.enabled' => Proc.new { !NewRelic::Agent::ThreadProfiler.is_supported? }
|
9
|
+
:'thread_profiler' => Proc.new { !NewRelic::Agent::Commands::ThreadProfiler.is_supported? },
|
10
|
+
:'thread_profiler.enabled' => Proc.new { !NewRelic::Agent::Commands::ThreadProfiler.is_supported? }
|
11
11
|
}
|
12
12
|
end
|
13
13
|
end
|
@@ -3,7 +3,8 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'new_relic/rack/agent_hooks'
|
6
|
-
require 'new_relic/agent/
|
6
|
+
require 'new_relic/agent/transaction_state'
|
7
|
+
require 'new_relic/agent/threading/agent_thread'
|
7
8
|
|
8
9
|
module NewRelic
|
9
10
|
module Agent
|
@@ -21,14 +22,6 @@ module NewRelic
|
|
21
22
|
}
|
22
23
|
CONTENT_LENGTH_HEADER_KEYS = %w{Content-Length HTTP_CONTENT_LENGTH CONTENT_LENGTH}
|
23
24
|
|
24
|
-
# Because we aren't in the right spot when our transaction actually
|
25
|
-
# starts, hold client_cross_app_id we get thread local until then.
|
26
|
-
THREAD_ID_KEY = :newrelic_client_cross_app_id
|
27
|
-
|
28
|
-
# Same for the referring transaction guid
|
29
|
-
THREAD_TXN_KEY = :newrelic_cross_app_referring_txn_info
|
30
|
-
|
31
|
-
|
32
25
|
# Functions for obfuscating and unobfuscating header values
|
33
26
|
module EncodingFunctions
|
34
27
|
|
@@ -101,15 +94,15 @@ module NewRelic
|
|
101
94
|
end
|
102
95
|
|
103
96
|
def save_client_cross_app_id(request_headers)
|
104
|
-
|
97
|
+
TransactionState.get.client_cross_app_id = decoded_id(request_headers)
|
105
98
|
end
|
106
99
|
|
107
100
|
def clear_client_cross_app_id
|
108
|
-
|
101
|
+
TransactionState.get.client_cross_app_id = nil
|
109
102
|
end
|
110
103
|
|
111
104
|
def client_cross_app_id
|
112
|
-
|
105
|
+
TransactionState.get.client_cross_app_id
|
113
106
|
end
|
114
107
|
|
115
108
|
def save_referring_transaction_info(request_headers)
|
@@ -119,27 +112,23 @@ module NewRelic
|
|
119
112
|
txn_info = NewRelic.json_load( txn_header )
|
120
113
|
NewRelic::Agent.logger.debug "Referring txn_info: %p" % [ txn_info ]
|
121
114
|
|
122
|
-
|
123
|
-
end
|
124
|
-
|
125
|
-
def clear_referring_transaction_info
|
126
|
-
NewRelic::Agent::AgentThread.current[THREAD_TXN_KEY] = nil
|
115
|
+
TransactionState.get.referring_transaction_info = txn_info
|
127
116
|
end
|
128
117
|
|
129
118
|
def client_referring_transaction_guid
|
130
|
-
info =
|
119
|
+
info = TransactionState.get.referring_transaction_info or return nil
|
131
120
|
return info[0]
|
132
121
|
end
|
133
122
|
|
134
123
|
def client_referring_transaction_record_flag
|
135
|
-
info =
|
124
|
+
info = TransactionState.get.referring_transaction_info or return nil
|
136
125
|
return info[1]
|
137
126
|
end
|
138
127
|
|
139
128
|
def insert_response_header(request_headers, response_headers)
|
140
129
|
unless client_cross_app_id.nil?
|
141
130
|
NewRelic::Agent::Transaction.freeze_name
|
142
|
-
timings = NewRelic::Agent::
|
131
|
+
timings = NewRelic::Agent::TransactionState.get.timings
|
143
132
|
content_length = content_length_from_request(request_headers)
|
144
133
|
|
145
134
|
set_response_headers(response_headers, timings, content_length)
|
@@ -220,7 +209,7 @@ module NewRelic
|
|
220
209
|
end
|
221
210
|
|
222
211
|
def transaction_guid
|
223
|
-
NewRelic::Agent::
|
212
|
+
NewRelic::Agent::TransactionState.get.request_guid
|
224
213
|
end
|
225
214
|
|
226
215
|
private
|
@@ -103,7 +103,7 @@ module NewRelic
|
|
103
103
|
|
104
104
|
# Add TT custom parameters
|
105
105
|
segment.name = scoped_metric
|
106
|
-
add_transaction_trace_parameters(request, response)
|
106
|
+
add_transaction_trace_parameters(request, response)
|
107
107
|
end
|
108
108
|
ensure
|
109
109
|
# We always need to pop the scope stack to avoid an inconsistent
|
@@ -138,7 +138,7 @@ module NewRelic
|
|
138
138
|
key = cross_app_encoding_key()
|
139
139
|
cross_app_id = NewRelic::Agent.config[:cross_process_id] or
|
140
140
|
raise NewRelic::Agent::CrossAppTracing::Error, "no cross app ID configured"
|
141
|
-
txn_guid = NewRelic::Agent::
|
141
|
+
txn_guid = NewRelic::Agent::TransactionState.get.request_guid
|
142
142
|
txn_data = NewRelic.json_dump([ txn_guid, false ])
|
143
143
|
|
144
144
|
request[ NR_ID_HEADER ] = obfuscate_with_key( key, cross_app_id )
|
@@ -151,7 +151,7 @@ module NewRelic
|
|
151
151
|
def add_transaction_trace_parameters(request, response)
|
152
152
|
filtered_uri = ::NewRelic::Agent::HTTPClients::URIUtil.filter_uri(request.uri)
|
153
153
|
transaction_sampler.add_segment_parameters(:uri => filtered_uri)
|
154
|
-
if response_is_crossapp?( response )
|
154
|
+
if response && response_is_crossapp?( response )
|
155
155
|
add_cat_transaction_trace_parameters( response )
|
156
156
|
end
|
157
157
|
end
|
@@ -20,10 +20,6 @@ module NewRelic
|
|
20
20
|
# memory and data retention
|
21
21
|
MAX_ERROR_QUEUE_LENGTH = 20 unless defined? MAX_ERROR_QUEUE_LENGTH
|
22
22
|
|
23
|
-
# This ivar is used to tag exceptions that we've alreday seen, so that we
|
24
|
-
# don't double-count them.
|
25
|
-
EXCEPTION_TAG_IVAR = :@__new_relic_exception_tag
|
26
|
-
|
27
23
|
attr_accessor :errors
|
28
24
|
|
29
25
|
# Returns a new error collector
|
@@ -101,20 +97,21 @@ module NewRelic
|
|
101
97
|
end
|
102
98
|
|
103
99
|
def seen?(exception)
|
104
|
-
|
100
|
+
error_ids = TransactionState.get.transaction_noticed_error_ids
|
101
|
+
error_ids.include?(exception.object_id)
|
105
102
|
end
|
106
103
|
|
107
104
|
def tag_as_seen(exception)
|
108
|
-
|
105
|
+
txn = Transaction.current
|
106
|
+
txn.noticed_error_ids << exception.object_id if txn
|
109
107
|
end
|
110
108
|
|
111
109
|
def blamed_metric_name(options)
|
112
110
|
if options[:metric] && options[:metric] != ::NewRelic::Agent::UNKNOWN_METRIC
|
113
111
|
"Errors/#{options[:metric]}"
|
114
112
|
else
|
115
|
-
|
116
|
-
|
117
|
-
"Errors/#{txn_info.transaction.name}"
|
113
|
+
if txn = TransactionState.get.transaction
|
114
|
+
"Errors/#{txn.name}"
|
118
115
|
end
|
119
116
|
end
|
120
117
|
end
|
@@ -264,7 +261,7 @@ module NewRelic
|
|
264
261
|
return if should_exit_notice_error?(exception)
|
265
262
|
increment_error_count!(exception, options)
|
266
263
|
NewRelic::Agent.instance.events.notify(:notice_error, exception, options)
|
267
|
-
action_path = fetch_from_options(options, :metric,
|
264
|
+
action_path = fetch_from_options(options, :metric, "")
|
268
265
|
exception_options = error_params_from_options(options).merge(exception_info(exception))
|
269
266
|
add_to_error_queue(NewRelic::NoticedError.new(action_path, exception_options, exception))
|
270
267
|
exception
|
@@ -18,12 +18,12 @@ module NewRelic
|
|
18
18
|
Agent.logger.debug("Error creating Rack::Request object: #{e}")
|
19
19
|
nil
|
20
20
|
end
|
21
|
-
|
21
|
+
TransactionState.reset(request)
|
22
22
|
end
|
23
23
|
end
|
24
24
|
|
25
25
|
def start(name, id, payload)
|
26
|
-
payload[:request] =
|
26
|
+
payload[:request] = TransactionState.get.request
|
27
27
|
event = ControllerEvent.new(name, Time.now, nil, id, payload)
|
28
28
|
push_event(event)
|
29
29
|
|
@@ -35,7 +35,7 @@ module NewRelic
|
|
35
35
|
NewRelic::Agent.instance.push_trace_execution_flag(false)
|
36
36
|
end
|
37
37
|
rescue => e
|
38
|
-
|
38
|
+
log_notification_error(e, name, 'start')
|
39
39
|
end
|
40
40
|
|
41
41
|
def finish(name, id, payload)
|
@@ -55,18 +55,11 @@ module NewRelic
|
|
55
55
|
Agent.instance.pop_trace_execution_flag
|
56
56
|
end
|
57
57
|
rescue => e
|
58
|
-
|
59
|
-
end
|
60
|
-
|
61
|
-
def handle_tracing_error(identifier, e)
|
62
|
-
# This is an important enough failure that we want the backtrace logged
|
63
|
-
# at error level, hence the explicit log_exception call.
|
64
|
-
NewRelic::Agent.logger.error("Tracing error during #{identifier}:")
|
65
|
-
NewRelic::Agent.logger.log_exception(:error, e)
|
58
|
+
log_notification_error(e, name, 'finish')
|
66
59
|
end
|
67
60
|
|
68
61
|
def set_enduser_ignore
|
69
|
-
|
62
|
+
TransactionState.get.request_ignore_enduser = true
|
70
63
|
end
|
71
64
|
|
72
65
|
def record_metrics(event)
|