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
@@ -97,14 +97,7 @@ module NewRelic
|
|
97
97
|
begin
|
98
98
|
require 'new_relic/rack/developer_mode'
|
99
99
|
rails_config.middleware.use NewRelic::Rack::DeveloperMode
|
100
|
-
|
101
|
-
# inform user that the dev edition is available if we are running inside
|
102
|
-
# a webserver process
|
103
|
-
if @local_env.dispatcher_instance_id
|
104
|
-
port = @local_env.dispatcher_instance_id.to_s =~ /^\d+/ ? ":#{local_env.dispatcher_instance_id}" : ":port"
|
105
|
-
::NewRelic::Agent.logger.debug("NewRelic Agent Developer Mode enabled.")
|
106
|
-
::NewRelic::Agent.logger.debug("To view performance information, go to http://localhost#{port}/newrelic")
|
107
|
-
end
|
100
|
+
::NewRelic::Agent.logger.info("New Relic Agent Developer Mode enabled.")
|
108
101
|
rescue => e
|
109
102
|
::NewRelic::Agent.logger.warn("Error installing New Relic Developer Mode", e)
|
110
103
|
end
|
@@ -64,14 +64,13 @@ module NewRelic
|
|
64
64
|
|
65
65
|
# Merge the stringified options into the config as overrides:
|
66
66
|
environment_name = options.delete(:env) and self.env = environment_name
|
67
|
-
dispatcher_instance_id = options.delete(:dispatcher_instance_id) and @local_env.dispatcher_instance_id = dispatcher_instance_id
|
68
67
|
|
69
68
|
NewRelic::Agent::PipeChannelManager.listener.start if options.delete(:start_channel_listener)
|
70
69
|
|
71
70
|
# An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
|
72
71
|
# methods in the module methods.
|
73
72
|
Module.send :include, NewRelic::Agent::MethodTracer::ClassMethods
|
74
|
-
Module.send :include, NewRelic::Agent::MethodTracer
|
73
|
+
Module.send :include, NewRelic::Agent::MethodTracer
|
75
74
|
init_config(options)
|
76
75
|
NewRelic::Agent.agent = NewRelic::Agent::Agent.instance
|
77
76
|
if Agent.config[:agent_enabled] && !NewRelic::Agent.instance.started?
|
data/lib/new_relic/helper.rb
CHANGED
@@ -32,6 +32,15 @@ module NewRelic
|
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
+
def instance_methods_include?(klass, method_name)
|
36
|
+
method_name_sym = method_name.to_sym
|
37
|
+
(
|
38
|
+
klass.instance_methods.map{ |s| s.to_sym }.include?(method_name_sym) ||
|
39
|
+
klass.protected_instance_methods.map{ |s|s.to_sym }.include?(method_name_sym) ||
|
40
|
+
klass.private_instance_methods.map{ |s|s.to_sym }.include?(method_name_sym)
|
41
|
+
)
|
42
|
+
end
|
43
|
+
|
35
44
|
def time_to_millis(time)
|
36
45
|
(time.to_f * 1000).round
|
37
46
|
end
|
@@ -6,26 +6,21 @@ require 'set'
|
|
6
6
|
require 'new_relic/version'
|
7
7
|
|
8
8
|
module NewRelic
|
9
|
-
# An instance of LocalEnvironment is responsible for determining
|
10
|
-
#
|
9
|
+
# An instance of LocalEnvironment is responsible for determining the 'dispatcher'
|
10
|
+
# in use by the current process.
|
11
11
|
#
|
12
|
-
#
|
13
|
-
#
|
12
|
+
# A dispatcher might be a recognized web server such as unicorn or passenger,
|
13
|
+
# a background job processor such as resque or sidekiq, or nil for unknown.
|
14
14
|
#
|
15
|
-
# If the environment can't be determined, it will be set to
|
16
|
-
# nil and dispatcher_instance_id will have nil.
|
15
|
+
# If the environment can't be determined, it will be set to nil.
|
17
16
|
#
|
18
17
|
# NewRelic::LocalEnvironment should be accessed through NewRelic::Control#env (via the NewRelic::Control singleton).
|
19
18
|
class LocalEnvironment
|
20
|
-
# mongrel, thin, webrick, or possibly nil
|
21
19
|
def discovered_dispatcher
|
22
20
|
discover_dispatcher unless @discovered_dispatcher
|
23
21
|
@discovered_dispatcher
|
24
22
|
end
|
25
23
|
|
26
|
-
# used to distinguish instances of a dispatcher from each other, may be nil
|
27
|
-
attr_writer :dispatcher_instance_id
|
28
|
-
|
29
24
|
def initialize
|
30
25
|
# Extend self with any any submodules of LocalEnvironment. These can override
|
31
26
|
# the discover methods to discover new framworks and dispatchers.
|
@@ -37,18 +32,6 @@ module NewRelic
|
|
37
32
|
discover_dispatcher
|
38
33
|
end
|
39
34
|
|
40
|
-
|
41
|
-
# An instance id pulled from either @dispatcher_instance_id or by
|
42
|
-
# splitting out the first part of the running file
|
43
|
-
def dispatcher_instance_id
|
44
|
-
if @dispatcher_instance_id.nil?
|
45
|
-
if @discovered_dispatcher.nil?
|
46
|
-
@dispatcher_instance_id = File.basename($0).split(".").first
|
47
|
-
end
|
48
|
-
end
|
49
|
-
@dispatcher_instance_id
|
50
|
-
end
|
51
|
-
|
52
35
|
# Runs through all the objects in ObjectSpace to find the first one that
|
53
36
|
# match the provided class
|
54
37
|
def find_class_in_object_space(klass)
|
@@ -70,6 +53,12 @@ module NewRelic
|
|
70
53
|
@mongrel
|
71
54
|
end
|
72
55
|
|
56
|
+
# Setter for testing
|
57
|
+
def mongrel=(m)
|
58
|
+
@looked_for_mongrel = true
|
59
|
+
@mongrel = m
|
60
|
+
end
|
61
|
+
|
73
62
|
private
|
74
63
|
|
75
64
|
# Although you can override the dispatcher with NEWRELIC_DISPATCHER this
|
@@ -107,11 +96,6 @@ module NewRelic
|
|
107
96
|
def check_for_webrick
|
108
97
|
return unless defined?(::WEBrick) && defined?(::WEBrick::VERSION)
|
109
98
|
@discovered_dispatcher = :webrick
|
110
|
-
if defined?(::OPTIONS) && OPTIONS.respond_to?(:fetch)
|
111
|
-
# OPTIONS is set by script/server
|
112
|
-
@dispatcher_instance_id = OPTIONS.fetch(:port)
|
113
|
-
end
|
114
|
-
@dispatcher_instance_id = default_port unless @dispatcher_instance_id
|
115
99
|
end
|
116
100
|
|
117
101
|
def check_for_fastcgi
|
@@ -126,19 +110,8 @@ module NewRelic
|
|
126
110
|
|
127
111
|
# Get the port from the server if it's started
|
128
112
|
if mongrel && mongrel.respond_to?(:port)
|
129
|
-
@dispatcher_instance_id = mongrel.port.to_s
|
130
113
|
end
|
131
114
|
|
132
|
-
# Get the port from the configurator if one was created
|
133
|
-
if NewRelic::LanguageSupport.object_space_enabled? && @dispatcher_instance_id.nil? && defined?(::Mongrel::Configurator)
|
134
|
-
ObjectSpace.each_object(Mongrel::Configurator) do |mongrel|
|
135
|
-
@dispatcher_instance_id = mongrel.defaults[:port] && mongrel.defaults[:port].to_s
|
136
|
-
end
|
137
|
-
end
|
138
|
-
|
139
|
-
# Still can't find the port. Let's look at ARGV to fall back
|
140
|
-
@dispatcher_instance_id = default_port if @dispatcher_instance_id.nil?
|
141
|
-
|
142
115
|
# Might not have server yet, so allow one more check later on first request
|
143
116
|
@looked_for_mongrel = false
|
144
117
|
end
|
@@ -168,7 +141,11 @@ module NewRelic
|
|
168
141
|
defined?(::Resque) &&
|
169
142
|
(ENV['QUEUE'] || ENV['QUEUES']) &&
|
170
143
|
(File.basename($0) == 'rake' && ARGV.include?('resque:work'))
|
144
|
+
) || (
|
145
|
+
defined?(::Resque::Pool) &&
|
146
|
+
(File.basename($0) == 'resque-pool')
|
171
147
|
)
|
148
|
+
|
172
149
|
@discovered_dispatcher = :resque if using_resque
|
173
150
|
end
|
174
151
|
|
@@ -184,21 +161,10 @@ module NewRelic
|
|
184
161
|
# Same issue as above- we assume only one instance per process
|
185
162
|
ObjectSpace.each_object(Thin::Server) do |thin_dispatcher|
|
186
163
|
@discovered_dispatcher = :thin
|
187
|
-
|
188
|
-
# We need a way to uniquely identify and distinguish agents. The port
|
189
|
-
# works for this. When using sockets, use the socket file name.
|
190
|
-
if backend.respond_to? :port
|
191
|
-
@dispatcher_instance_id = backend.port
|
192
|
-
elsif backend.respond_to? :socket
|
193
|
-
@dispatcher_instance_id = backend.socket
|
194
|
-
else
|
195
|
-
raise "Unknown thin backend: #{backend}"
|
196
|
-
end
|
197
|
-
end # each thin instance
|
164
|
+
end
|
198
165
|
end
|
199
166
|
if defined?(::Thin) && defined?(::Thin::VERSION) && !@discovered_dispatcher
|
200
167
|
@discovered_dispatcher = :thin
|
201
|
-
@dispatcher_instance_id = default_port
|
202
168
|
end
|
203
169
|
end
|
204
170
|
|
@@ -214,24 +180,11 @@ module NewRelic
|
|
214
180
|
end
|
215
181
|
end
|
216
182
|
|
217
|
-
|
218
|
-
def default_port
|
219
|
-
require 'optparse'
|
220
|
-
# If nothing else is found, use the 3000 default
|
221
|
-
default_port = 3000
|
222
|
-
OptionParser.new do |opts|
|
223
|
-
opts.on("-p", "--port=port", String) { | p | default_port = p }
|
224
|
-
opts.parse(ARGV.clone) rescue nil
|
225
|
-
end
|
226
|
-
default_port
|
227
|
-
end
|
228
|
-
|
229
183
|
public
|
230
184
|
# outputs a human-readable description
|
231
185
|
def to_s
|
232
186
|
s = "LocalEnvironment["
|
233
187
|
s << ";dispatcher=#{@discovered_dispatcher}" if @discovered_dispatcher
|
234
|
-
s << ";instance=#{@dispatcher_instance_id}" if @dispatcher_instance_id
|
235
188
|
s << "]"
|
236
189
|
end
|
237
190
|
|
@@ -39,6 +39,8 @@ module NewRelic::Rack
|
|
39
39
|
!headers['Content-Disposition'].to_s.include?('attachment')
|
40
40
|
end
|
41
41
|
|
42
|
+
X_UA_COMPATIBLE_RE = /<\s*meta[^>]+http-equiv=['"]x-ua-compatible['"][^>]*>/im.freeze
|
43
|
+
|
42
44
|
def autoinstrument_source(response, headers)
|
43
45
|
source = nil
|
44
46
|
response.each {|fragment| source ? (source << fragment.to_s) : (source = fragment.to_s)}
|
@@ -53,12 +55,13 @@ module NewRelic::Rack
|
|
53
55
|
footer = NewRelic::Agent.browser_timing_footer
|
54
56
|
header = NewRelic::Agent.browser_timing_header
|
55
57
|
|
56
|
-
|
58
|
+
match = X_UA_COMPATIBLE_RE.match(beginning_of_source)
|
59
|
+
x_ua_compatible_position = match.end(0) if match
|
57
60
|
|
58
|
-
head_pos = if
|
59
|
-
# put
|
60
|
-
::NewRelic::Agent.logger.debug "Detected X-UA-Compatible meta tag. Attempting to insert RUM header
|
61
|
-
|
61
|
+
head_pos = if x_ua_compatible_position
|
62
|
+
# put after X-UA-Compatible meta tag if found
|
63
|
+
::NewRelic::Agent.logger.debug "Detected X-UA-Compatible meta tag. Attempting to insert RUM header after meta tag."
|
64
|
+
x_ua_compatible_position
|
62
65
|
elsif head_open = beginning_of_source.index("<head")
|
63
66
|
::NewRelic::Agent.logger.debug "Attempting to insert RUM header at beginning of head."
|
64
67
|
# put at the beginning of the header
|
data/lib/new_relic/recipes.rb
CHANGED
@@ -21,37 +21,20 @@ make_notify_task = Proc.new do
|
|
21
21
|
task :notice_deployment, :roles => :app, :except => {:no_release => true } do
|
22
22
|
rails_env = fetch(:newrelic_rails_env, fetch(:rails_env, "production"))
|
23
23
|
|
24
|
-
require File.join(File.dirname(__FILE__), 'command.rb')
|
24
|
+
require File.join(File.dirname(__FILE__), 'cli', 'command.rb')
|
25
25
|
|
26
26
|
begin
|
27
27
|
# allow overrides to be defined for revision, description, changelog, appname, and user
|
28
|
-
rev = fetch(:newrelic_revision)
|
29
|
-
description = fetch(:newrelic_desc)
|
30
|
-
changelog = fetch(:newrelic_changelog)
|
31
|
-
appname = fetch(:newrelic_appname)
|
32
|
-
user = fetch(:newrelic_user)
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
if scm == :git
|
39
|
-
log_command = "git log --no-color --pretty=format:' * %an: %s' " +
|
40
|
-
"--abbrev-commit --no-merges #{previous_revision}..#{real_revision}"
|
41
|
-
else
|
42
|
-
log_command = "#{source.log(from_revision)}"
|
43
|
-
end
|
44
|
-
|
45
|
-
changelog = `#{log_command}`
|
46
|
-
end
|
47
|
-
|
48
|
-
if rev.nil?
|
49
|
-
rev = source.query_revision(source.head()) do |cmd|
|
50
|
-
logger.debug "executing locally: '#{cmd}'"
|
51
|
-
`#{cmd}`
|
52
|
-
end
|
53
|
-
|
54
|
-
rev = rev[0..6] if scm == :git
|
28
|
+
rev = fetch(:newrelic_revision) if exists?(:newrelic_revision)
|
29
|
+
description = fetch(:newrelic_desc) if exists?(:newrelic_desc)
|
30
|
+
changelog = fetch(:newrelic_changelog) if exists?(:newrelic_changelog)
|
31
|
+
appname = fetch(:newrelic_appname) if exists?(:newrelic_appname)
|
32
|
+
user = fetch(:newrelic_user) if exists?(:newrelic_user)
|
33
|
+
license_key = fetch(:newrelic_license_key) if exists?(:newrelic_license_key)
|
34
|
+
|
35
|
+
unless scm == :none
|
36
|
+
changelog = lookup_changelog(changelog)
|
37
|
+
rev = lookup_rev(rev)
|
55
38
|
end
|
56
39
|
|
57
40
|
new_revision = rev
|
@@ -61,15 +44,16 @@ make_notify_task = Proc.new do
|
|
61
44
|
:changelog => changelog,
|
62
45
|
:description => description,
|
63
46
|
:appname => appname,
|
64
|
-
:user => user
|
47
|
+
:user => user,
|
48
|
+
:license_key => license_key
|
65
49
|
}
|
66
50
|
|
67
51
|
logger.debug "Uploading deployment to New Relic"
|
68
|
-
deployment = NewRelic::
|
52
|
+
deployment = NewRelic::Cli::Deployments.new deploy_options
|
69
53
|
deployment.run
|
70
54
|
logger.info "Uploaded deployment information to New Relic"
|
71
55
|
|
72
|
-
rescue NewRelic::Command::CommandFailure => e
|
56
|
+
rescue NewRelic::Cli::Command::CommandFailure => e
|
73
57
|
logger.info e.message
|
74
58
|
|
75
59
|
rescue Capistrano::CommandError
|
@@ -84,6 +68,35 @@ make_notify_task = Proc.new do
|
|
84
68
|
# run(...)
|
85
69
|
# end
|
86
70
|
end
|
71
|
+
|
72
|
+
def lookup_changelog(changelog)
|
73
|
+
if !changelog
|
74
|
+
logger.debug "Getting log of changes for New Relic Deployment details"
|
75
|
+
from_revision = source.next_revision(current_revision)
|
76
|
+
|
77
|
+
if scm == :git
|
78
|
+
log_command = "git log --no-color --pretty=format:' * %an: %s' " +
|
79
|
+
"--abbrev-commit --no-merges #{previous_revision}..#{real_revision}"
|
80
|
+
else
|
81
|
+
log_command = "#{source.log(from_revision)}"
|
82
|
+
end
|
83
|
+
|
84
|
+
changelog = `#{log_command}`
|
85
|
+
end
|
86
|
+
changelog
|
87
|
+
end
|
88
|
+
|
89
|
+
def lookup_rev(rev)
|
90
|
+
if rev.nil?
|
91
|
+
rev = source.query_revision(source.head()) do |cmd|
|
92
|
+
logger.debug "executing locally: '#{cmd}'"
|
93
|
+
`#{cmd}`
|
94
|
+
end
|
95
|
+
|
96
|
+
rev = rev[0..6] if scm == :git
|
97
|
+
end
|
98
|
+
rev
|
99
|
+
end
|
87
100
|
end
|
88
101
|
end
|
89
102
|
|
@@ -31,7 +31,7 @@ module NewRelic
|
|
31
31
|
@root_segment = create_segment 0.0, "ROOT"
|
32
32
|
|
33
33
|
@guid = generate_guid
|
34
|
-
NewRelic::Agent::
|
34
|
+
NewRelic::Agent::TransactionState.get.request_guid = @guid
|
35
35
|
end
|
36
36
|
|
37
37
|
def count_segments
|
@@ -187,6 +187,11 @@ module NewRelic
|
|
187
187
|
@params = params
|
188
188
|
end
|
189
189
|
|
190
|
+
def force_persist_sample?
|
191
|
+
NewRelic::Agent::TransactionState.get.request_token &&
|
192
|
+
self.duration > NewRelic::Agent::TransactionState.get.transaction.apdex_t
|
193
|
+
end
|
194
|
+
|
190
195
|
private
|
191
196
|
|
192
197
|
HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
|
@@ -268,6 +273,5 @@ module NewRelic
|
|
268
273
|
target_called_segment.end_trace(source_called_segment.exit_timestamp)
|
269
274
|
end
|
270
275
|
end
|
271
|
-
|
272
276
|
end
|
273
277
|
end
|
data/lib/new_relic/version.rb
CHANGED
data/lib/tasks/install.rake
CHANGED
@@ -1,7 +1,27 @@
|
|
1
1
|
# run unit tests for the NewRelic Agent
|
2
2
|
namespace :newrelic do
|
3
|
-
desc "
|
3
|
+
desc "Install a default config/newrelic.yml file"
|
4
4
|
task :install do
|
5
5
|
load File.expand_path(File.join(File.dirname(__FILE__), "..", "..", "install.rb"))
|
6
6
|
end
|
7
|
+
|
8
|
+
namespace :config do
|
9
|
+
desc "Describe available New Relic configuration settings."
|
10
|
+
task :docs do
|
11
|
+
require File.expand_path(File.join(File.dirname(__FILE__), "..", "new_relic", "agent", "configuration", "default_source.rb"))
|
12
|
+
|
13
|
+
NewRelic::Agent::Configuration::DEFAULTS.each do |key, value|
|
14
|
+
if value[:public]
|
15
|
+
puts "Setting: #{key}"
|
16
|
+
if value[:type] == NewRelic::Agent::Configuration::Boolean
|
17
|
+
puts "Type: Boolean"
|
18
|
+
else
|
19
|
+
puts "Type: #{value[:type]}"
|
20
|
+
end
|
21
|
+
puts 'Description: ' + value[:description]
|
22
|
+
puts "-" * (value[:description].length + 14)
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
7
27
|
end
|
data/newrelic_rpm.gemspec
CHANGED
@@ -9,7 +9,7 @@ Gem::Specification.new do |s|
|
|
9
9
|
s.name = "newrelic_rpm"
|
10
10
|
s.version = NewRelic::VERSION::STRING
|
11
11
|
s.required_rubygems_version = Gem::Requirement.new("> 1.3.1") if s.respond_to? :required_rubygems_version=
|
12
|
-
s.authors = [ "Jason Clark", "Sam Goldstein", "Michael Granger", "
|
12
|
+
s.authors = [ "Jason Clark", "Sam Goldstein", "Michael Granger", "Jonan Scheffler", "Ben Weintraub" ]
|
13
13
|
s.date = Time.now.strftime('%Y-%m-%d')
|
14
14
|
s.description = <<-EOS
|
15
15
|
New Relic is a performance management system, developed by New Relic,
|
@@ -50,6 +50,10 @@ EOS
|
|
50
50
|
s.add_development_dependency 'activerecord-jdbcsqlite3-adapter' if RUBY_PLATFORM == 'java'
|
51
51
|
s.add_development_dependency 'jruby-openssl' if RUBY_PLATFORM == 'java'
|
52
52
|
s.add_development_dependency 'sequel', '~> 3.46.0'
|
53
|
+
s.add_development_dependency 'pry'
|
54
|
+
s.add_development_dependency 'guard'
|
55
|
+
s.add_development_dependency 'guard-test'
|
56
|
+
s.add_development_dependency 'rb-fsevent', '~> 0.9.1'
|
53
57
|
|
54
58
|
# Only sign with our private key if you can find it
|
55
59
|
signing_key_path = File.expand_path('~/.ssh/newrelic_rpm-private_key.pem')
|
data/test/agent_helper.rb
CHANGED
@@ -295,15 +295,6 @@ ensure
|
|
295
295
|
parent.const_set(const_name, removed_constant) if removed_constant
|
296
296
|
end
|
297
297
|
|
298
|
-
def internet_connection?
|
299
|
-
if ENV['NO_INTERNET']
|
300
|
-
puts " - No internet connection, skipping"
|
301
|
-
false
|
302
|
-
else
|
303
|
-
true
|
304
|
-
end
|
305
|
-
end
|
306
|
-
|
307
298
|
def with_debug_logging
|
308
299
|
orig_logger = NewRelic::Agent.logger
|
309
300
|
$stderr.puts '', '---', ''
|
@@ -313,3 +304,7 @@ def with_debug_logging
|
|
313
304
|
ensure
|
314
305
|
NewRelic::Agent.logger = orig_logger
|
315
306
|
end
|
307
|
+
|
308
|
+
def create_agent_command(args = {})
|
309
|
+
NewRelic::Agent::Commands::AgentCommand.new([-1, { "name" => "command_name", "arguments" => args}])
|
310
|
+
end
|