newrelic_rpm 3.6.5.130 → 3.6.6.147
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/CHANGELOG +27 -3
- data/Gemfile +1 -14
- data/Rakefile +15 -5
- data/config.dot +1 -1
- data/lib/new_relic/agent/agent.rb +15 -0
- data/lib/new_relic/agent/agent_logger.rb +19 -14
- data/lib/new_relic/agent/configuration/defaults.rb +4 -3
- data/lib/new_relic/agent/configuration/environment_source.rb +6 -4
- data/lib/new_relic/agent/configuration/manager.rb +7 -2
- data/lib/new_relic/agent/configuration/mask_defaults.rb +1 -2
- data/lib/new_relic/agent/cross_app_monitor.rb +5 -4
- data/lib/new_relic/agent/cross_app_tracing.rb +0 -1
- data/lib/new_relic/agent/error_collector.rb +30 -1
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +67 -0
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +59 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +12 -0
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +3 -3
- data/lib/new_relic/agent/instrumentation/authlogic.rb +3 -3
- data/lib/new_relic/agent/instrumentation/curb.rb +179 -0
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +3 -3
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +35 -26
- data/lib/new_relic/agent/instrumentation/httpclient.rb +46 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +3 -3
- data/lib/new_relic/agent/instrumentation/puma.rb +23 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +40 -0
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +0 -1
- data/lib/new_relic/agent/instrumentation/sunspot.rb +1 -1
- data/lib/new_relic/agent/internal_agent_error.rb +18 -0
- data/lib/new_relic/agent/new_relic_service.rb +2 -8
- data/lib/new_relic/agent/request_sampler.rb +4 -6
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +0 -1
- data/lib/new_relic/agent/stats.rb +9 -0
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +44 -6
- data/lib/new_relic/agent/system_info.rb +1 -1
- data/lib/new_relic/agent/thread_profiler.rb +6 -6
- data/lib/new_relic/agent/transaction.rb +1 -1
- data/lib/new_relic/agent/transaction_info.rb +0 -1
- data/lib/new_relic/agent/transaction_sample_builder.rb +6 -5
- data/lib/new_relic/agent/transaction_sampler.rb +1 -1
- data/lib/new_relic/commands/deployments.rb +6 -0
- data/lib/new_relic/commands/install.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -2
- data/lib/new_relic/control/instrumentation.rb +2 -2
- data/lib/new_relic/control/server_methods.rb +1 -2
- data/lib/new_relic/delayed_job_injection.rb +0 -40
- data/lib/new_relic/helper.rb +0 -1
- data/lib/new_relic/latest_changes.rb +1 -1
- data/lib/new_relic/local_environment.rb +9 -4
- data/lib/new_relic/metric_spec.rb +19 -3
- data/lib/new_relic/noticed_error.rb +2 -1
- data/lib/new_relic/rack/agent_hooks.rb +0 -1
- data/lib/new_relic/rack/developer_mode.rb +1 -1
- data/lib/new_relic/rack/error_collector.rb +42 -21
- data/lib/new_relic/recipes.rb +0 -1
- data/lib/new_relic/transaction_analysis.rb +0 -1
- data/lib/new_relic/transaction_sample/segment.rb +4 -4
- data/lib/new_relic/version.rb +1 -1
- data/lib/sequel/extensions/newrelic_instrumentation.rb +6 -7
- data/lib/sequel/plugins/newrelic_instrumentation.rb +0 -1
- data/lib/tasks/install.rake +2 -2
- data/newrelic_rpm.gemspec +11 -1
- data/test/active_record_fixtures.rb +2 -2
- data/test/agent_helper.rb +46 -3
- data/test/config/newrelic.yml +2 -2
- data/test/multiverse/.gitignore +2 -0
- data/test/multiverse/lib/multiverse/envfile.rb +6 -9
- data/test/multiverse/lib/multiverse/environment.rb +0 -1
- data/test/multiverse/lib/multiverse/output_collector.rb +43 -11
- data/test/multiverse/lib/multiverse/runner.rb +37 -5
- data/test/multiverse/lib/multiverse/suite.rb +149 -67
- data/test/multiverse/script/run_one +4 -2
- data/test/multiverse/script/runner +1 -5
- data/test/multiverse/suites/active_record/Envfile +3 -2
- data/test/multiverse/suites/active_record/ar_method_aliasing.rb +13 -12
- data/test/multiverse/suites/active_record/config/newrelic.yml +0 -3
- data/test/multiverse/suites/agent_only/audit_log_test.rb +30 -34
- data/test/multiverse/suites/agent_only/before_suite.rb +7 -0
- data/test/multiverse/suites/agent_only/config/newrelic.yml +1 -7
- data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +12 -20
- data/test/multiverse/suites/agent_only/http_response_code_test.rb +16 -34
- data/test/multiverse/suites/agent_only/key_transactions_test.rb +18 -28
- data/test/multiverse/suites/agent_only/logging_test.rb +25 -49
- data/test/multiverse/suites/agent_only/marshaling_test.rb +30 -38
- data/test/multiverse/suites/agent_only/pipe_manager_test.rb +12 -6
- data/test/multiverse/suites/agent_only/rename_rule_test.rb +30 -38
- data/test/multiverse/suites/agent_only/rum_instrumentation_test.rb +16 -18
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +6 -7
- data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +26 -32
- data/test/multiverse/suites/agent_only/ssl_test.rb +10 -14
- data/test/multiverse/suites/agent_only/start_up_test.rb +1 -1
- data/test/multiverse/suites/agent_only/testing_app.rb +2 -0
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +23 -24
- data/test/multiverse/suites/config_file_loading/Envfile +6 -2
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +8 -4
- data/test/multiverse/suites/curb/Envfile +19 -0
- data/test/multiverse/suites/curb/config/newrelic.yml +19 -0
- data/test/multiverse/suites/curb/curb_test.rb +195 -0
- data/test/multiverse/suites/datamapper/Envfile +2 -0
- data/test/multiverse/suites/datamapper/config/newrelic.yml +0 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +6 -10
- data/test/multiverse/suites/deferred_instrumentation/Envfile +19 -0
- data/test/multiverse/suites/deferred_instrumentation/config/newrelic.yml +22 -0
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +103 -0
- data/test/multiverse/suites/excon/config/newrelic.yml +0 -2
- data/test/multiverse/suites/excon/excon_test.rb +3 -3
- data/test/multiverse/suites/httpclient/Envfile +15 -0
- data/test/multiverse/suites/httpclient/config/newrelic.yml +19 -0
- data/test/multiverse/suites/httpclient/httpclient_test.rb +70 -0
- data/test/multiverse/suites/net_http/config/newrelic.yml +0 -2
- data/test/multiverse/suites/net_http/net_http_test.rb +9 -4
- data/test/multiverse/suites/padrino/Envfile +2 -0
- data/test/multiverse/suites/padrino/config/newrelic.yml +0 -3
- data/test/multiverse/suites/padrino/padrino_test.rb +5 -4
- data/test/multiverse/suites/rails/Envfile +3 -0
- data/test/multiverse/suites/rails/app.rb +1 -0
- data/test/multiverse/suites/rails/bad_instrumentation_test.rb +31 -0
- data/test/multiverse/suites/rails/config/newrelic.yml +2 -3
- data/test/multiverse/suites/rails/error_tracing_test.rb +32 -41
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +6 -16
- data/test/multiverse/suites/rails/queue_time_test.rb +4 -20
- data/test/multiverse/suites/rails/request_statistics_test.rb +7 -32
- data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -10
- data/test/multiverse/suites/resque/config/newrelic.yml +1 -3
- data/test/multiverse/suites/resque/instrumentation_test.rb +10 -7
- data/test/multiverse/suites/sequel/Envfile +8 -0
- data/test/multiverse/suites/sequel/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sequel/sequel_test.rb +1 -2
- data/test/multiverse/suites/sidekiq/Envfile +0 -12
- data/test/multiverse/suites/sidekiq/config/newrelic.yml +1 -3
- data/test/multiverse/suites/sidekiq/sidekiq_instrumentation_test.rb +44 -100
- data/test/multiverse/suites/sinatra/config/newrelic.yml +0 -3
- data/test/multiverse/suites/sinatra/ignoring_test.rb +8 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +8 -1
- data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +9 -12
- data/test/multiverse/suites/sinatra/sinatra_metric_explosion_test.rb +9 -8
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_routes_test.rb +6 -5
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +10 -13
- data/test/multiverse/suites/typhoeus/config/newrelic.yml +0 -2
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +7 -4
- data/test/multiverse/test/suite_examples/one/a/a_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/a/config/newrelic.yml +0 -1
- data/test/multiverse/test/suite_examples/one/b/b_test.rb +0 -1
- data/test/multiverse/test/suite_examples/one/b/config/newrelic.yml +0 -1
- data/test/new_relic/agent/agent/connect_test.rb +1 -1
- data/test/new_relic/agent/agent/start_test.rb +0 -1
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +0 -1
- data/test/new_relic/agent/agent_logger_test.rb +37 -3
- data/test/new_relic/agent/agent_test.rb +23 -1
- data/test/new_relic/agent/browser_monitoring_test.rb +0 -1
- data/test/new_relic/agent/busy_calculator_test.rb +2 -2
- data/test/new_relic/agent/configuration/environment_source_test.rb +22 -0
- data/test/new_relic/agent/error_collector/notice_error_test.rb +1 -1
- data/test/new_relic/agent/error_collector_test.rb +95 -13
- data/test/new_relic/agent/event_listener_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +23 -0
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +4 -2
- data/test/new_relic/agent/instrumentation/instrumentation_test.rb +0 -1
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +16 -11
- data/test/new_relic/agent/instrumentation/rack_test.rb +0 -1
- data/test/new_relic/agent/memcache_instrumentation_test.rb +7 -7
- data/test/{multiverse/suites/agent_only/test_trace_method_with_punctuation.rb → new_relic/agent/method_interrobang_test.rb} +3 -5
- data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +1 -2
- data/test/{multiverse/suites/agent_only → new_relic/agent}/method_visibility_test.rb +17 -29
- data/test/new_relic/agent/new_relic_service_test.rb +1 -1
- data/test/new_relic/agent/pipe_service_test.rb +1 -1
- data/test/new_relic/agent/request_sampler_test.rb +10 -10
- data/test/new_relic/agent/rpm_agent_test.rb +1 -2
- data/test/new_relic/agent/stats_hash_test.rb +83 -5
- data/test/new_relic/agent/stats_test.rb +0 -1
- data/test/new_relic/agent/thread_profiler_test.rb +7 -7
- data/test/new_relic/agent/threaded_test.rb +1 -2
- data/test/new_relic/agent/transaction/pop_test.rb +0 -1
- data/test/{multiverse/suites/agent_only/test_trace_transaction_with_punctuation.rb → new_relic/agent/transaction_interrobang_test.rb} +2 -4
- data/test/new_relic/agent/transaction_sample_builder_test.rb +13 -0
- data/test/new_relic/agent/transaction_test.rb +7 -5
- data/test/new_relic/agent/worker_loop_test.rb +0 -1
- data/test/new_relic/agent_test.rb +0 -27
- data/test/new_relic/collection_helper_test.rb +17 -17
- data/test/new_relic/control/class_methods_test.rb +1 -1
- data/test/new_relic/control_test.rb +6 -6
- data/test/new_relic/dependency_detection_test.rb +28 -0
- data/test/new_relic/evil_server.rb +0 -1
- data/test/new_relic/fake_collector.rb +20 -2
- data/test/new_relic/fake_server.rb +0 -12
- data/test/new_relic/http_client_test_cases.rb +20 -24
- data/test/new_relic/metric_spec_test.rb +18 -0
- data/test/new_relic/multiverse_helpers.rb +164 -0
- data/test/new_relic/rack/agent_hooks_test.rb +0 -1
- data/test/new_relic/rack/all_test.rb +0 -1
- data/test/new_relic/rack/deferred_instrumentation_test.rb +35 -0
- data/test/new_relic/rack/developer_mode_helper_test.rb +8 -9
- data/test/new_relic/rack/developer_mode_test.rb +0 -2
- data/test/new_relic/rack/error_collector_test.rb +52 -8
- data/test/new_relic/transaction_sample/composite_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/fake_segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample/summary_segment_test.rb +0 -1
- data/test/performance/README.md +162 -0
- data/test/performance/lib/performance.rb +28 -0
- data/test/performance/lib/performance/console_reporter.rb +51 -0
- data/test/performance/lib/performance/hako_client.rb +31 -0
- data/test/performance/lib/performance/hako_reporter.rb +26 -0
- data/test/performance/lib/performance/instrumentation/cpu_usage.rb +26 -0
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +53 -0
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +30 -0
- data/test/performance/lib/performance/instrumentor.rb +110 -0
- data/test/performance/lib/performance/json_reporter.rb +15 -0
- data/test/performance/lib/performance/result.rb +80 -0
- data/test/performance/lib/performance/runner.rb +207 -0
- data/test/performance/lib/performance/test_case.rb +65 -0
- data/test/performance/lib/performance/timer.rb +38 -0
- data/test/performance/script/mega-runner +37 -0
- data/test/performance/script/runner +81 -0
- data/test/performance/suites/startup.rb +12 -0
- data/test/performance/suites/transaction_tracing.rb +66 -0
- data/test/script/ci_agent-tests_runner.sh +4 -4
- data/test/script/ci_multiverse_runner.sh +3 -3
- data/test/test_helper.rb +0 -11
- data/ui/helpers/developer_mode_helper.rb +1 -1
- data/ui/views/layouts/newrelic_default.rhtml +1 -1
- data/ui/views/newrelic/_segment.rhtml +2 -2
- data/ui/views/newrelic/_segment_limit_message.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_detail.rhtml +1 -1
- data/ui/views/newrelic/_show_sample_sql.rhtml +4 -4
- data/ui/views/newrelic/_stack_trace.rhtml +2 -2
- data/ui/views/newrelic/file/javascript/transaction_sample.js +3 -3
- data/ui/views/newrelic/file/stylesheets/style.css +13 -13
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection.rb +18 -4
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/metric_parser.rb +0 -1
- metadata +186 -17
- metadata.gz.sig +0 -0
- data/test/multiverse/suites/active_record/encoding_test.rb +0 -30
- data/test/multiverse/suites/agent_only/no_dns_resolv.rb +0 -21
- data/test/multiverse/suites/sidekiq/app.rb +0 -25
- data/test/new_relic/delayed_job_injection_test.rb +0 -25
@@ -0,0 +1,23 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
DependencyDetection.defer do
|
6
|
+
named :puma
|
7
|
+
|
8
|
+
depends_on do
|
9
|
+
defined?(::Puma) &&
|
10
|
+
defined?(::Puma::Const::VERSION) &&
|
11
|
+
NewRelic::VersionNumber.new(::Puma::Const::VERSION) > NewRelic::VersionNumber.new("2.0.0")
|
12
|
+
end
|
13
|
+
|
14
|
+
executes do
|
15
|
+
::NewRelic::Agent.logger.info 'Installing Puma cluster mode support'
|
16
|
+
end
|
17
|
+
|
18
|
+
executes do
|
19
|
+
Puma.cli_config.options[:worker_boot] << Proc.new do
|
20
|
+
::NewRelic::Agent.after_fork(:force_reconnect => true)
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -100,3 +100,43 @@ module NewRelic
|
|
100
100
|
end
|
101
101
|
end
|
102
102
|
end
|
103
|
+
|
104
|
+
|
105
|
+
DependencyDetection.defer do
|
106
|
+
named :rack
|
107
|
+
|
108
|
+
depends_on do
|
109
|
+
defined?(::Rack) && defined?(::Rack::Builder)
|
110
|
+
end
|
111
|
+
|
112
|
+
executes do
|
113
|
+
::NewRelic::Agent.logger.info 'Installing deferred Rack instrumentation'
|
114
|
+
end
|
115
|
+
|
116
|
+
executes do
|
117
|
+
unless ::Rack::Builder.respond_to?(:_nr_deferred_detection_ran)
|
118
|
+
class ::Rack::Builder
|
119
|
+
|
120
|
+
class << self
|
121
|
+
attr_accessor :_nr_deferred_detection_ran
|
122
|
+
end
|
123
|
+
self._nr_deferred_detection_ran = false
|
124
|
+
|
125
|
+
def to_app_with_newrelic_deferred_dependency_detection
|
126
|
+
unless Rack::Builder._nr_deferred_detection_ran
|
127
|
+
NewRelic::Agent.logger.info "Doing deferred dependency-detection before Rack startup"
|
128
|
+
DependencyDetection.detect!
|
129
|
+
Rack::Builder._nr_deferred_detection_ran = true
|
130
|
+
end
|
131
|
+
|
132
|
+
to_app_without_newrelic
|
133
|
+
end
|
134
|
+
|
135
|
+
alias_method :to_app_without_newrelic, :to_app
|
136
|
+
alias_method :to_app, :to_app_with_newrelic_deferred_dependency_detection
|
137
|
+
|
138
|
+
end
|
139
|
+
end
|
140
|
+
end
|
141
|
+
end
|
142
|
+
|
@@ -4,15 +4,15 @@
|
|
4
4
|
|
5
5
|
DependencyDetection.defer do
|
6
6
|
@name = :rails_action_web_service
|
7
|
-
|
7
|
+
|
8
8
|
depends_on do
|
9
9
|
defined?(ActionWebService)
|
10
10
|
end
|
11
|
-
|
11
|
+
|
12
12
|
executes do
|
13
13
|
::NewRelic::Agent.logger.info 'Installing Rails ActionWebService instrumentation'
|
14
|
-
end
|
15
|
-
|
14
|
+
end
|
15
|
+
|
16
16
|
executes do
|
17
17
|
# NewRelic Agent instrumentation for WebServices
|
18
18
|
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
# This is the base class for all errors that we want to record through the
|
6
|
+
# NewRelic::Agent::ErrorCollector#notice_agent_error API. It provides the
|
7
|
+
# standard support text at the front of the message, and is used for flagging
|
8
|
+
# agent errors when checking queue limits.
|
9
|
+
|
10
|
+
module NewRelic
|
11
|
+
module Agent
|
12
|
+
class InternalAgentError < StandardError
|
13
|
+
def initialize(msg=nil)
|
14
|
+
super("Ruby agent internal error. Please contact support referencing this error.\n #{msg}")
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -38,8 +38,6 @@ module NewRelic
|
|
38
38
|
Agent.config.register_callback(:ssl) do |ssl|
|
39
39
|
if !ssl
|
40
40
|
::NewRelic::Agent.logger.warn("Agent is configured not to use SSL when communicating with New Relic's servers")
|
41
|
-
elsif !Agent.config[:verify_certificate]
|
42
|
-
::NewRelic::Agent.logger.warn("Agent is configured to use SSL but to skip certificate validation when communicating with New Relic's servers")
|
43
41
|
else
|
44
42
|
::NewRelic::Agent.logger.debug("Agent is configured to use SSL")
|
45
43
|
end
|
@@ -209,12 +207,8 @@ module NewRelic
|
|
209
207
|
# an error when use_ssl=(true) is called and jruby-openssl isn't
|
210
208
|
# installed
|
211
209
|
http.use_ssl = true
|
212
|
-
|
213
|
-
|
214
|
-
http.ca_file = cert_file_path
|
215
|
-
else
|
216
|
-
http.verify_mode = OpenSSL::SSL::VERIFY_NONE
|
217
|
-
end
|
210
|
+
http.verify_mode = OpenSSL::SSL::VERIFY_PEER
|
211
|
+
http.ca_file = cert_file_path
|
218
212
|
rescue StandardError, LoadError
|
219
213
|
msg = "Agent is configured to use SSL, but SSL is not available in the environment. "
|
220
214
|
msg << "Either disable SSL in the agent configuration, or install SSL support."
|
@@ -146,11 +146,12 @@ class NewRelic::Agent::RequestSampler
|
|
146
146
|
|
147
147
|
|
148
148
|
# Event handler for the :transaction_finished event.
|
149
|
-
def on_transaction_finished( metric, duration, options={} )
|
149
|
+
def on_transaction_finished( metric, start_timestamp, duration, options={} )
|
150
150
|
return unless @enabled
|
151
151
|
self << {
|
152
|
-
|
153
|
-
|
152
|
+
TIMESTAMP_KEY => float(start_timestamp),
|
153
|
+
NAME_KEY => string(metric),
|
154
|
+
DURATION_KEY => float(duration)
|
154
155
|
}.merge(options)
|
155
156
|
end
|
156
157
|
|
@@ -234,8 +235,6 @@ class NewRelic::Agent::RequestSampler
|
|
234
235
|
@last_sample_taken = Time.now
|
235
236
|
|
236
237
|
sample[TYPE_KEY] = SAMPLE_TYPE
|
237
|
-
sample[TIMESTAMP_KEY] = @last_sample_taken
|
238
|
-
|
239
238
|
@samples << sample
|
240
239
|
end
|
241
240
|
|
@@ -247,4 +246,3 @@ class NewRelic::Agent::RequestSampler
|
|
247
246
|
end
|
248
247
|
|
249
248
|
end # class NewRelic::Agent::RequestSampler
|
250
|
-
|
@@ -100,6 +100,15 @@ module NewRelic
|
|
100
100
|
"#<NewRelic::Agent::Stats #{to_s} >"
|
101
101
|
end
|
102
102
|
|
103
|
+
# Concerned about implicit usage of inspect relying on stats format, so
|
104
|
+
# putting back a version to get full inspection as separate method
|
105
|
+
def inspect_full
|
106
|
+
variables = instance_variables.map do |ivar|
|
107
|
+
"#{ivar.to_s}=#{instance_variable_get(ivar).inspect}"
|
108
|
+
end.join(" ")
|
109
|
+
"#<NewRelic::Agent::Stats #{variables}>"
|
110
|
+
end
|
111
|
+
|
103
112
|
def ==(other)
|
104
113
|
other.class == self.class &&
|
105
114
|
(
|
@@ -12,6 +12,9 @@
|
|
12
12
|
#
|
13
13
|
# This class makes no provisions for safe usage from multiple threads, such
|
14
14
|
# measures should be externally provided.
|
15
|
+
|
16
|
+
require 'new_relic/agent/internal_agent_error'
|
17
|
+
|
15
18
|
module NewRelic
|
16
19
|
module Agent
|
17
20
|
class StatsHash < ::Hash
|
@@ -31,9 +34,32 @@ module NewRelic
|
|
31
34
|
Hash[self] == Hash[other]
|
32
35
|
end
|
33
36
|
|
37
|
+
class CorruptedDefaultProcError < NewRelic::Agent::InternalAgentError
|
38
|
+
def initialize(hash, metric_spec)
|
39
|
+
super("Corrupted default proc for StatsHash. Falling back adding #{metric_spec.inspect}")
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
34
43
|
def record(metric_specs, value=nil, aux=nil)
|
35
44
|
Array(metric_specs).each do |metric_spec|
|
36
|
-
stats =
|
45
|
+
stats = nil
|
46
|
+
begin
|
47
|
+
stats = self[metric_spec]
|
48
|
+
rescue => e
|
49
|
+
# This only happen in the case of a corrupted default_proc
|
50
|
+
# Side-step it manually, notice the issue, and carry on....
|
51
|
+
NewRelic::Agent.instance.error_collector. \
|
52
|
+
notice_agent_error(CorruptedDefaultProcError.new(self, metric_spec))
|
53
|
+
|
54
|
+
stats = NewRelic::Agent::Stats.new
|
55
|
+
self[metric_spec] = stats
|
56
|
+
|
57
|
+
# Try to restore the default_proc so we won't continually trip the error
|
58
|
+
if respond_to?(:default_proc=)
|
59
|
+
self.default_proc = Proc.new { |hash, key| hash[key] = NewRelic::Agent::Stats.new }
|
60
|
+
end
|
61
|
+
end
|
62
|
+
|
37
63
|
if block_given?
|
38
64
|
yield stats
|
39
65
|
else
|
@@ -50,12 +76,24 @@ module NewRelic
|
|
50
76
|
end
|
51
77
|
end
|
52
78
|
|
79
|
+
class StatsMergerError < NewRelic::Agent::InternalAgentError
|
80
|
+
def initialize(key, destination, source, original_exception)
|
81
|
+
super("Failure when merging stats '#{key}'. In Hash: #{destination.inspect_full}. Merging: #{source.inspect_full}. Original exception: #{original_exception.class} #{original_exception.message}")
|
82
|
+
set_backtrace(original_exception.backtrace)
|
83
|
+
end
|
84
|
+
end
|
85
|
+
|
53
86
|
def merge!(other)
|
54
87
|
other.each do |key,val|
|
55
|
-
|
56
|
-
self
|
57
|
-
|
58
|
-
|
88
|
+
begin
|
89
|
+
if self.has_key?(key)
|
90
|
+
self[key].merge!(val)
|
91
|
+
else
|
92
|
+
self[key] = val
|
93
|
+
end
|
94
|
+
rescue => err
|
95
|
+
NewRelic::Agent.instance.error_collector. \
|
96
|
+
notice_agent_error(StatsMergerError.new(key, self.fetch(key, nil), val, err))
|
59
97
|
end
|
60
98
|
end
|
61
99
|
self
|
@@ -69,4 +107,4 @@ module NewRelic
|
|
69
107
|
end
|
70
108
|
end
|
71
109
|
end
|
72
|
-
end
|
110
|
+
end
|
@@ -39,9 +39,9 @@ module NewRelic
|
|
39
39
|
end
|
40
40
|
|
41
41
|
def respond_to_commands(commands, ¬ify_results)
|
42
|
-
return if commands.empty? || commands.first.size < 2
|
42
|
+
return if commands.empty? || commands.first.size < 2
|
43
43
|
|
44
|
-
# Doesn't deal with multiple commands in the return set as
|
44
|
+
# Doesn't deal with multiple commands in the return set as
|
45
45
|
# we currently only have start/stop of thread profiling
|
46
46
|
command_id = commands.first[0]
|
47
47
|
command = commands.first[1]
|
@@ -107,10 +107,10 @@ EOF
|
|
107
107
|
|
108
108
|
class ThreadProfile
|
109
109
|
|
110
|
-
attr_reader :profile_id,
|
111
|
-
:traces,
|
112
|
-
:profile_agent_code, :interval,
|
113
|
-
:poll_count, :sample_count,
|
110
|
+
attr_reader :profile_id,
|
111
|
+
:traces,
|
112
|
+
:profile_agent_code, :interval,
|
113
|
+
:poll_count, :sample_count,
|
114
114
|
:start_time, :stop_time
|
115
115
|
|
116
116
|
def initialize(profile_id, duration, interval, profile_agent_code)
|
@@ -196,7 +196,7 @@ module NewRelic
|
|
196
196
|
|
197
197
|
# these tear everything down so need to be done after merging stats
|
198
198
|
if self.root?
|
199
|
-
agent.events.notify(:transaction_finished, @name, end_time.to_f - start_time.to_f, overview_metrics)
|
199
|
+
agent.events.notify(:transaction_finished, @name, start_time.to_f, end_time.to_f - start_time.to_f, overview_metrics)
|
200
200
|
agent.stats_engine.end_transaction
|
201
201
|
end
|
202
202
|
end
|
@@ -32,13 +32,14 @@ module NewRelic
|
|
32
32
|
@depth = 1
|
33
33
|
end
|
34
34
|
|
35
|
-
# No-op - some clients expect to be able to use
|
36
|
-
# TT segments.
|
35
|
+
# No-op - some clients expect to be able to use these to read/write
|
36
|
+
# params on TT segments.
|
37
|
+
def [](key); end
|
37
38
|
def []=(key, value); end
|
38
39
|
|
39
|
-
#
|
40
|
-
|
41
|
-
def
|
40
|
+
# Stubbed out in case clients try to touch params directly.
|
41
|
+
def params; {}; end
|
42
|
+
def params=; end
|
42
43
|
end
|
43
44
|
|
44
45
|
attr_reader :current_segment, :sample
|
@@ -343,7 +343,7 @@ module NewRelic
|
|
343
343
|
# Set parameters on the current segment.
|
344
344
|
def add_segment_parameters( params )
|
345
345
|
return unless builder
|
346
|
-
builder.current_segment
|
346
|
+
params.each { |k,v| builder.current_segment[k] = v }
|
347
347
|
end
|
348
348
|
|
349
349
|
# Every 1/n harvests, adds the most recent sample to the harvest
|
@@ -35,6 +35,7 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
35
35
|
control.env = @environment if @environment
|
36
36
|
load_yaml_from_env(control.env)
|
37
37
|
@appname ||= NewRelic::Agent.config.app_names[0] || control.env || 'development'
|
38
|
+
setup_logging(control.env)
|
38
39
|
end
|
39
40
|
|
40
41
|
def load_yaml_from_env(env)
|
@@ -42,6 +43,11 @@ class NewRelic::Command::Deployments < NewRelic::Command
|
|
42
43
|
NewRelic::Agent.config.replace_or_add_config(yaml, 1)
|
43
44
|
end
|
44
45
|
|
46
|
+
def setup_logging(env)
|
47
|
+
NewRelic::Agent.logger = NewRelic::Agent::AgentLogger.new(NewRelic::Agent.config)
|
48
|
+
NewRelic::Agent.logger.info("Running Capistrano from '#{env}' environment for application '#{@appname}'")
|
49
|
+
end
|
50
|
+
|
45
51
|
# Run the Deployment upload in New Relic via Active Resource.
|
46
52
|
# Will possibly print errors and exit the VM
|
47
53
|
def run
|
@@ -49,8 +49,7 @@ module NewRelic
|
|
49
49
|
if rails_config && ::Rails.configuration.respond_to?(:after_initialize)
|
50
50
|
rails_config.after_initialize do
|
51
51
|
# This will insure we load all the instrumentation as late as possible. If the agent
|
52
|
-
# is not enabled, it will load a limited amount of instrumentation.
|
53
|
-
# delayed_job_injection.rb
|
52
|
+
# is not enabled, it will load a limited amount of instrumentation.
|
54
53
|
DependencyDetection.detect!
|
55
54
|
end
|
56
55
|
end
|
@@ -45,13 +45,13 @@ module NewRelic
|
|
45
45
|
@instrumentation_files << pattern
|
46
46
|
end
|
47
47
|
end
|
48
|
-
|
48
|
+
|
49
49
|
# Signals the agent that it's time to actually load the
|
50
50
|
# instrumentation files. May be overridden by subclasses
|
51
51
|
def install_instrumentation
|
52
52
|
_install_instrumentation
|
53
53
|
end
|
54
|
-
|
54
|
+
|
55
55
|
# adds samplers to the stats engine so that they run every
|
56
56
|
# minute. This is dynamically recognized by any class that
|
57
57
|
# subclasses NewRelic::Agent::Sampler
|
@@ -52,7 +52,7 @@ module NewRelic
|
|
52
52
|
def convert_to_ip_address(host)
|
53
53
|
# here we leave it as a host name since the cert verification
|
54
54
|
# needs it in host form
|
55
|
-
return host if Agent.config[:ssl]
|
55
|
+
return host if Agent.config[:ssl]
|
56
56
|
# We won't talk directly to the host, so no need to resolve if proxy configured
|
57
57
|
return host if Agent.config[:proxy_host]
|
58
58
|
return nil if host.nil? || host.downcase == "localhost"
|
@@ -83,4 +83,3 @@ module NewRelic
|
|
83
83
|
include ServerMethods
|
84
84
|
end
|
85
85
|
end
|
86
|
-
|