newrelic_rpm 3.8.1.221 → 3.9.0.229
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 +1 -0
- data/.yardopts +2 -0
- data/CHANGELOG +95 -0
- data/README.md +9 -3
- data/Rakefile +6 -0
- data/lib/new_relic/agent.rb +37 -52
- data/lib/new_relic/agent/agent.rb +32 -64
- data/lib/new_relic/agent/agent_logger.rb +3 -2
- data/lib/new_relic/agent/audit_logger.rb +2 -1
- data/lib/new_relic/agent/busy_calculator.rb +10 -8
- data/lib/new_relic/agent/configuration.rb +0 -13
- data/lib/new_relic/agent/configuration/default_source.rb +27 -20
- data/lib/new_relic/agent/configuration/manager.rb +101 -27
- data/lib/new_relic/agent/cross_app_monitor.rb +43 -50
- data/lib/new_relic/agent/cross_app_tracing.rb +13 -12
- data/lib/new_relic/agent/error_collector.rb +31 -35
- data/lib/new_relic/agent/harvester.rb +5 -1
- data/lib/new_relic/agent/hostname.rb +17 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +1 -1
- data/lib/new_relic/agent/http_clients/uri_util.rb +13 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +18 -32
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +15 -15
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record.rb +6 -4
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +3 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +18 -20
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +79 -93
- data/lib/new_relic/agent/instrumentation/curb.rb +3 -3
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +5 -4
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +96 -0
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +69 -0
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/queue_time.rb +21 -13
- data/lib/new_relic/agent/instrumentation/rack.rb +85 -74
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +3 -1
- data/lib/new_relic/agent/instrumentation/rails_middleware.rb +39 -0
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +3 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +28 -5
- data/lib/new_relic/agent/instrumentation/sinatra.rb +4 -4
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +4 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +34 -30
- data/lib/new_relic/agent/memory_logger.rb +12 -12
- data/lib/new_relic/agent/method_tracer.rb +34 -74
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/pipe_channel_manager.rb +3 -3
- data/lib/new_relic/agent/request_sampler.rb +10 -11
- data/lib/new_relic/agent/samplers/vm_sampler.rb +6 -6
- data/lib/new_relic/agent/shim_agent.rb +2 -1
- data/lib/new_relic/agent/sql_sampler.rb +52 -27
- data/lib/new_relic/agent/stats.rb +24 -10
- data/lib/new_relic/agent/stats_engine/gc_profiler.rb +5 -17
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +106 -58
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +20 -24
- data/lib/new_relic/agent/supported_versions.rb +3 -1
- data/lib/new_relic/agent/threading/agent_thread.rb +42 -11
- data/lib/new_relic/agent/threading/backtrace_service.rb +3 -7
- data/lib/new_relic/agent/threading/thread_profile.rb +2 -2
- data/lib/new_relic/agent/traced_method_stack.rb +28 -18
- data/lib/new_relic/agent/transaction.rb +249 -196
- data/lib/new_relic/agent/transaction_metrics.rb +57 -0
- data/lib/new_relic/agent/transaction_sample_builder.rb +10 -7
- data/lib/new_relic/agent/transaction_sampler.rb +81 -45
- data/lib/new_relic/agent/transaction_state.rb +38 -49
- data/lib/new_relic/agent/vm/monotonic_gc_profiler.rb +15 -18
- data/lib/new_relic/agent/vm/rubinius_vm.rb +4 -2
- data/lib/new_relic/cli/commands/deployments.rb +3 -2
- data/lib/new_relic/control/frameworks/ruby.rb +2 -3
- data/lib/new_relic/control/frameworks/sinatra.rb +0 -7
- data/lib/new_relic/control/instance_methods.rb +3 -5
- data/lib/new_relic/json_wrapper.rb +2 -0
- data/lib/new_relic/language_support.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -16
- data/lib/new_relic/metric_spec.rb +10 -38
- data/lib/new_relic/noticed_error.rb +16 -11
- data/lib/new_relic/rack/agent_hooks.rb +4 -10
- data/lib/new_relic/rack/agent_middleware.rb +31 -0
- data/lib/new_relic/rack/browser_monitoring.rb +7 -13
- data/lib/new_relic/rack/developer_mode.rb +16 -59
- data/lib/new_relic/rack/error_collector.rb +16 -54
- data/lib/new_relic/recipes.rb +8 -101
- data/lib/new_relic/recipes/capistrano3.rb +66 -0
- data/lib/new_relic/recipes/capistrano_legacy.rb +98 -0
- data/lib/new_relic/transaction_sample.rb +6 -54
- data/lib/new_relic/transaction_sample/composite_segment.rb +1 -1
- data/lib/new_relic/transaction_sample/segment.rb +12 -4
- data/lib/new_relic/transaction_sample/summary_segment.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +19 -19
- data/lib/tasks/tests.rake +20 -1
- data/lib/tasks/versions.html.erb +0 -4
- data/lib/tasks/versions.rake +4 -3
- data/newrelic.yml +4 -12
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +146 -44
- data/test/config/newrelic.yml +0 -1
- data/test/environments/norails/Gemfile +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails23/Gemfile +1 -1
- data/test/environments/rails30/Gemfile +1 -1
- data/test/environments/rails31/Gemfile +1 -1
- data/test/environments/rails32/Gemfile +1 -1
- data/test/environments/rails40/Gemfile +1 -1
- data/test/environments/rails41/Gemfile +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +13 -1
- data/test/multiverse/lib/multiverse/suite.rb +26 -9
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -1
- data/test/multiverse/suites/activemerchant/Envfile +18 -1
- data/test/multiverse/suites/agent_only/audit_log_test.rb +4 -3
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +35 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +0 -1
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +1 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +3 -2
- data/test/multiverse/suites/agent_only/exclusive_time_test.rb +178 -0
- data/test/multiverse/suites/agent_only/logging_test.rb +10 -6
- data/test/multiverse/suites/agent_only/marshaling_test.rb +11 -9
- data/test/multiverse/suites/agent_only/script/loading.rb +1 -1
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +5 -1
- data/test/multiverse/suites/agent_only/transaction_ignoring_test.rb +2 -1
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +9 -9
- data/test/multiverse/suites/capistrano/Capfile +26 -0
- data/test/multiverse/suites/capistrano/Envfile +18 -0
- data/test/multiverse/suites/capistrano/config/deploy.rb +10 -0
- data/test/multiverse/suites/capistrano/config/deploy/production.rb +9 -0
- data/test/multiverse/suites/capistrano/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano/deployment_test.rb +47 -0
- data/test/multiverse/suites/capistrano2/Capfile +4 -0
- data/test/multiverse/suites/capistrano2/Envfile +4 -0
- data/test/multiverse/suites/capistrano2/config/deploy.rb +19 -0
- data/test/multiverse/suites/capistrano2/config/newrelic.yml +21 -0
- data/test/multiverse/suites/capistrano2/deployment_test.rb +38 -0
- data/test/multiverse/suites/curb/Envfile +10 -1
- data/test/multiverse/suites/curb/config/newrelic.yml +0 -1
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -1
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +0 -1
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -1
- data/test/multiverse/suites/httpclient/config/newrelic.yml +0 -1
- data/test/multiverse/suites/mongo/config/newrelic.yml +0 -1
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -1
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -1
- data/test/multiverse/suites/rack/Envfile +25 -0
- data/test/multiverse/suites/rack/example_app.rb +50 -0
- data/test/multiverse/suites/rack/nested_non_rack_app_test.rb +66 -0
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +143 -0
- data/test/multiverse/suites/rack/rack_unsupported_version_test.rb +45 -0
- data/test/multiverse/suites/rack/url_map_test.rb +120 -0
- data/test/multiverse/suites/rails/Envfile +10 -0
- data/test/multiverse/suites/rails/app.rb +28 -63
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +2 -4
- data/test/multiverse/suites/rails/config/newrelic.yml +1 -2
- data/test/multiverse/suites/rails/dummy.txt +1 -0
- data/test/multiverse/suites/rails/error_tracing_test.rb +46 -31
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +0 -1
- data/test/multiverse/suites/rails/ignore_test.rb +9 -3
- data/test/multiverse/suites/rails/middleware_instrumentation_test.rb +41 -0
- data/test/multiverse/suites/rails/middlewares.rb +19 -0
- data/test/multiverse/suites/rails/parameter_capture_test.rb +169 -0
- data/test/multiverse/suites/rails/queue_time_test.rb +14 -4
- data/test/multiverse/suites/rails/rails2_app/app/controllers/application.rb +7 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +127 -0
- data/test/multiverse/suites/rails/rails2_app/config/database.yml +18 -0
- data/test/multiverse/suites/rails/rails2_app/config/environment.rb +16 -0
- data/test/multiverse/suites/rails/rails2_app/config/environments/development.rb +10 -0
- data/test/multiverse/suites/rails/rails2_app/config/initializers/load_newrelic_rpm.rb +9 -0
- data/test/multiverse/suites/rails/rails2_app/config/preinitializer.rb +25 -0
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +18 -0
- data/test/multiverse/suites/rails/rails2_app/db/schema.rb +5 -0
- data/test/multiverse/suites/rails/rails3_app/app_rails3_plus.rb +76 -0
- data/test/multiverse/suites/rails/request_statistics_test.rb +2 -4
- data/test/multiverse/suites/rails/transaction_ignoring_test.rb +3 -5
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +73 -42
- data/test/multiverse/suites/resque/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/Envfile +4 -0
- data/test/multiverse/suites/sidekiq/after_suite.rb +7 -0
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +55 -34
- data/test/multiverse/suites/sidekiq/sidekiq_server.rb +30 -0
- data/test/multiverse/suites/sidekiq/test_worker.rb +60 -0
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -1
- data/test/multiverse/suites/sinatra/ignoring_test.rb +33 -11
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +3 -1
- data/test/multiverse/suites/typhoeus/Envfile +9 -0
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -1
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +10 -0
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +3 -10
- data/test/new_relic/agent/agent_logger_test.rb +24 -6
- data/test/new_relic/agent/agent_test.rb +7 -8
- data/test/new_relic/agent/agent_test_controller.rb +2 -2
- data/test/new_relic/agent/audit_logger_test.rb +5 -1
- data/test/new_relic/agent/busy_calculator_test.rb +1 -1
- data/test/new_relic/agent/configuration/manager_test.rb +68 -69
- data/test/new_relic/agent/cross_app_monitor_test.rb +32 -14
- data/test/new_relic/agent/cross_app_tracing_test.rb +2 -2
- data/test/new_relic/agent/error_collector/notice_error_test.rb +9 -33
- data/test/new_relic/agent/error_collector_test.rb +45 -14
- data/test/new_relic/agent/harvester_test.rb +9 -0
- data/test/new_relic/agent/hostname_test.rb +41 -0
- data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +27 -19
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/active_record_test.rb +3 -3
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +95 -14
- data/test/new_relic/agent/instrumentation/middleware_proxy_test.rb +189 -0
- data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +2 -2
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +18 -1
- data/test/new_relic/agent/instrumentation/rack_test.rb +10 -1
- data/test/new_relic/agent/instrumentation/sinatra_test.rb +3 -1
- data/test/new_relic/agent/javascript_instrumentor_test.rb +28 -41
- data/test/new_relic/agent/memory_logger_test.rb +14 -0
- data/test/new_relic/agent/method_interrobang_test.rb +1 -1
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +1 -30
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +5 -21
- data/test/new_relic/agent/method_tracer_test.rb +5 -4
- data/test/new_relic/agent/mock_scope_listener.rb +2 -2
- data/test/new_relic/agent/obfuscator_test.rb +1 -1
- data/test/new_relic/agent/pipe_channel_manager_test.rb +17 -5
- data/test/new_relic/agent/request_sampler_test.rb +16 -16
- data/test/new_relic/agent/rpm_agent_test.rb +23 -29
- data/test/new_relic/agent/sql_sampler_test.rb +39 -31
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +189 -117
- data/test/new_relic/agent/stats_engine_test.rb +1 -1
- data/test/new_relic/agent/stats_hash_test.rb +28 -1
- data/test/new_relic/agent/stats_test.rb +1 -12
- data/test/new_relic/agent/threading/agent_thread_test.rb +23 -9
- data/test/new_relic/agent/threading/backtrace_service_test.rb +33 -32
- data/test/new_relic/agent/threading/fake_thread.rb +4 -8
- data/test/new_relic/agent/threading/threaded_test_case.rb +4 -14
- data/test/new_relic/agent/traced_method_stack_test.rb +43 -27
- data/test/new_relic/agent/transaction_interrobang_test.rb +1 -1
- data/test/new_relic/agent/transaction_metrics_test.rb +113 -0
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -61
- data/test/new_relic/agent/transaction_sampler_test.rb +176 -228
- data/test/new_relic/agent/transaction_state_test.rb +62 -26
- data/test/new_relic/agent/transaction_test.rb +198 -80
- data/test/new_relic/agent/vm/monotonic_gc_profiler_test.rb +4 -4
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +68 -0
- data/test/new_relic/agent_test.rb +31 -27
- data/test/new_relic/cli/commands/deployments_test.rb +7 -2
- data/test/new_relic/control/instance_methods_test.rb +4 -4
- data/test/new_relic/control_test.rb +28 -22
- data/test/new_relic/dependency_detection_test.rb +14 -0
- data/test/new_relic/fake_external_server.rb +1 -0
- data/test/new_relic/fake_rpm_site.rb +35 -0
- data/test/new_relic/http_client_test_cases.rb +12 -3
- data/test/new_relic/json_wrapper_test.rb +5 -0
- data/test/new_relic/language_support_test.rb +7 -0
- data/test/new_relic/license_test.rb +11 -5
- data/test/new_relic/local_environment_test.rb +0 -18
- data/test/new_relic/metric_data_test.rb +2 -2
- data/test/new_relic/metric_spec_test.rb +4 -23
- data/test/new_relic/multiverse_helpers.rb +1 -3
- data/test/new_relic/noticed_error_test.rb +6 -22
- data/test/new_relic/rack/agent_hooks_test.rb +5 -1
- data/test/new_relic/rack/agent_middleware_test.rb +32 -0
- data/test/new_relic/rack/browser_monitoring_test.rb +14 -1
- data/test/new_relic/rack/developer_mode_helper_test.rb +0 -8
- data/test/new_relic/rack/developer_mode_test.rb +1 -1
- data/test/new_relic/rack/error_collector_test.rb +6 -30
- data/test/new_relic/transaction_sample/fake_segment_test.rb +2 -2
- data/test/new_relic/transaction_sample/segment_test.rb +47 -47
- data/test/new_relic/transaction_sample_test.rb +9 -8
- data/test/performance/lib/performance/instrumentation/stackprof.rb +11 -8
- data/test/performance/script/runner +13 -0
- data/test/performance/suites/config.rb +5 -2
- data/test/performance/suites/rack_middleware.rb +84 -0
- data/test/performance/suites/rum_autoinsertion.rb +1 -1
- data/test/performance/suites/thread_profiling.rb +1 -1
- data/test/test_helper.rb +12 -10
- data/ui/helpers/developer_mode_helper.rb +3 -43
- data/ui/views/layouts/newrelic_default.rhtml +2 -2
- data/ui/views/newrelic/_sample.rhtml +2 -2
- data/ui/views/newrelic/_sql_row.rhtml +11 -11
- data/ui/views/newrelic/index.rhtml +21 -22
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +15 -10
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser.rb +2 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/middleware.rb +34 -0
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/nested.rb +24 -0
- metadata +108 -31
- metadata.gz.sig +0 -0
- data/lib/new_relic/rack/transaction_reset.rb +0 -20
- data/test/multiverse/suites/rails/mongrel_queue_depth_test.rb +0 -42
- data/test/new_relic/rack/transaction_reset_test.rb +0 -35
- data/ui/views/newrelic/show_source.rhtml +0 -3
@@ -3,6 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'logger'
|
6
|
+
require 'new_relic/agent/hostname'
|
6
7
|
|
7
8
|
module NewRelic
|
8
9
|
module Agent
|
@@ -44,7 +45,7 @@ module NewRelic
|
|
44
45
|
end
|
45
46
|
|
46
47
|
def is_startup_logger?
|
47
|
-
|
48
|
+
@log.is_a?(NullLogger)
|
48
49
|
end
|
49
50
|
|
50
51
|
# Use this when you want to log an exception with explicit control over
|
@@ -161,7 +162,7 @@ module NewRelic
|
|
161
162
|
end
|
162
163
|
|
163
164
|
def set_log_format!
|
164
|
-
@hostname =
|
165
|
+
@hostname = NewRelic::Agent::Hostname.get
|
165
166
|
@prefix = wants_stdout? ? '** [NewRelic]' : ''
|
166
167
|
@log.formatter = Proc.new do |severity, timestamp, progname, msg|
|
167
168
|
"#{@prefix}[#{timestamp.strftime("%m/%d/%y %H:%M:%S %z")} #{@hostname} (#{$$})] #{severity} : #{msg}\n"
|
@@ -4,6 +4,7 @@
|
|
4
4
|
|
5
5
|
require 'logger'
|
6
6
|
require 'fileutils'
|
7
|
+
require 'new_relic/agent/hostname'
|
7
8
|
|
8
9
|
module NewRelic
|
9
10
|
module Agent
|
@@ -66,7 +67,7 @@ module NewRelic
|
|
66
67
|
end
|
67
68
|
|
68
69
|
def create_log_formatter
|
69
|
-
@hostname =
|
70
|
+
@hostname = NewRelic::Agent::Hostname.get
|
70
71
|
Proc.new do |severity, time, progname, msg|
|
71
72
|
"[#{time} #{@hostname} (#{$$})] : #{msg}\n"
|
72
73
|
end
|
@@ -24,9 +24,10 @@ module NewRelic
|
|
24
24
|
# sets up busy calculations based on the start and end of
|
25
25
|
# transactions - used for a rough estimate of what percentage of
|
26
26
|
# wall clock time is spent processing requests
|
27
|
-
def dispatcher_start(time)
|
28
|
-
TransactionState.
|
29
|
-
|
27
|
+
def dispatcher_start(time) #THREAD_LOCAL_ACCESS
|
28
|
+
state = TransactionState.tl_get
|
29
|
+
state.busy_entries ||= 0
|
30
|
+
callers = state.busy_entries += 1
|
30
31
|
return if callers > 1
|
31
32
|
@lock.synchronize do
|
32
33
|
@entrypoint_stack.push time
|
@@ -36,12 +37,13 @@ module NewRelic
|
|
36
37
|
# called when a transaction finishes, to add time to the
|
37
38
|
# instance variable accumulator. this is harvested when we send
|
38
39
|
# data to the server
|
39
|
-
def dispatcher_finish(end_time = nil)
|
40
|
+
def dispatcher_finish(end_time = nil) #THREAD_LOCAL_ACCESS
|
41
|
+
state = TransactionState.tl_get
|
40
42
|
# If #dispatcher_start hasn't been called at least once, abort early
|
41
|
-
return unless
|
43
|
+
return unless state.busy_entries
|
42
44
|
|
43
45
|
end_time ||= time_now
|
44
|
-
callers =
|
46
|
+
callers = state.busy_entries -= 1
|
45
47
|
|
46
48
|
# Ignore nested calls
|
47
49
|
return if callers > 0
|
@@ -63,9 +65,9 @@ module NewRelic
|
|
63
65
|
|
64
66
|
# Reset the state of the information accumulated by all threads,
|
65
67
|
# but only reset the recursion counter for this thread.
|
66
|
-
def reset
|
68
|
+
def reset #THREAD_LOCAL_ACCESS
|
67
69
|
@entrypoint_stack = []
|
68
|
-
TransactionState.
|
70
|
+
TransactionState.tl_get.busy_entries = 0
|
69
71
|
@lock ||= Mutex.new
|
70
72
|
@accumulator = 0
|
71
73
|
@harvest_start = time_now
|
@@ -28,19 +28,6 @@ require 'new_relic/agent/configuration/manager'
|
|
28
28
|
module NewRelic
|
29
29
|
module Agent
|
30
30
|
module Configuration
|
31
|
-
# This can be mixed in with minimal impact to provide easy
|
32
|
-
# access to the config manager
|
33
|
-
module Instance
|
34
|
-
def config
|
35
|
-
@@manager ||= Manager.new
|
36
|
-
end
|
37
|
-
|
38
|
-
# for testing
|
39
|
-
def reset_config
|
40
|
-
@@manager = Manager.new
|
41
|
-
end
|
42
|
-
end
|
43
|
-
|
44
31
|
class DottedHash < ::Hash
|
45
32
|
def initialize(hash)
|
46
33
|
self.merge!(dot_flattened(hash))
|
@@ -55,7 +55,7 @@ module NewRelic
|
|
55
55
|
case
|
56
56
|
when defined?(::NewRelic::TEST) then :test
|
57
57
|
when defined?(::Merb) && defined?(::Merb::Plugins) then :merb
|
58
|
-
when defined?(::Rails)
|
58
|
+
when defined?(::Rails::VERSION)
|
59
59
|
case Rails::VERSION::MAJOR
|
60
60
|
when 0..2
|
61
61
|
:rails
|
@@ -313,12 +313,6 @@ module NewRelic
|
|
313
313
|
:type => Boolean,
|
314
314
|
:description => 'Determines if ruby-prof is available for developer mode profiling.'
|
315
315
|
},
|
316
|
-
:'profiling.enabled' => {
|
317
|
-
:default => false,
|
318
|
-
:public => false,
|
319
|
-
:type => Boolean,
|
320
|
-
:description => 'Determines at runtime whether developer mode should be profiling or not.'
|
321
|
-
},
|
322
316
|
:apdex_t => {
|
323
317
|
:default => 0.5,
|
324
318
|
:public => true,
|
@@ -576,6 +570,12 @@ module NewRelic
|
|
576
570
|
:type => Boolean,
|
577
571
|
:description => 'Enable or disable memcache instrumentation.'
|
578
572
|
},
|
573
|
+
:disable_gc_profiler => {
|
574
|
+
:default => false,
|
575
|
+
:public => true,
|
576
|
+
:type => Boolean,
|
577
|
+
:description => 'Enable or disable usage of GC::Profiler to measure time spent in garbage collection'
|
578
|
+
},
|
579
579
|
:capture_params => {
|
580
580
|
:default => false,
|
581
581
|
:public => true,
|
@@ -600,12 +600,6 @@ module NewRelic
|
|
600
600
|
:type => Boolean,
|
601
601
|
:description => 'Enable or disable capturing and attachment of memcache keys to transaction traces.'
|
602
602
|
},
|
603
|
-
:textmate => {
|
604
|
-
:default => false,
|
605
|
-
:public => false,
|
606
|
-
:type => Boolean,
|
607
|
-
:description => 'Enables Textmate integration.'
|
608
|
-
},
|
609
603
|
:'transaction_tracer.enabled' => {
|
610
604
|
:default => true,
|
611
605
|
:public => true,
|
@@ -714,12 +708,6 @@ module NewRelic
|
|
714
708
|
:type => Boolean,
|
715
709
|
:description => 'Enable or disable recording of traced errors and error count metrics.'
|
716
710
|
},
|
717
|
-
:'error_collector.capture_source' => {
|
718
|
-
:default => true,
|
719
|
-
:public => true,
|
720
|
-
:type => Boolean,
|
721
|
-
:description => 'Enable or disable collection of source code for errors that support it.'
|
722
|
-
},
|
723
711
|
:'error_collector.capture_attributes' => {
|
724
712
|
:default => true,
|
725
713
|
:public => true,
|
@@ -801,7 +789,7 @@ module NewRelic
|
|
801
789
|
},
|
802
790
|
:'browser_monitoring.capture_attributes' => {
|
803
791
|
:default => false,
|
804
|
-
:public =>
|
792
|
+
:public => true,
|
805
793
|
:type => Boolean,
|
806
794
|
:description => 'Include custom attributes in real user monitoring script in outgoing responses.'
|
807
795
|
},
|
@@ -982,6 +970,13 @@ module NewRelic
|
|
982
970
|
:dynamic_name => true,
|
983
971
|
:description => 'Controls whether instrumentation for the httpclient gem will be installed by the agent.'
|
984
972
|
},
|
973
|
+
:disable_net_http => {
|
974
|
+
:default => false,
|
975
|
+
:public => true,
|
976
|
+
:type => Boolean,
|
977
|
+
:dynamic_name => true,
|
978
|
+
:description => 'Controls whether instrumentation for Net::HTTP will be installed by the agent.'
|
979
|
+
},
|
985
980
|
:disable_mongo => {
|
986
981
|
:default => false,
|
987
982
|
:public => true,
|
@@ -1009,6 +1004,18 @@ module NewRelic
|
|
1009
1004
|
:type => Boolean,
|
1010
1005
|
:dynamic_name => true,
|
1011
1006
|
:description => 'Controls whether instrumentation for the typhoeus gem will be installed by the agent.'
|
1007
|
+
},
|
1008
|
+
:disable_middleware_instrumentation => {
|
1009
|
+
:default => false,
|
1010
|
+
:public => true,
|
1011
|
+
:type => Boolean,
|
1012
|
+
:description => 'Controls whether 3rd-party middlewares will be wrapped in instrumentation (regardless of whether they are installed via Rack::Builder or Rails).'
|
1013
|
+
},
|
1014
|
+
:use_heroku_dyno_names => {
|
1015
|
+
:default => false,
|
1016
|
+
:public => false,
|
1017
|
+
:type => Boolean,
|
1018
|
+
:description => 'Controls whether or not we use the heroku dyno name as the hostname.'
|
1012
1019
|
}
|
1013
1020
|
}.freeze
|
1014
1021
|
|
@@ -13,9 +13,21 @@ module NewRelic
|
|
13
13
|
module Agent
|
14
14
|
module Configuration
|
15
15
|
class Manager
|
16
|
-
|
17
|
-
|
18
|
-
|
16
|
+
attr_reader :stripped_exceptions_whitelist
|
17
|
+
|
18
|
+
# Defining these explicitly saves object allocations that we incur
|
19
|
+
# if we use Forwardable and def_delegators.
|
20
|
+
def [](key)
|
21
|
+
@cache[key]
|
22
|
+
end
|
23
|
+
|
24
|
+
def has_key?(key)
|
25
|
+
@cache.has_key?[key]
|
26
|
+
end
|
27
|
+
|
28
|
+
def keys
|
29
|
+
@cache.keys
|
30
|
+
end
|
19
31
|
|
20
32
|
def initialize
|
21
33
|
reset_to_defaults
|
@@ -30,24 +42,35 @@ module NewRelic
|
|
30
42
|
end
|
31
43
|
end
|
32
44
|
|
33
|
-
def
|
34
|
-
|
35
|
-
|
45
|
+
def add_config_for_testing(source, level=0)
|
46
|
+
raise 'Invalid config type for testing' unless [Hash, DottedHash].include?(source.class)
|
36
47
|
invoke_callbacks(:add, source)
|
37
|
-
@
|
48
|
+
@configs_for_testing << [source.freeze, level]
|
38
49
|
reset_cache
|
39
50
|
log_config(:add, source)
|
51
|
+
end
|
40
52
|
|
41
|
-
|
53
|
+
def remove_config_type(sym)
|
54
|
+
source = case sym
|
55
|
+
when :environment then @environment_source
|
56
|
+
when :server then @server_source
|
57
|
+
when :manual then @manual_source
|
58
|
+
when :yaml then @yaml_source
|
59
|
+
when :default then @default_source
|
60
|
+
end
|
61
|
+
|
62
|
+
remove_config(source)
|
42
63
|
end
|
43
64
|
|
44
|
-
def remove_config(source
|
45
|
-
|
46
|
-
|
47
|
-
|
48
|
-
|
49
|
-
|
50
|
-
|
65
|
+
def remove_config(source)
|
66
|
+
case source
|
67
|
+
when EnvironmentSource then @environment_source = nil
|
68
|
+
when ServerSource then @server_source = nil
|
69
|
+
when ManualSource then @manual_source = nil
|
70
|
+
when YamlSource then @yaml_source = nil
|
71
|
+
when DefaultSource then @default_source = nil
|
72
|
+
else
|
73
|
+
@configs_for_testing.delete_if {|src,lvl| src == source}
|
51
74
|
end
|
52
75
|
|
53
76
|
reset_cache
|
@@ -55,18 +78,29 @@ module NewRelic
|
|
55
78
|
log_config(:remove, source)
|
56
79
|
end
|
57
80
|
|
58
|
-
def replace_or_add_config(source
|
59
|
-
|
60
|
-
|
61
|
-
|
62
|
-
|
81
|
+
def replace_or_add_config(source)
|
82
|
+
source.freeze
|
83
|
+
was_finished = finished_configuring?
|
84
|
+
|
85
|
+
invoke_callbacks(:add, source)
|
86
|
+
case source
|
87
|
+
when EnvironmentSource then @environment_source = source
|
88
|
+
when ServerSource then @server_source = source
|
89
|
+
when ManualSource then @manual_source = source
|
90
|
+
when YamlSource then @yaml_source = source
|
91
|
+
when DefaultSource then @default_source = source
|
92
|
+
else
|
93
|
+
NewRelic::Agent.logger.warn("Invalid config format; config will be ignored: #{source}")
|
94
|
+
end
|
63
95
|
|
64
|
-
|
65
|
-
|
96
|
+
reset_cache
|
97
|
+
log_config(:add, source)
|
98
|
+
|
99
|
+
notify_finished_configuring if !was_finished && finished_configuring?
|
66
100
|
end
|
67
101
|
|
68
102
|
def source(key)
|
69
|
-
|
103
|
+
config_stack.each do |config|
|
70
104
|
if config.respond_to?(key.to_sym) || config.has_key?(key.to_sym)
|
71
105
|
return config
|
72
106
|
end
|
@@ -74,7 +108,7 @@ module NewRelic
|
|
74
108
|
end
|
75
109
|
|
76
110
|
def fetch(key)
|
77
|
-
|
111
|
+
config_stack.each do |config|
|
78
112
|
next unless config
|
79
113
|
accessor = key.to_sym
|
80
114
|
if config.has_key?(accessor)
|
@@ -113,11 +147,11 @@ module NewRelic
|
|
113
147
|
end
|
114
148
|
|
115
149
|
def finished_configuring?
|
116
|
-
|
150
|
+
!@server_source.nil?
|
117
151
|
end
|
118
152
|
|
119
153
|
def flattened
|
120
|
-
|
154
|
+
config_stack.reverse.inject({}) do |flat,layer|
|
121
155
|
thawed_layer = layer.to_hash.dup
|
122
156
|
thawed_layer.each do |k,v|
|
123
157
|
begin
|
@@ -153,7 +187,14 @@ module NewRelic
|
|
153
187
|
|
154
188
|
# Generally only useful during initial construction and tests
|
155
189
|
def reset_to_defaults
|
156
|
-
@
|
190
|
+
@environment_source = EnvironmentSource.new
|
191
|
+
@server_source = nil
|
192
|
+
@manual_source = nil
|
193
|
+
@yaml_source = nil
|
194
|
+
@default_source = DefaultSource.new
|
195
|
+
|
196
|
+
@configs_for_testing = []
|
197
|
+
|
157
198
|
reset_cache
|
158
199
|
end
|
159
200
|
|
@@ -171,8 +212,41 @@ module NewRelic
|
|
171
212
|
end
|
172
213
|
end
|
173
214
|
|
215
|
+
def delete_all_configs_for_testing
|
216
|
+
@environment_source = nil
|
217
|
+
@server_source = nil
|
218
|
+
@manual_source = nil
|
219
|
+
@yaml_source = nil
|
220
|
+
@default_source = nil
|
221
|
+
@configs_for_testing = []
|
222
|
+
end
|
223
|
+
|
224
|
+
def num_configs_for_testing
|
225
|
+
config_stack.size
|
226
|
+
end
|
227
|
+
|
228
|
+
def config_classes_for_testing
|
229
|
+
config_stack.map(&:class)
|
230
|
+
end
|
231
|
+
|
174
232
|
private
|
175
233
|
|
234
|
+
def config_stack
|
235
|
+
stack = [@environment_source,
|
236
|
+
@server_source,
|
237
|
+
@manual_source,
|
238
|
+
@yaml_source,
|
239
|
+
@default_source]
|
240
|
+
|
241
|
+
stack.compact!
|
242
|
+
|
243
|
+
@configs_for_testing.each do |config, index|
|
244
|
+
stack.insert(index, config)
|
245
|
+
end
|
246
|
+
|
247
|
+
stack
|
248
|
+
end
|
249
|
+
|
176
250
|
def parse_constant_list(list)
|
177
251
|
list.split(/\s*,\s*/).map do |class_name|
|
178
252
|
const = constantize(class_name)
|
@@ -2,7 +2,6 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
-
require 'new_relic/rack/agent_hooks'
|
6
5
|
require 'new_relic/agent/transaction_state'
|
7
6
|
require 'new_relic/agent/threading/agent_thread'
|
8
7
|
|
@@ -48,23 +47,26 @@ module NewRelic
|
|
48
47
|
debug("Wiring up Cross Application Tracing to events after finished configuring")
|
49
48
|
|
50
49
|
events = Agent.instance.events
|
51
|
-
events.subscribe(:before_call) do |env|
|
50
|
+
events.subscribe(:before_call) do |env| #THREAD_LOCAL_ACCESS
|
52
51
|
if should_process_request(env)
|
53
|
-
|
54
|
-
|
52
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
53
|
+
|
54
|
+
save_client_cross_app_id(state, env)
|
55
|
+
save_referring_transaction_info(state, env)
|
56
|
+
set_transaction_custom_parameters(state)
|
55
57
|
end
|
56
58
|
end
|
57
59
|
|
58
|
-
events.subscribe(:
|
59
|
-
|
60
|
-
end
|
60
|
+
events.subscribe(:after_call) do |env, (status_code, headers, body)| #THREAD_LOCAL_ACCESS
|
61
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
61
62
|
|
62
|
-
|
63
|
-
insert_response_header(env, headers)
|
63
|
+
insert_response_header(state, env, headers)
|
64
64
|
end
|
65
65
|
|
66
|
-
events.subscribe(:notice_error) do |_, options|
|
67
|
-
|
66
|
+
events.subscribe(:notice_error) do |_, options| #THREAD_LOCAL_ACCESS
|
67
|
+
state = NewRelic::Agent::TransactionState.tl_get
|
68
|
+
|
69
|
+
set_error_custom_parameters(state, options)
|
68
70
|
end
|
69
71
|
end
|
70
72
|
|
@@ -73,50 +75,46 @@ module NewRelic
|
|
73
75
|
@obfuscator = NewRelic::Agent::Obfuscator.new(NewRelic::Agent.config[:encoding_key])
|
74
76
|
end
|
75
77
|
|
76
|
-
def save_client_cross_app_id(request_headers)
|
77
|
-
|
78
|
+
def save_client_cross_app_id(state, request_headers)
|
79
|
+
state.client_cross_app_id = decoded_id(request_headers)
|
78
80
|
end
|
79
81
|
|
80
|
-
def clear_client_cross_app_id
|
81
|
-
|
82
|
+
def clear_client_cross_app_id(state)
|
83
|
+
state.client_cross_app_id = nil
|
82
84
|
end
|
83
85
|
|
84
|
-
def
|
85
|
-
|
86
|
-
|
86
|
+
def save_referring_transaction_info(state, request_headers)
|
87
|
+
txn_header = from_headers(request_headers, NEWRELIC_TXN_HEADER_KEYS) or return
|
88
|
+
txn_header = obfuscator.deobfuscate(txn_header)
|
89
|
+
txn_info = NewRelic::JSONWrapper.load(txn_header)
|
90
|
+
NewRelic::Agent.logger.debug("Referring txn_info: %p" % [txn_info])
|
87
91
|
|
88
|
-
|
89
|
-
txn_header = from_headers( request_headers, NEWRELIC_TXN_HEADER_KEYS ) or return
|
90
|
-
txn_header = obfuscator.deobfuscate( txn_header )
|
91
|
-
txn_info = NewRelic::JSONWrapper.load( txn_header )
|
92
|
-
NewRelic::Agent.logger.debug "Referring txn_info: %p" % [ txn_info ]
|
93
|
-
|
94
|
-
TransactionState.get.referring_transaction_info = txn_info
|
92
|
+
state.referring_transaction_info = txn_info
|
95
93
|
end
|
96
94
|
|
97
|
-
def client_referring_transaction_guid
|
98
|
-
info =
|
95
|
+
def client_referring_transaction_guid(state)
|
96
|
+
info = state.referring_transaction_info or return nil
|
99
97
|
return info[0]
|
100
98
|
end
|
101
99
|
|
102
|
-
def client_referring_transaction_record_flag
|
103
|
-
info =
|
100
|
+
def client_referring_transaction_record_flag(state)
|
101
|
+
info = state.referring_transaction_info or return nil
|
104
102
|
return info[1]
|
105
103
|
end
|
106
104
|
|
107
|
-
def insert_response_header(request_headers, response_headers)
|
108
|
-
unless client_cross_app_id.nil?
|
109
|
-
txn =
|
105
|
+
def insert_response_header(state, request_headers, response_headers)
|
106
|
+
unless state.client_cross_app_id.nil?
|
107
|
+
txn = state.current_transaction
|
110
108
|
unless txn.nil?
|
111
109
|
txn.freeze_name_and_execute_if_not_ignored do
|
112
|
-
timings =
|
110
|
+
timings = state.timings
|
113
111
|
content_length = content_length_from_request(request_headers)
|
114
112
|
|
115
|
-
set_response_headers(response_headers, timings, content_length)
|
116
|
-
set_metrics(client_cross_app_id, timings)
|
113
|
+
set_response_headers(state, response_headers, timings, content_length)
|
114
|
+
set_metrics(state.client_cross_app_id, timings)
|
117
115
|
end
|
118
116
|
end
|
119
|
-
clear_client_cross_app_id
|
117
|
+
clear_client_cross_app_id(state)
|
120
118
|
end
|
121
119
|
end
|
122
120
|
|
@@ -137,37 +135,36 @@ module NewRelic
|
|
137
135
|
NewRelic::Agent.config[:trusted_account_ids].include?(split_id.captures.first.to_i)
|
138
136
|
end
|
139
137
|
|
140
|
-
def set_response_headers(response_headers, timings, content_length)
|
141
|
-
response_headers[NEWRELIC_APPDATA_HEADER] = build_payload(timings, content_length)
|
138
|
+
def set_response_headers(state, response_headers, timings, content_length)
|
139
|
+
response_headers[NEWRELIC_APPDATA_HEADER] = build_payload(state, timings, content_length)
|
142
140
|
end
|
143
141
|
|
144
|
-
def build_payload(timings, content_length)
|
142
|
+
def build_payload(state, timings, content_length)
|
145
143
|
payload = [
|
146
144
|
NewRelic::Agent.config[:cross_process_id],
|
147
145
|
timings.transaction_name,
|
148
146
|
timings.queue_time_in_seconds.to_f,
|
149
147
|
timings.app_time_in_seconds.to_f,
|
150
148
|
content_length,
|
151
|
-
|
149
|
+
state.request_guid
|
152
150
|
]
|
153
151
|
payload = obfuscator.obfuscate(NewRelic::JSONWrapper.dump(payload))
|
154
152
|
end
|
155
153
|
|
156
|
-
def set_transaction_custom_parameters
|
154
|
+
def set_transaction_custom_parameters(state)
|
157
155
|
# We expect to get the before call to set the id (if we have it) before
|
158
156
|
# this, and then write our custom parameter when the transaction starts
|
159
|
-
NewRelic::Agent.add_custom_parameters(:client_cross_process_id => client_cross_app_id
|
157
|
+
NewRelic::Agent.add_custom_parameters(:client_cross_process_id => state.client_cross_app_id) if state.client_cross_app_id
|
160
158
|
|
161
|
-
referring_guid = client_referring_transaction_guid()
|
159
|
+
referring_guid = client_referring_transaction_guid(state)
|
162
160
|
if referring_guid
|
163
161
|
NewRelic::Agent.logger.debug "Referring transaction guid: %p" % [referring_guid]
|
164
162
|
NewRelic::Agent.add_custom_parameters(:referring_transaction_guid => referring_guid)
|
165
163
|
end
|
166
164
|
end
|
167
165
|
|
168
|
-
def set_error_custom_parameters(options)
|
169
|
-
options[:client_cross_process_id] = client_cross_app_id
|
170
|
-
# [MG] TODO: Should the CAT metrics be set here too?
|
166
|
+
def set_error_custom_parameters(state, options)
|
167
|
+
options[:client_cross_process_id] = state.client_cross_app_id if state.client_cross_app_id
|
171
168
|
end
|
172
169
|
|
173
170
|
def set_metrics(id, timings)
|
@@ -186,10 +183,6 @@ module NewRelic
|
|
186
183
|
from_headers(request, CONTENT_LENGTH_HEADER_KEYS) || -1
|
187
184
|
end
|
188
185
|
|
189
|
-
def transaction_guid
|
190
|
-
NewRelic::Agent::TransactionState.get.request_guid
|
191
|
-
end
|
192
|
-
|
193
186
|
private
|
194
187
|
|
195
188
|
def from_headers(request, try_keys)
|