newrelic_rpm 3.9.1.236 → 3.9.2.239
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +2 -4
- data/CHANGELOG +96 -2
- data/lib/new_relic/agent.rb +47 -4
- data/lib/new_relic/agent/agent.rb +51 -26
- data/lib/new_relic/agent/agent_logger.rb +4 -0
- data/lib/new_relic/agent/configuration.rb +2 -32
- data/lib/new_relic/agent/configuration/default_source.rb +153 -118
- data/lib/new_relic/agent/configuration/dotted_hash.rb +52 -0
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
- data/lib/new_relic/agent/configuration/manager.rb +101 -2
- data/lib/new_relic/agent/configuration/manual_source.rb +17 -0
- data/lib/new_relic/agent/configuration/server_source.rb +12 -4
- data/lib/new_relic/agent/configuration/yaml_source.rb +46 -22
- data/lib/new_relic/agent/cross_app_monitor.rb +1 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +1 -1
- data/lib/new_relic/agent/database/obfuscation_helpers.rb +55 -14
- data/lib/new_relic/agent/database/obfuscator.rb +22 -7
- data/lib/new_relic/agent/database/postgres_explain_obfuscator.rb +6 -8
- data/lib/new_relic/agent/error_collector.rb +24 -16
- data/lib/new_relic/agent/event_loop.rb +189 -0
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +8 -17
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +17 -16
- data/lib/new_relic/agent/instrumentation/ignore_actions.rb +41 -0
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -11
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +0 -8
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +1 -9
- data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -18
- data/lib/new_relic/agent/instrumentation/rubyprof.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sinatra.rb +12 -1
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -1
- data/lib/new_relic/agent/method_tracer.rb +33 -39
- data/lib/new_relic/agent/new_relic_service.rb +35 -156
- data/lib/new_relic/agent/new_relic_service/encoders.rb +34 -0
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +50 -0
- data/lib/new_relic/agent/new_relic_service/marshaller.rb +52 -0
- data/lib/new_relic/agent/new_relic_service/pruby_marshaller.rb +52 -0
- data/lib/new_relic/agent/threading/backtrace_node.rb +1 -1
- data/lib/new_relic/agent/traced_method_stack.rb +16 -2
- data/lib/new_relic/agent/transaction.rb +0 -4
- data/lib/new_relic/collection_helper.rb +2 -2
- data/lib/new_relic/control/frameworks/rails.rb +3 -0
- data/lib/new_relic/control/instrumentation.rb +6 -2
- data/lib/new_relic/json_wrapper.rb +47 -25
- data/lib/new_relic/language_support.rb +0 -4
- data/lib/new_relic/latest_changes.rb +2 -2
- data/lib/new_relic/rack/developer_mode.rb +4 -3
- data/lib/new_relic/recipes/capistrano3.rb +2 -2
- data/lib/new_relic/recipes/capistrano_legacy.rb +1 -1
- data/lib/new_relic/timer_lib.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/tasks/config.html.erb +28 -0
- data/lib/tasks/config.rake +134 -0
- data/lib/tasks/config.text.erb +7 -0
- data/lib/tasks/install.rake +0 -63
- data/newrelic.yml +7 -0
- data/test/active_record_fixtures.rb +4 -4
- data/test/agent_helper.rb +58 -18
- data/test/environments/lib/environments/runner.rb +1 -1
- data/test/environments/rails21/Gemfile +1 -1
- data/test/environments/rails21/config/boot.rb +1 -1
- data/test/environments/rails22/Gemfile +1 -1
- data/test/environments/rails22/config/boot.rb +1 -1
- data/test/environments/rails23/config/boot.rb +2 -2
- 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/fixtures/cross_agent_tests/labels.json +104 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/README.md +23 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/back_quoted_identifiers.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/comment_delimiters_in_strings.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/double_quoted_identifiers.postgres.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.obfuscated +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comment_in_string.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_line_comments_with_quotes.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_cstyle.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.obfuscated +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_doubledash.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/end_of_query_comment_hash.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/escape_string_constants.postgres.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_double_quoted_string.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/malformed/unterminated_single_quoted_string.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_comments_and_quotes.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_comments_and_newlines.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/mixed_quotes_end_of_line_comments.sql +3 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/multiple_literal_types.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numbers_in_identifiers.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/numeric_literals.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/quote_delimiters_in_comments.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_double_quoted.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_single_quoted.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_backslash_and_twin_single_quotes.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_double_quote.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_newline.sql +2 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_embedded_single_quote.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_escaped_quotes.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_backslash.sql +4 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash.mysql.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_backslash_single_quoted.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_trailing_escaped_quote.sql +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.obfuscated +1 -0
- data/test/fixtures/cross_agent_tests/sql_obfuscation/string_with_twin_single_quotes.sql +1 -0
- data/test/multiverse/lib/multiverse/output_collector.rb +1 -1
- data/test/multiverse/lib/multiverse/runner.rb +1 -1
- data/test/multiverse/lib/multiverse/suite.rb +19 -4
- data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -38
- data/test/multiverse/suites/agent_only/collector_exception_handling_test.rb +25 -35
- data/test/multiverse/suites/agent_only/config/newrelic.yml +2 -0
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +1 -0
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +1 -1
- data/test/multiverse/suites/agent_only/keepalive_test.rb +29 -0
- data/test/multiverse/suites/agent_only/labels_test.rb +89 -0
- data/test/multiverse/suites/agent_only/marshaling_test.rb +1 -3
- data/test/multiverse/suites/agent_only/service_timeout_test.rb +1 -1
- data/test/multiverse/suites/agent_only/start_up_test.rb +9 -1
- data/test/multiverse/suites/capistrano/config/deploy.rb +6 -2
- data/test/multiverse/suites/capistrano/deployment_test.rb +12 -4
- data/test/multiverse/suites/config_file_loading/config_file_loading_test.rb +29 -1
- data/test/multiverse/suites/curb/Envfile +6 -2
- data/test/multiverse/suites/datamapper/Envfile +0 -4
- data/test/multiverse/suites/deferred_instrumentation/Envfile +0 -4
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +1 -1
- data/test/multiverse/suites/excon/Envfile +5 -4
- data/test/multiverse/suites/excon/excon_test.rb +1 -1
- data/test/multiverse/suites/httpclient/Envfile +0 -4
- data/test/multiverse/suites/marshalling/Envfile +12 -0
- data/test/multiverse/suites/marshalling/config/newrelic.yml +20 -0
- data/test/multiverse/suites/marshalling/marshalling_test.rb +60 -0
- data/test/multiverse/suites/mongo/helpers/mongo_operation_tests.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_replica_set.rb +1 -1
- data/test/multiverse/suites/mongo/helpers/mongo_server.rb +4 -4
- data/test/multiverse/suites/padrino/Envfile +0 -5
- data/test/multiverse/suites/padrino/padrino_test.rb +1 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +2 -1
- data/test/multiverse/suites/rails/ignore_test.rb +22 -0
- data/test/multiverse/suites/rails/rails2_app/config/boot.rb +2 -2
- data/test/multiverse/suites/rails/rails2_app/config/routes.rb +1 -0
- data/test/multiverse/suites/resque/Envfile +0 -4
- data/test/multiverse/suites/sequel/Envfile +0 -5
- data/test/multiverse/suites/sinatra/sinatra_classic_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_modular_test.rb +1 -1
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +22 -0
- data/test/multiverse/suites/typhoeus/Envfile +1 -4
- data/test/new_relic/agent/agent/start_worker_thread_test.rb +1 -13
- data/test/new_relic/agent/agent_logger_test.rb +11 -0
- data/test/new_relic/agent/agent_test.rb +43 -20
- data/test/new_relic/agent/audit_logger_test.rb +7 -3
- data/test/new_relic/agent/commands/thread_profiler_session_test.rb +0 -1
- data/test/new_relic/agent/commands/xray_session_collection_test.rb +1 -1
- data/test/new_relic/agent/configuration/dotted_hash_test.rb +53 -0
- data/test/new_relic/agent/configuration/manager_test.rb +99 -6
- data/test/new_relic/agent/configuration/manual_source_test.rb +18 -0
- data/test/new_relic/agent/configuration/orphan_configuration_test.rb +1 -1
- data/test/new_relic/agent/configuration/yaml_source_test.rb +8 -4
- data/test/new_relic/agent/database/sql_obfuscation_test.rb +76 -0
- data/test/new_relic/agent/database_test.rb +2 -38
- data/test/new_relic/agent/error_collector/notice_error_test.rb +21 -3
- data/test/new_relic/agent/error_collector_test.rb +15 -2
- data/test/new_relic/agent/event_loop_test.rb +202 -0
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +4 -0
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +283 -182
- data/test/new_relic/agent/method_tracer_test.rb +1 -2
- data/test/new_relic/agent/new_relic_service_test.rb +83 -27
- data/test/new_relic/agent/pipe_channel_manager_test.rb +6 -6
- data/test/new_relic/agent/rpm_agent_test.rb +1 -8
- data/test/new_relic/agent/sql_sampler_test.rb +10 -8
- data/test/new_relic/agent/threading/backtrace_service_test.rb +1 -1
- data/test/new_relic/agent/traced_method_stack_test.rb +45 -13
- data/test/new_relic/agent/transaction_sample_builder_test.rb +1 -2
- data/test/new_relic/agent/transaction_test.rb +3 -3
- data/test/new_relic/agent_test.rb +47 -8
- data/test/new_relic/collection_helper_test.rb +5 -5
- data/test/new_relic/control/instrumentation_test.rb +56 -0
- data/test/new_relic/control_test.rb +4 -3
- data/test/new_relic/fake_collector.rb +7 -2
- data/test/new_relic/http_client_test_cases.rb +4 -4
- data/test/new_relic/latest_changes_test.rb +3 -3
- data/test/new_relic/transaction_sample/segment_test.rb +0 -1
- data/test/new_relic/transaction_sample_test.rb +19 -2
- data/test/performance/lib/performance/runner.rb +4 -4
- data/test/performance/suites/marshalling.rb +46 -30
- data/test/performance/suites/sql_obfuscation.rb +30 -0
- data/test/test_helper.rb +1 -1
- data/ui/helpers/developer_mode_helper.rb +2 -2
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/java.rb +1 -1
- data/vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/view.rb +1 -1
- metadata +84 -3
- metadata.gz.sig +0 -0
- data/test/environments/rails23/config/environments/development.rb +0 -11
@@ -21,17 +21,6 @@ DependencyDetection.defer do
|
|
21
21
|
Merb::Controller.class_eval do
|
22
22
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
23
23
|
|
24
|
-
class_inheritable_accessor :do_not_trace
|
25
|
-
class_inheritable_accessor :ignore_apdex
|
26
|
-
|
27
|
-
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
28
|
-
self.send "#{attr_name}=", attr_name, value
|
29
|
-
end
|
30
|
-
|
31
|
-
def self.newrelic_read_attr(attr_name) # :nodoc:
|
32
|
-
self.send attr_name
|
33
|
-
end
|
34
|
-
|
35
24
|
# determine the path that is used in the metric name for
|
36
25
|
# the called controller action
|
37
26
|
def newrelic_metric_path
|
@@ -101,14 +101,6 @@ DependencyDetection.defer do
|
|
101
101
|
alias_method :perform_action, :perform_action_with_newrelic_trace
|
102
102
|
private :perform_action
|
103
103
|
|
104
|
-
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
105
|
-
write_inheritable_attribute(attr_name, value)
|
106
|
-
end
|
107
|
-
|
108
|
-
def self.newrelic_read_attr(attr_name) # :nodoc:
|
109
|
-
read_inheritable_attribute(attr_name)
|
110
|
-
end
|
111
|
-
|
112
104
|
# determine the path that is used in the metric name for
|
113
105
|
# the called controller action
|
114
106
|
def newrelic_metric_path(action_name_override = nil)
|
@@ -7,14 +7,6 @@ module NewRelic
|
|
7
7
|
module Instrumentation
|
8
8
|
module Rails3
|
9
9
|
module ActionController
|
10
|
-
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
11
|
-
write_inheritable_attribute(attr_name, value)
|
12
|
-
end
|
13
|
-
|
14
|
-
def self.newrelic_read_attr(attr_name) # :nodoc:
|
15
|
-
read_inheritable_attribute(attr_name)
|
16
|
-
end
|
17
|
-
|
18
10
|
# determine the path that is used in the metric name for
|
19
11
|
# the called controller action
|
20
12
|
def newrelic_metric_path(action_name_override = nil)
|
@@ -28,7 +20,7 @@ module NewRelic
|
|
28
20
|
|
29
21
|
def process_action(*args) #THREAD_LOCAL_ACCESS
|
30
22
|
# skip instrumentation if we are in an ignored action
|
31
|
-
if _is_filtered?(
|
23
|
+
if _is_filtered?(ControllerInstrumentation::NR_DO_NOT_TRACE_KEY)
|
32
24
|
txn = NewRelic::Agent::Transaction.tl_current
|
33
25
|
txn.ignore! if txn
|
34
26
|
NewRelic::Agent.disable_all_tracing do
|
@@ -3,23 +3,6 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
require 'new_relic/agent/instrumentation/action_controller_subscriber'
|
5
5
|
|
6
|
-
module NewRelic
|
7
|
-
module Agent
|
8
|
-
module Instrumentation
|
9
|
-
module Rails4
|
10
|
-
module ActionController
|
11
|
-
def self.newrelic_write_attr(attr_name, value) # :nodoc:
|
12
|
-
write_inheritable_attribute(attr_name, value)
|
13
|
-
end
|
14
|
-
|
15
|
-
def self.newrelic_read_attr(attr_name) # :nodoc:
|
16
|
-
read_inheritable_attribute(attr_name)
|
17
|
-
end
|
18
|
-
end
|
19
|
-
end
|
20
|
-
end
|
21
|
-
end
|
22
|
-
end
|
23
6
|
|
24
7
|
DependencyDetection.defer do
|
25
8
|
@name = :rails4_controller
|
@@ -39,7 +22,6 @@ DependencyDetection.defer do
|
|
39
22
|
executes do
|
40
23
|
class ActionController::Base
|
41
24
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
42
|
-
include NewRelic::Agent::Instrumentation::Rails4::ActionController
|
43
25
|
end
|
44
26
|
NewRelic::Agent::Instrumentation::ActionControllerSubscriber \
|
45
27
|
.subscribe(/^process_action.action_controller$/)
|
@@ -45,7 +45,7 @@ DependencyDetection.defer do
|
|
45
45
|
|
46
46
|
class Sidekiq::Extensions::DelayedClass
|
47
47
|
def newrelic_trace_args(msg, queue)
|
48
|
-
(target, method_name,
|
48
|
+
(target, method_name, _args) = YAML.load(msg['args'][0])
|
49
49
|
{
|
50
50
|
:name => method_name,
|
51
51
|
:class_name => target.name,
|
@@ -144,14 +144,25 @@ module NewRelic
|
|
144
144
|
return dispatch_without_newrelic
|
145
145
|
end
|
146
146
|
|
147
|
+
request_params = get_request_params
|
148
|
+
|
147
149
|
name = TransactionNamer.initial_transaction_name(request)
|
148
150
|
perform_action_with_newrelic_trace(:category => :sinatra,
|
149
151
|
:name => name,
|
150
|
-
:params =>
|
152
|
+
:params => request_params) do
|
151
153
|
dispatch_and_notice_errors_with_newrelic
|
152
154
|
end
|
153
155
|
end
|
154
156
|
|
157
|
+
def get_request_params
|
158
|
+
begin
|
159
|
+
@request.params
|
160
|
+
rescue => e
|
161
|
+
NewRelic::Agent.logger.debug("Failed to get params from Rack request.", e)
|
162
|
+
nil
|
163
|
+
end
|
164
|
+
end
|
165
|
+
|
155
166
|
def dispatch_and_notice_errors_with_newrelic
|
156
167
|
dispatch_without_newrelic
|
157
168
|
ensure
|
@@ -380,30 +380,18 @@ module NewRelic
|
|
380
380
|
end
|
381
381
|
include AddMethodTracer
|
382
382
|
|
383
|
-
|
384
|
-
|
385
383
|
# Add a method tracer to the specified method.
|
386
384
|
#
|
387
|
-
#
|
388
|
-
#
|
389
|
-
#
|
390
|
-
#
|
391
|
-
# pie charts.
|
392
|
-
# * <tt>:metric => false</tt> specifies that no metric will be recorded.
|
393
|
-
# Instead the call will show up in transaction traces as well as traces
|
394
|
-
# shown in Developer Mode.
|
395
|
-
#
|
396
|
-
# === Uncommon Options
|
397
|
-
#
|
398
|
-
# * <tt>:code_header</tt> and <tt>:code_footer</tt> specify ruby code that
|
399
|
-
# is inserted into the tracer before and after the call.
|
385
|
+
# By default, this will cause invocations of the traced method to be
|
386
|
+
# recorded in transaction traces, and in a metric named after the class
|
387
|
+
# and method. It will also make the method show up in transaction-level
|
388
|
+
# breakdown charts and tables.
|
400
389
|
#
|
401
390
|
# === Overriding the metric name
|
402
391
|
#
|
403
|
-
# +metric_name_code+ is a string that is eval'd to get the
|
404
|
-
#
|
405
|
-
#
|
406
|
-
# the value like this:
|
392
|
+
# +metric_name_code+ is a string that is eval'd to get the name of the
|
393
|
+
# metric associated with the call, so if you want to use interpolation
|
394
|
+
# evaluated at call time, then single quote the value like this:
|
407
395
|
#
|
408
396
|
# add_method_tracer :foo, 'Custom/#{self.class.name}/foo'
|
409
397
|
#
|
@@ -412,30 +400,36 @@ module NewRelic
|
|
412
400
|
#
|
413
401
|
# If not provided, the metric name will be <tt>Custom/ClassName/method_name</tt>.
|
414
402
|
#
|
415
|
-
#
|
416
|
-
#
|
417
|
-
#
|
418
|
-
#
|
419
|
-
#
|
420
|
-
#
|
421
|
-
#
|
422
|
-
#
|
423
|
-
#
|
424
|
-
#
|
425
|
-
#
|
426
|
-
#
|
427
|
-
#
|
428
|
-
#
|
403
|
+
# @param [Symbol] method_name the name of the method to trace
|
404
|
+
# @param [String] metric_name_code the metric name to record calls to
|
405
|
+
# the traced method under. This may be either a static string, or Ruby
|
406
|
+
# code to be evaluated at call-time in order to determine the metric
|
407
|
+
# name dynamically.
|
408
|
+
# @param [Hash] options additional options controlling how the method is
|
409
|
+
# traced.
|
410
|
+
# @option options [Boolean] :push_scope (true) If false, the traced method will
|
411
|
+
# not appear in transaction traces or breakdown charts, and it will
|
412
|
+
# only be visible in custom dashboards.
|
413
|
+
# @option options [Boolean] :metric (true) If false, the traced method will
|
414
|
+
# only appear in transaction traces, but no metrics will be recorded
|
415
|
+
# for it.
|
416
|
+
# @option options [String] :code_header ('') Ruby code to be inserted and run
|
417
|
+
# before the tracer begins timing.
|
418
|
+
# @option options [String] :code_footer ('') Ruby code to be inserted and run
|
419
|
+
# after the tracer stops timing.
|
429
420
|
#
|
430
|
-
#
|
421
|
+
# @example
|
422
|
+
# add_method_tracer :foo
|
431
423
|
#
|
432
|
-
#
|
424
|
+
# # With a custom metric name
|
425
|
+
# add_method_tracer :foo, 'Custom/#{self.class.name}/foo'
|
433
426
|
#
|
434
|
-
# Instrument
|
427
|
+
# # Instrument foo only for custom dashboards (not in transaction
|
428
|
+
# # traces or breakdown charts)
|
429
|
+
# add_method_tracer :foo, 'Custom/foo', :push_scope => false
|
435
430
|
#
|
436
|
-
#
|
437
|
-
#
|
438
|
-
# end
|
431
|
+
# # Instrument foo in transaction traces only
|
432
|
+
# add_method_tracer :foo, 'Custom/foo', :metric => false
|
439
433
|
#
|
440
434
|
# @api public
|
441
435
|
#
|
@@ -4,6 +4,10 @@
|
|
4
4
|
|
5
5
|
require 'zlib'
|
6
6
|
require 'new_relic/agent/audit_logger'
|
7
|
+
require 'new_relic/agent/new_relic_service/encoders'
|
8
|
+
require 'new_relic/agent/new_relic_service/marshaller'
|
9
|
+
require 'new_relic/agent/new_relic_service/json_marshaller'
|
10
|
+
require 'new_relic/agent/new_relic_service/pruby_marshaller'
|
7
11
|
|
8
12
|
module NewRelic
|
9
13
|
module Agent
|
@@ -46,12 +50,12 @@ module NewRelic
|
|
46
50
|
Agent.config.register_callback(:marshaller) do |marshaller|
|
47
51
|
begin
|
48
52
|
if marshaller == 'json'
|
49
|
-
require 'json'
|
50
53
|
@marshaller = JsonMarshaller.new
|
51
54
|
else
|
52
55
|
@marshaller = PrubyMarshaller.new
|
53
56
|
end
|
54
57
|
rescue LoadError
|
58
|
+
::NewRelic::Agent.logger.warn("JSON marshaller requested, but the 'json' gem was not available, falling back to pruby. This will not be supported in future versions of the agent.")
|
55
59
|
@marshaller = PrubyMarshaller.new
|
56
60
|
end
|
57
61
|
end
|
@@ -181,28 +185,42 @@ module NewRelic
|
|
181
185
|
def session(&block)
|
182
186
|
raise ArgumentError, "#{self.class}#shared_connection must be passed a block" unless block_given?
|
183
187
|
|
184
|
-
# Immediately open a TCP connection to the server and leave it open for
|
185
|
-
# multiple requests.
|
186
188
|
begin
|
187
189
|
t0 = Time.now
|
188
|
-
|
189
|
-
|
190
|
-
|
190
|
+
if NewRelic::Agent.config[:aggressive_keepalive]
|
191
|
+
session_with_keepalive(&block)
|
192
|
+
else
|
193
|
+
session_without_keepalive(&block)
|
194
|
+
end
|
191
195
|
rescue Timeout::Error
|
192
196
|
elapsed = Time.now - t0
|
193
197
|
::NewRelic::Agent.logger.warn "Timed out opening connection to collector after #{elapsed} seconds. If this problem persists, please see http://status.newrelic.com"
|
194
198
|
raise
|
199
|
+
end
|
200
|
+
end
|
201
|
+
|
202
|
+
def session_with_keepalive(&block)
|
203
|
+
establish_shared_connection
|
204
|
+
block.call
|
205
|
+
end
|
206
|
+
|
207
|
+
def session_without_keepalive(&block)
|
208
|
+
begin
|
209
|
+
establish_shared_connection
|
210
|
+
block.call
|
195
211
|
ensure
|
196
|
-
@in_session = false
|
197
212
|
close_shared_connection
|
198
213
|
end
|
199
214
|
end
|
200
215
|
|
201
216
|
def establish_shared_connection
|
202
|
-
|
203
|
-
|
204
|
-
|
205
|
-
|
217
|
+
unless @shared_tcp_connection
|
218
|
+
connection = create_http_connection
|
219
|
+
NewRelic::Agent.logger.debug("Opening shared TCP connection to #{connection.address}:#{connection.port}")
|
220
|
+
NewRelic::TimerLib.timeout(@request_timeout) { connection.start }
|
221
|
+
@shared_tcp_connection = connection
|
222
|
+
end
|
223
|
+
@shared_tcp_connection
|
206
224
|
end
|
207
225
|
|
208
226
|
def close_shared_connection
|
@@ -217,9 +235,7 @@ module NewRelic
|
|
217
235
|
# We'll reuse the same handle for cases where we're using keep-alive, or
|
218
236
|
# otherwise create a new one.
|
219
237
|
def http_connection
|
220
|
-
|
221
|
-
(@in_session && establish_shared_connection) ||
|
222
|
-
create_http_connection)
|
238
|
+
@shared_tcp_connection || create_http_connection
|
223
239
|
end
|
224
240
|
|
225
241
|
# Return the Net::HTTP with proxy configuration given the NewRelic::Control::Server object.
|
@@ -244,6 +260,11 @@ module NewRelic
|
|
244
260
|
raise UnrecoverableAgentException.new(msg)
|
245
261
|
end
|
246
262
|
end
|
263
|
+
|
264
|
+
if http.respond_to?(:keep_alive_timeout) && NewRelic::Agent.config[:aggressive_keepalive]
|
265
|
+
http.keep_alive_timeout = NewRelic::Agent.config[:keep_alive_timeout]
|
266
|
+
end
|
267
|
+
|
247
268
|
::NewRelic::Agent.logger.debug("Created net/http handle to #{http.address}:#{http.port}")
|
248
269
|
http
|
249
270
|
end
|
@@ -419,150 +440,8 @@ module NewRelic
|
|
419
440
|
"NewRelic-RubyAgent/#{NewRelic::VERSION::STRING} #{ruby_description}#{zlib_version}"
|
420
441
|
end
|
421
442
|
|
422
|
-
module Encoders
|
423
|
-
module Identity
|
424
|
-
def self.encode(data)
|
425
|
-
data
|
426
|
-
end
|
427
|
-
end
|
428
|
-
|
429
|
-
module Compressed
|
430
|
-
def self.encode(data)
|
431
|
-
Zlib::Deflate.deflate(data, Zlib::DEFAULT_COMPRESSION)
|
432
|
-
end
|
433
|
-
end
|
434
|
-
|
435
|
-
module Base64CompressedJSON
|
436
|
-
def self.encode(data)
|
437
|
-
json = ::NewRelic::JSONWrapper.dump(data,
|
438
|
-
:normalize => Agent.config[:normalize_json_string_encodings])
|
439
|
-
Base64.encode64(Compressed.encode(json))
|
440
|
-
end
|
441
|
-
end
|
442
|
-
end
|
443
|
-
|
444
443
|
# Used to wrap errors reported to agent by the collector
|
445
444
|
class CollectorError < StandardError; end
|
446
|
-
|
447
|
-
class Marshaller
|
448
|
-
def parsed_error(error)
|
449
|
-
error_class = error['error_type'].split('::') \
|
450
|
-
.inject(Module) {|mod,const| mod.const_get(const) }
|
451
|
-
error_class.new(error['message'])
|
452
|
-
rescue NameError
|
453
|
-
CollectorError.new("#{error['error_type']}: #{error['message']}")
|
454
|
-
end
|
455
|
-
|
456
|
-
def prepare(data, options={})
|
457
|
-
encoder = options[:encoder] || default_encoder
|
458
|
-
if data.respond_to?(:to_collector_array)
|
459
|
-
data.to_collector_array(encoder)
|
460
|
-
elsif data.kind_of?(Array)
|
461
|
-
data.map { |element| prepare(element, options) }
|
462
|
-
else
|
463
|
-
data
|
464
|
-
end
|
465
|
-
end
|
466
|
-
|
467
|
-
def default_encoder
|
468
|
-
Encoders::Identity
|
469
|
-
end
|
470
|
-
|
471
|
-
def self.human_readable?
|
472
|
-
false
|
473
|
-
end
|
474
|
-
|
475
|
-
protected
|
476
|
-
|
477
|
-
def return_value(data)
|
478
|
-
if data.respond_to?(:has_key?)
|
479
|
-
if data.has_key?('exception')
|
480
|
-
raise parsed_error(data['exception'])
|
481
|
-
elsif data.has_key?('return_value')
|
482
|
-
return data['return_value']
|
483
|
-
end
|
484
|
-
end
|
485
|
-
::NewRelic::Agent.logger.debug("Unexpected response from collector: #{data}")
|
486
|
-
nil
|
487
|
-
end
|
488
|
-
end
|
489
|
-
|
490
|
-
# Primitive Ruby Object Notation which complies JSON format data strutures
|
491
|
-
class PrubyMarshaller < Marshaller
|
492
|
-
def initialize
|
493
|
-
::NewRelic::Agent.logger.debug 'Using Pruby marshaller'
|
494
|
-
warn_for_pruby_deprecation
|
495
|
-
end
|
496
|
-
|
497
|
-
def warn_for_pruby_deprecation
|
498
|
-
if !NewRelic::LanguageSupport.stdlib_json_usable? && !defined?(::JSON)
|
499
|
-
NewRelic::Agent.logger.warn("Upcoming versions of the Ruby agent running on Ruby 1.8.7 will require the 'json' gem. To avoid interuption in reporting, please update your Gemfile. See http://docs.newrelic.com/docs/ruby/ruby-1.8.7-support for more information.")
|
500
|
-
end
|
501
|
-
end
|
502
|
-
|
503
|
-
def dump(ruby, opts={})
|
504
|
-
NewRelic::LanguageSupport.with_cautious_gc do
|
505
|
-
Marshal.dump(prepare(ruby, opts))
|
506
|
-
end
|
507
|
-
rescue => e
|
508
|
-
::NewRelic::Agent.logger.debug("#{e.class.name} : #{e.message} when marshalling #{ruby.inspect}")
|
509
|
-
raise
|
510
|
-
end
|
511
|
-
|
512
|
-
def load(data)
|
513
|
-
return unless data && data != ''
|
514
|
-
NewRelic::LanguageSupport.with_cautious_gc do
|
515
|
-
return_value(Marshal.load(data))
|
516
|
-
end
|
517
|
-
rescue
|
518
|
-
::NewRelic::Agent.logger.debug "Error encountered loading collector response: #{data}"
|
519
|
-
raise
|
520
|
-
end
|
521
|
-
|
522
|
-
def format
|
523
|
-
'pruby'
|
524
|
-
end
|
525
|
-
|
526
|
-
def self.is_supported?
|
527
|
-
true
|
528
|
-
end
|
529
|
-
end
|
530
|
-
|
531
|
-
# Marshal collector protocol with JSON when available
|
532
|
-
class JsonMarshaller < Marshaller
|
533
|
-
def initialize
|
534
|
-
::NewRelic::Agent.logger.debug 'Using JSON marshaller'
|
535
|
-
end
|
536
|
-
|
537
|
-
def dump(ruby, opts={})
|
538
|
-
prepared = prepare(ruby, opts)
|
539
|
-
NewRelic::JSONWrapper.dump(prepared,
|
540
|
-
:normalize => Agent.config[:normalize_json_string_encodings])
|
541
|
-
end
|
542
|
-
|
543
|
-
def load(data)
|
544
|
-
return_value(NewRelic::JSONWrapper.load(data)) if data && data != ''
|
545
|
-
rescue => e
|
546
|
-
::NewRelic::Agent.logger.debug "#{e.class.name} : #{e.message} encountered loading collector response: #{data}"
|
547
|
-
raise
|
548
|
-
end
|
549
|
-
|
550
|
-
def default_encoder
|
551
|
-
Encoders::Base64CompressedJSON
|
552
|
-
end
|
553
|
-
|
554
|
-
def format
|
555
|
-
'json'
|
556
|
-
end
|
557
|
-
|
558
|
-
def self.is_supported?
|
559
|
-
NewRelic::JSONWrapper.usable_for_collector_serialization?
|
560
|
-
end
|
561
|
-
|
562
|
-
def self.human_readable?
|
563
|
-
true # for some definitions of 'human'
|
564
|
-
end
|
565
|
-
end
|
566
445
|
end
|
567
446
|
end
|
568
447
|
end
|