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
@@ -34,6 +34,8 @@ module NewRelic
|
|
34
34
|
# transaction are also ignored
|
35
35
|
NewRelic::Agent.instance.push_trace_execution_flag(false)
|
36
36
|
end
|
37
|
+
rescue => e
|
38
|
+
handle_tracing_error('ActionControllerSubscriber#start', e)
|
37
39
|
end
|
38
40
|
|
39
41
|
def finish(name, id, payload)
|
@@ -52,6 +54,15 @@ module NewRelic
|
|
52
54
|
else
|
53
55
|
Agent.instance.pop_trace_execution_flag
|
54
56
|
end
|
57
|
+
rescue => e
|
58
|
+
handle_tracing_error('ActionControllerSubscriber#finish', e)
|
59
|
+
end
|
60
|
+
|
61
|
+
def handle_tracing_error(identifier, e)
|
62
|
+
# This is an important enough failure that we want the backtrace logged
|
63
|
+
# at error level, hence the explicit log_exception call.
|
64
|
+
NewRelic::Agent.logger.error("Tracing error during #{identifier}:")
|
65
|
+
NewRelic::Agent.logger.log_exception(:error, e)
|
55
66
|
end
|
56
67
|
|
57
68
|
def set_enduser_ignore
|
@@ -102,6 +113,7 @@ module NewRelic
|
|
102
113
|
def stop_transaction(event)
|
103
114
|
Agent.instance.stats_engine \
|
104
115
|
.pop_scope(event.scope, event.metric_name, event.end)
|
116
|
+
ensure
|
105
117
|
Transaction.stop
|
106
118
|
end
|
107
119
|
|
@@ -4,17 +4,17 @@
|
|
4
4
|
|
5
5
|
DependencyDetection.defer do
|
6
6
|
@name = :active_merchant
|
7
|
-
|
7
|
+
|
8
8
|
depends_on do
|
9
9
|
defined?(ActiveMerchant) && defined?(ActiveMerchant::Billing) &&
|
10
10
|
defined?(ActiveMerchant::Billing::Gateway) &&
|
11
11
|
ActiveMerchant::Billing::Gateway.respond_to?(:implementations)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
executes do
|
15
15
|
::NewRelic::Agent.logger.info 'Installing ActiveMerchant instrumentation'
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
executes do
|
19
19
|
ActiveMerchant::Billing::Gateway.implementations.each do |gateway|
|
20
20
|
gateway.class_eval do
|
@@ -23,7 +23,7 @@ end
|
|
23
23
|
|
24
24
|
DependencyDetection.defer do
|
25
25
|
@name = :acts_as_solr
|
26
|
-
|
26
|
+
|
27
27
|
depends_on do
|
28
28
|
defined?(ActsAsSolr)
|
29
29
|
end
|
@@ -39,11 +39,11 @@ DependencyDetection.defer do
|
|
39
39
|
depends_on do
|
40
40
|
defined?(ActsAsSolr::CommonMethods)
|
41
41
|
end
|
42
|
-
|
42
|
+
|
43
43
|
executes do
|
44
44
|
::NewRelic::Agent.logger.info 'Installing ActsAsSolr instrumentation'
|
45
45
|
end
|
46
|
-
|
46
|
+
|
47
47
|
executes do
|
48
48
|
ActsAsSolr::ParserMethods.module_eval do
|
49
49
|
include NewRelic::Instrumentation::ActsAsSolrInstrumentation::ParserMethodsInstrumentation
|
@@ -4,7 +4,7 @@
|
|
4
4
|
|
5
5
|
DependencyDetection.defer do
|
6
6
|
@name = :authlogic
|
7
|
-
|
7
|
+
|
8
8
|
depends_on do
|
9
9
|
defined?(AuthLogic) &&
|
10
10
|
defined?(AuthLogic::Session) &&
|
@@ -13,8 +13,8 @@ DependencyDetection.defer do
|
|
13
13
|
|
14
14
|
executes do
|
15
15
|
::NewRelic::Agent.logger.info 'Installing AuthLogic instrumentation'
|
16
|
-
end
|
17
|
-
|
16
|
+
end
|
17
|
+
|
18
18
|
executes do
|
19
19
|
AuthLogic::Session::Base.class_eval do
|
20
20
|
add_method_tracer :find, 'Custom/Authlogic/find'
|
@@ -0,0 +1,179 @@
|
|
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 :curb
|
7
|
+
|
8
|
+
CURB_MIN_VERSION = ::NewRelic::VersionNumber.new("0.8.1")
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
defined?(::Curl) && defined?(::Curl::CURB_VERSION) &&
|
12
|
+
::NewRelic::VersionNumber.new(::Curl::CURB_VERSION) >= CURB_MIN_VERSION
|
13
|
+
end
|
14
|
+
|
15
|
+
executes do
|
16
|
+
::NewRelic::Agent.logger.info 'Installing Curb instrumentation'
|
17
|
+
require 'new_relic/agent/cross_app_tracing'
|
18
|
+
require 'new_relic/agent/http_clients/curb_wrappers'
|
19
|
+
end
|
20
|
+
|
21
|
+
executes do
|
22
|
+
class Curl::Easy
|
23
|
+
|
24
|
+
attr_accessor :_nr_instrumented,
|
25
|
+
:_nr_http_verb,
|
26
|
+
:_nr_header_str,
|
27
|
+
:_nr_original_on_header,
|
28
|
+
:_nr_original_on_complete,
|
29
|
+
:_nr_serial
|
30
|
+
|
31
|
+
# We have to hook these three methods separately, as they don't use
|
32
|
+
# Curl::Easy#http
|
33
|
+
def http_head_with_newrelic(*args, &blk)
|
34
|
+
self._nr_http_verb = :HEAD
|
35
|
+
http_head_without_newrelic(*args, &blk)
|
36
|
+
end
|
37
|
+
alias_method :http_head_without_newrelic, :http_head
|
38
|
+
alias_method :http_head, :http_head_with_newrelic
|
39
|
+
|
40
|
+
def http_post_with_newrelic(*args, &blk)
|
41
|
+
self._nr_http_verb = :POST
|
42
|
+
http_post_without_newrelic(*args, &blk)
|
43
|
+
end
|
44
|
+
alias_method :http_post_without_newrelic, :http_post
|
45
|
+
alias_method :http_post, :http_post_with_newrelic
|
46
|
+
|
47
|
+
def http_put_with_newrelic(url, data, &blk)
|
48
|
+
self._nr_http_verb = :PUT
|
49
|
+
http_put_with_newrelic(url, data, &blk)
|
50
|
+
end
|
51
|
+
alias_method :http_put_without_newrelic, :http_put
|
52
|
+
alias_method :http_put, :http_put_with_newrelic
|
53
|
+
|
54
|
+
|
55
|
+
# Hook the #http method to set the verb.
|
56
|
+
def http_with_newrelic( verb )
|
57
|
+
self._nr_http_verb = verb.to_s.upcase
|
58
|
+
http_without_newrelic( verb )
|
59
|
+
end
|
60
|
+
|
61
|
+
alias_method :http_without_newrelic, :http
|
62
|
+
alias_method :http, :http_with_newrelic
|
63
|
+
|
64
|
+
|
65
|
+
# Hook the #perform method to mark the request as non-parallel.
|
66
|
+
def perform_with_newrelic
|
67
|
+
self._nr_serial = true
|
68
|
+
perform_without_newrelic
|
69
|
+
end
|
70
|
+
|
71
|
+
alias_method :perform_without_newrelic, :perform
|
72
|
+
alias_method :perform, :perform_with_newrelic
|
73
|
+
|
74
|
+
# We override this method in order to ensure access to header_str even
|
75
|
+
# though we use an on_header callback
|
76
|
+
def header_str
|
77
|
+
self._nr_header_str
|
78
|
+
end
|
79
|
+
end # class Curl::Easy
|
80
|
+
|
81
|
+
|
82
|
+
class Curl::Multi
|
83
|
+
include NewRelic::Agent::MethodTracer
|
84
|
+
|
85
|
+
# Add CAT with callbacks if the request is serial
|
86
|
+
def add_with_newrelic( curl )
|
87
|
+
if curl.respond_to?( :_nr_serial ) && curl._nr_serial
|
88
|
+
hook_pending_request( curl ) if NewRelic::Agent.is_execution_traced?
|
89
|
+
end
|
90
|
+
|
91
|
+
return add_without_newrelic( curl )
|
92
|
+
end
|
93
|
+
|
94
|
+
alias_method :add_without_newrelic, :add
|
95
|
+
alias_method :add, :add_with_newrelic
|
96
|
+
|
97
|
+
|
98
|
+
# Trace as an External/Multiple call if the first request isn't serial.
|
99
|
+
def perform_with_newrelic(&blk)
|
100
|
+
return perform_without_newrelic if
|
101
|
+
self.requests.first &&
|
102
|
+
self.requests.first.respond_to?( :_nr_serial ) &&
|
103
|
+
self.requests.first._nr_serial
|
104
|
+
|
105
|
+
trace_execution_scoped("External/Multiple/Curb::Multi/perform") do
|
106
|
+
perform_without_newrelic(&blk)
|
107
|
+
end
|
108
|
+
end
|
109
|
+
|
110
|
+
alias_method :perform_without_newrelic, :perform
|
111
|
+
alias_method :perform, :perform_with_newrelic
|
112
|
+
|
113
|
+
|
114
|
+
# Instrument the specified +request+ (a Curl::Easy object) and set up cross-application
|
115
|
+
# tracing if it's enabled.
|
116
|
+
def hook_pending_request( request )
|
117
|
+
wrapped_request, wrapped_response = wrap_request( request )
|
118
|
+
t0, segment = NewRelic::Agent::CrossAppTracing.start_trace( wrapped_request )
|
119
|
+
|
120
|
+
unless request._nr_instrumented
|
121
|
+
install_header_callback( request, wrapped_response )
|
122
|
+
install_completion_callback( request, t0, segment, wrapped_request, wrapped_response )
|
123
|
+
request._nr_instrumented = true
|
124
|
+
end
|
125
|
+
rescue => err
|
126
|
+
NewRelic::Agent.logger.error( "Untrapped exception", err )
|
127
|
+
end
|
128
|
+
|
129
|
+
|
130
|
+
# Create request and response adapter objects for the specified +request+
|
131
|
+
def wrap_request( request )
|
132
|
+
return NewRelic::Agent::HTTPClients::CurbRequest.new( request ),
|
133
|
+
NewRelic::Agent::HTTPClients::CurbResponse.new( request )
|
134
|
+
end
|
135
|
+
|
136
|
+
|
137
|
+
# Install a callback that will record the response headers to enable
|
138
|
+
# CAT linking
|
139
|
+
def install_header_callback( request, wrapped_response )
|
140
|
+
original_callback = request.on_header
|
141
|
+
request._nr_original_on_header = original_callback
|
142
|
+
request._nr_header_str = ''
|
143
|
+
request.on_header do |header_data|
|
144
|
+
wrapped_response.append_header_data( header_data )
|
145
|
+
|
146
|
+
if original_callback
|
147
|
+
original_callback.call( header_data )
|
148
|
+
else
|
149
|
+
header_data.length
|
150
|
+
end
|
151
|
+
end
|
152
|
+
end
|
153
|
+
|
154
|
+
# Install a callback that will finish the trace.
|
155
|
+
def install_completion_callback( request, t0, segment, wrapped_request, wrapped_response )
|
156
|
+
original_callback = request.on_complete
|
157
|
+
request._nr_original_on_complete = original_callback
|
158
|
+
request.on_complete do |finished_request|
|
159
|
+
begin
|
160
|
+
NewRelic::Agent::CrossAppTracing.finish_trace( t0, segment, wrapped_request, wrapped_response )
|
161
|
+
ensure
|
162
|
+
# Make sure the existing completion callback is run, and restore the
|
163
|
+
# on_complete callback to how it was before.
|
164
|
+
original_callback.call( finished_request ) if original_callback
|
165
|
+
remove_instrumentation_callbacks( request )
|
166
|
+
end
|
167
|
+
end
|
168
|
+
end
|
169
|
+
|
170
|
+
def remove_instrumentation_callbacks( request )
|
171
|
+
request.on_complete(&request._nr_original_on_complete)
|
172
|
+
request.on_header(&request._nr_original_on_header)
|
173
|
+
request._nr_instrumented = false
|
174
|
+
end
|
175
|
+
|
176
|
+
end # class Curl::Multi
|
177
|
+
|
178
|
+
end
|
179
|
+
end
|
@@ -43,7 +43,7 @@
|
|
43
43
|
|
44
44
|
DependencyDetection.defer do
|
45
45
|
@name = :data_mapper
|
46
|
-
|
46
|
+
|
47
47
|
depends_on do
|
48
48
|
defined?(::DataMapper)
|
49
49
|
end
|
@@ -59,11 +59,11 @@ DependencyDetection.defer do
|
|
59
59
|
depends_on do
|
60
60
|
defined?(DataMapper::Collection)
|
61
61
|
end
|
62
|
-
|
62
|
+
|
63
63
|
executes do
|
64
64
|
::NewRelic::Agent.logger.info 'Installing DataMapper instrumentation'
|
65
65
|
end
|
66
|
-
|
66
|
+
|
67
67
|
executes do
|
68
68
|
DataMapper::Model.class_eval do
|
69
69
|
add_method_tracer :get, 'ActiveRecord/#{self.name}/get'
|
@@ -6,44 +6,53 @@ require 'new_relic/agent/instrumentation/controller_instrumentation'
|
|
6
6
|
|
7
7
|
DependencyDetection.defer do
|
8
8
|
@name = :delayed_job
|
9
|
-
|
9
|
+
|
10
10
|
depends_on do
|
11
11
|
!NewRelic::Agent.config[:disable_dj]
|
12
12
|
end
|
13
13
|
|
14
14
|
depends_on do
|
15
|
-
|
16
|
-
defined?(::Delayed) && defined?(::Delayed::Job) &&
|
17
|
-
Delayed::Job.method_defined?(:invoke_job)
|
15
|
+
defined?(::Delayed) && defined?(::Delayed::Worker) && !NewRelic::Agent.config[:disable_dj]
|
18
16
|
end
|
19
|
-
|
17
|
+
|
20
18
|
executes do
|
21
|
-
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation'
|
19
|
+
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation [part 1/2]'
|
22
20
|
end
|
23
|
-
|
21
|
+
|
24
22
|
executes do
|
25
|
-
Delayed::
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
23
|
+
Delayed::Worker.class_eval do
|
24
|
+
def initialize_with_new_relic(*args)
|
25
|
+
initialize_without_new_relic(*args)
|
26
|
+
worker_name = case
|
27
|
+
when self.respond_to?(:name) then self.name
|
28
|
+
when self.class.respond_to?(:default_name) then self.class.default_name
|
29
|
+
end
|
30
|
+
NewRelic::DelayedJobInjection.worker_name = worker_name
|
31
|
+
|
32
|
+
if defined?(::Delayed::Job) && ::Delayed::Job.method_defined?(:invoke_job)
|
33
|
+
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation [part 2/2]'
|
34
|
+
install_newrelic_job_tracer
|
35
|
+
|
36
|
+
dispatcher_instance_id = worker_name || "host:#{Socket.gethostname} pid:#{Process.pid}" rescue "pid:#{Process.pid}"
|
37
|
+
NewRelic::Control.instance.init_plugin :dispatcher => :delayed_job, :dispatcher_instance_id => dispatcher_instance_id
|
38
|
+
else
|
39
|
+
NewRelic::Agent.logger.warn("Did not find a Delayed::Job class responding to invoke_job, aborting DJ instrumentation")
|
40
|
+
end
|
31
41
|
end
|
32
|
-
end
|
33
|
-
end
|
34
42
|
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
39
|
-
|
40
|
-
|
41
|
-
|
42
|
-
|
43
|
-
|
44
|
-
|
43
|
+
alias initialize_without_new_relic initialize
|
44
|
+
alias initialize initialize_with_new_relic
|
45
|
+
|
46
|
+
def install_newrelic_job_tracer
|
47
|
+
Delayed::Job.class_eval do
|
48
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
49
|
+
if self.instance_methods.include?('name') || self.instance_methods.include?(:name)
|
50
|
+
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob', :path => '#{self.name}'
|
51
|
+
else
|
52
|
+
add_transaction_tracer "invoke_job", :category => 'OtherTransaction/DelayedJob'
|
53
|
+
end
|
54
|
+
end
|
45
55
|
end
|
46
56
|
end
|
47
57
|
end
|
48
58
|
end
|
49
|
-
|
@@ -0,0 +1,46 @@
|
|
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 :httpclient
|
7
|
+
|
8
|
+
HTTPCLIENT_MIN_VERSION = '2.2.0'
|
9
|
+
|
10
|
+
depends_on do
|
11
|
+
defined?(HTTPClient) && defined?(HTTPClient::VERSION)
|
12
|
+
end
|
13
|
+
|
14
|
+
depends_on do
|
15
|
+
minimum_supported_version = NewRelic::VersionNumber.new(HTTPCLIENT_MIN_VERSION)
|
16
|
+
current_version = NewRelic::VersionNumber.new(HTTPClient::VERSION)
|
17
|
+
|
18
|
+
current_version >= minimum_supported_version
|
19
|
+
end
|
20
|
+
|
21
|
+
executes do
|
22
|
+
::NewRelic::Agent.logger.info 'Installing HTTPClient instrumentation'
|
23
|
+
require 'new_relic/agent/cross_app_tracing'
|
24
|
+
require 'new_relic/agent/http_clients/httpclient_wrappers'
|
25
|
+
end
|
26
|
+
|
27
|
+
executes do
|
28
|
+
class HTTPClient
|
29
|
+
def do_get_block_with_newrelic(req, proxy, conn, &block)
|
30
|
+
wrapped_request = NewRelic::Agent::HTTPClients::HTTPClientRequest.new(req)
|
31
|
+
|
32
|
+
response = nil
|
33
|
+
::NewRelic::Agent::CrossAppTracing.trace_http_request(wrapped_request) do
|
34
|
+
do_get_block_without_newrelic(req, proxy, conn, &block)
|
35
|
+
response = conn.pop
|
36
|
+
conn.push response
|
37
|
+
::NewRelic::Agent::HTTPClients::HTTPClientResponse.new(response)
|
38
|
+
end
|
39
|
+
response
|
40
|
+
end
|
41
|
+
|
42
|
+
alias do_get_block_without_newrelic do_get_block
|
43
|
+
alias do_get_block do_get_block_with_newrelic
|
44
|
+
end
|
45
|
+
end
|
46
|
+
end
|
@@ -6,15 +6,15 @@ require 'set'
|
|
6
6
|
|
7
7
|
DependencyDetection.defer do
|
8
8
|
@name = :merb_controller
|
9
|
-
|
9
|
+
|
10
10
|
depends_on do
|
11
11
|
defined?(Merb) && defined?(Merb::Controller)
|
12
12
|
end
|
13
|
-
|
13
|
+
|
14
14
|
executes do
|
15
15
|
::NewRelic::Agent.logger.info 'Installing Merb Controller instrumentation'
|
16
16
|
end
|
17
|
-
|
17
|
+
|
18
18
|
executes do
|
19
19
|
require 'merb-core/controller/merb_controller'
|
20
20
|
|