newrelic_rpm 3.18.1.330 → 4.0.0.332
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +2 -74
- data/CHANGELOG.md +77 -0
- data/CONTRIBUTING.md +14 -6
- data/LICENSE +1 -88
- data/lib/new_relic/agent.rb +2 -103
- data/lib/new_relic/agent/agent.rb +3 -32
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +2 -6
- data/lib/new_relic/agent/configuration/default_source.rb +1 -8
- data/lib/new_relic/agent/configuration/yaml_source.rb +1 -12
- data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
- data/lib/new_relic/agent/cross_app_tracing.rb +4 -2
- data/lib/new_relic/agent/datastores/mongo.rb +1 -1
- data/lib/new_relic/agent/datastores/redis.rb +1 -1
- data/lib/new_relic/agent/encoding_normalizer.rb +1 -20
- data/lib/new_relic/agent/error_collector.rb +8 -21
- data/lib/new_relic/agent/inbound_request_monitor.rb +4 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +14 -30
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +4 -5
- data/lib/new_relic/agent/instrumentation/curb.rb +2 -2
- data/lib/new_relic/agent/instrumentation/excon.rb +3 -3
- data/lib/new_relic/agent/instrumentation/grape.rb +3 -3
- data/lib/new_relic/agent/instrumentation/httpclient.rb +2 -2
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -2
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +3 -7
- data/lib/new_relic/agent/instrumentation/queue_time.rb +13 -15
- data/lib/new_relic/agent/instrumentation/rack.rb +4 -50
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -2
- data/lib/new_relic/agent/instrumentation/sinatra.rb +0 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +2 -2
- data/lib/new_relic/agent/javascript_instrumentor.rb +3 -2
- data/lib/new_relic/agent/method_tracer.rb +1 -60
- data/lib/new_relic/agent/new_relic_service.rb +3 -2
- data/lib/new_relic/agent/new_relic_service/encoders.rb +5 -6
- data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +7 -16
- data/lib/new_relic/agent/pipe_channel_manager.rb +1 -3
- data/lib/new_relic/agent/pipe_service.rb +1 -3
- data/lib/new_relic/agent/rules_engine.rb +2 -17
- data/lib/new_relic/agent/stats_engine.rb +0 -2
- data/lib/new_relic/agent/stats_engine/metric_stats.rb +0 -48
- data/lib/new_relic/agent/supported_versions.rb +12 -19
- data/lib/new_relic/agent/threading/backtrace_service.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +0 -3
- data/lib/new_relic/agent/transaction/attributes.rb +1 -10
- data/lib/new_relic/agent/vm.rb +1 -4
- data/lib/new_relic/agent/vm/jruby_vm.rb +1 -3
- data/lib/new_relic/agent/vm/mri_vm.rb +2 -10
- data/lib/new_relic/control.rb +1 -2
- data/lib/new_relic/control/frameworks/rails.rb +1 -1
- data/lib/new_relic/control/frameworks/rails3.rb +1 -2
- data/lib/new_relic/control/frameworks/rails4.rb +1 -1
- data/lib/new_relic/control/frameworks/rails5.rb +1 -1
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/{vendor/gems/dependency_detection-0.0.1.build/lib → lib/new_relic}/dependency_detection.rb +0 -1
- data/lib/new_relic/helper.rb +6 -13
- data/lib/new_relic/language_support.rb +44 -139
- data/lib/new_relic/metric_spec.rb +0 -17
- data/lib/new_relic/noticed_error.rb +18 -27
- data/lib/new_relic/version.rb +3 -48
- data/lib/tasks/versions.rake +7 -5
- data/newrelic_rpm.gemspec +1 -16
- data/test/agent_helper.rb +4 -2
- data/test/environments/lib/environments/runner.rb +5 -14
- data/test/environments/norails/Gemfile +0 -8
- data/test/environments/rails21/Gemfile +0 -8
- data/test/environments/rails21/config/database.yml +1 -1
- data/test/environments/rails22/Gemfile +0 -8
- data/test/environments/rails22/config/database.yml +1 -1
- data/test/environments/rails23/Gemfile +1 -7
- data/test/environments/rails23/config/database.yml +1 -1
- data/test/environments/rails30/Gemfile +0 -1
- data/test/environments/rails30/config/database.yml +1 -1
- data/test/environments/rails31/Gemfile +0 -3
- data/test/environments/rails31/config/database.yml +1 -1
- data/test/environments/rails32/Gemfile +0 -3
- data/test/environments/rails32/config/database.yml +1 -1
- data/test/environments/rails40/Gemfile +0 -26
- data/test/environments/rails40/config/database.yml +1 -1
- data/test/environments/rails41/Gemfile +0 -18
- data/test/environments/rails41/config/database.yml +1 -1
- data/test/environments/rails42/Gemfile +0 -22
- data/test/environments/rails42/config/database.yml +1 -1
- data/test/environments/rails50/Gemfile +0 -13
- data/test/environments/rails50/config/database.yml +1 -1
- data/test/helpers/logging.rb +37 -0
- data/test/helpers/minitest.rb +50 -0
- data/test/helpers/misc.rb +87 -0
- data/test/helpers/transaction_sample.rb +44 -0
- data/test/multiverse/lib/multiverse/suite.rb +6 -91
- data/test/multiverse/script/runner +1 -1
- data/test/multiverse/suites/active_record/Envfile +1 -28
- data/test/multiverse/suites/active_record/active_record_test.rb +6 -6
- data/test/multiverse/suites/active_record/config/database.rb +2 -3
- data/test/multiverse/suites/active_record/config/database.yml +0 -2
- data/test/multiverse/suites/activemerchant/Envfile +4 -18
- data/test/multiverse/suites/agent_only/encoding_handling_test.rb +7 -15
- data/test/multiverse/suites/agent_only/error_events_test.rb +1 -7
- data/test/multiverse/suites/agent_only/harvest_timestamps_test.rb +4 -20
- data/test/multiverse/suites/agent_only/labels_test.rb +1 -1
- data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -10
- data/test/multiverse/suites/agent_only/script/public_api_when_disabled.rb +0 -11
- data/test/multiverse/suites/agent_only/start_up_test.rb +3 -3
- data/test/multiverse/suites/agent_only/synthetics_test.rb +1 -1
- data/test/multiverse/suites/agent_only/thread_profiling_test.rb +0 -3
- data/test/multiverse/suites/agent_only/xray_sessions_test.rb +0 -3
- data/test/multiverse/suites/capistrano/Envfile +2 -4
- data/test/multiverse/suites/capistrano2/Envfile +0 -4
- data/test/multiverse/suites/curb/Envfile +3 -7
- data/test/multiverse/suites/datamapper/Envfile +2 -2
- data/test/multiverse/suites/datamapper/datamapper_test.rb +2 -2
- data/test/multiverse/suites/deferred_instrumentation/sinatra_test.rb +0 -1
- data/test/multiverse/suites/delayed_job/Envfile +28 -41
- data/test/multiverse/suites/excon/Envfile +0 -3
- data/test/multiverse/suites/grape/Envfile +0 -4
- data/test/multiverse/suites/grape/grape_versioning_test.rb +2 -2
- data/test/multiverse/suites/grape/grape_versioning_test_api.rb +2 -2
- data/test/multiverse/suites/json/Envfile +1 -9
- data/test/multiverse/suites/marshalling/Envfile +0 -9
- data/test/multiverse/suites/memcached/Envfile +5 -23
- data/test/multiverse/suites/mongo/Envfile +9 -11
- data/test/multiverse/suites/padrino/Envfile +0 -6
- data/test/multiverse/suites/rack/http_response_code_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_auto_instrumentation_test.rb +5 -10
- data/test/multiverse/suites/rack/rack_cascade_test.rb +0 -1
- data/test/multiverse/suites/rack/rack_env_mutation_test.rb +0 -1
- data/test/multiverse/suites/rack/response_content_type_test.rb +0 -1
- data/test/multiverse/suites/rails/Envfile +1 -19
- data/test/multiverse/suites/rails/activejob_test.rb +1 -2
- data/test/multiverse/suites/rails/error_tracing_test.rb +0 -13
- data/test/multiverse/suites/rails/gc_instrumentation_test.rb +12 -32
- data/test/multiverse/suites/rake/Envfile +15 -22
- data/test/multiverse/suites/redis/redis_instrumentation_test.rb +1 -1
- data/test/multiverse/suites/sequel/database.rb +1 -4
- data/test/multiverse/suites/sidekiq/Envfile +13 -23
- data/test/multiverse/suites/sinatra/sinatra_test_cases.rb +3 -3
- data/test/multiverse/suites/typhoeus/Envfile +0 -19
- data/test/multiverse/suites/typhoeus/typhoeus_test.rb +3 -3
- data/test/multiverse/suites/yajl/Envfile +5 -0
- data/test/multiverse/suites/yajl/yajl_test.rb +1 -3
- data/test/new_relic/agent/agent/start_test.rb +3 -3
- data/test/new_relic/agent/agent_logger_test.rb +2 -2
- data/test/new_relic/agent/agent_test.rb +2 -2
- data/test/new_relic/agent/attribute_processing_test.rb +3 -4
- data/test/new_relic/agent/audit_logger_test.rb +4 -6
- data/test/new_relic/agent/aws_info_test.rb +17 -1
- data/test/new_relic/agent/busy_calculator_test.rb +14 -16
- data/test/new_relic/agent/configuration/manager_test.rb +1 -7
- data/test/new_relic/agent/cross_app_monitor_test.rb +1 -1
- data/test/new_relic/agent/database_test.rb +2 -10
- data/test/new_relic/agent/datastores/mongo/event_formatter_test.rb +90 -93
- data/test/new_relic/agent/datastores/redis_test.rb +14 -16
- data/test/new_relic/agent/encoding_normalizer_test.rb +38 -40
- data/test/new_relic/agent/error_collector_test.rb +16 -49
- data/test/new_relic/agent/instrumentation/active_record_helper_test.rb +0 -6
- data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +1 -1
- data/test/new_relic/agent/instrumentation/mongodb_command_subscriber_test.rb +101 -103
- data/test/new_relic/agent/instrumentation/rack_test.rb +11 -14
- data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +0 -10
- data/test/new_relic/agent/javascript_instrumentor_test.rb +2 -2
- data/test/new_relic/agent/method_tracer/class_methods/add_method_tracer_test.rb +0 -10
- data/test/new_relic/agent/method_tracer_test.rb +35 -76
- data/test/new_relic/agent/new_relic_service_test.rb +86 -102
- data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -9
- data/test/new_relic/agent/pipe_service_test.rb +2 -3
- data/test/new_relic/agent/rpm_agent_test.rb +0 -4
- data/test/new_relic/agent/sampled_buffer_test.rb +2 -2
- data/test/new_relic/agent/samplers/cpu_sampler_test.rb +28 -0
- data/test/new_relic/agent/samplers/memory_sampler_test.rb +66 -0
- data/test/new_relic/agent/sized_buffer_test.rb +1 -1
- data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +2 -14
- data/test/new_relic/agent/stats_engine/metric_stats_test.rb +44 -66
- data/test/new_relic/agent/stats_test.rb +6 -8
- data/test/new_relic/agent/synthetics_event_buffer_test.rb +1 -1
- data/test/new_relic/agent/transaction/attributes_test.rb +4 -12
- data/test/new_relic/agent/transaction_test.rb +2 -10
- data/test/new_relic/agent/utilization_data_test.rb +17 -1
- data/test/new_relic/agent/vm/mri_vm_test.rb +5 -7
- data/test/new_relic/agent_test.rb +0 -43
- data/test/new_relic/coerce_test.rb +1 -3
- data/test/new_relic/fake_collector.rb +3 -3
- data/test/new_relic/fake_external_server.rb +1 -1
- data/test/new_relic/fake_server.rb +1 -1
- data/test/new_relic/http_client_test_cases.rb +3 -3
- data/test/new_relic/language_support_test.rb +6 -12
- data/test/new_relic/latest_changes_test.rb +0 -11
- data/test/new_relic/license_test.rb +3 -8
- data/test/new_relic/multiverse_helpers.rb +1 -1
- data/test/new_relic/noticed_error_test.rb +11 -7
- data/test/new_relic/rack/browser_monitoring_test.rb +1 -3
- data/test/nullverse/nullverse_helper.rb +1 -1
- data/test/performance/lib/performance.rb +1 -1
- data/test/performance/lib/performance/instrumentation/gc_stats.rb +4 -6
- data/test/performance/lib/performance/instrumentation/perf_tools.rb +1 -1
- data/test/performance/lib/performance/instrumentation/stackprof.rb +1 -1
- data/test/performance/lib/performance/platform.rb +1 -8
- data/test/performance/script/runner +1 -3
- data/test/performance/suites/active_record.rb +3 -24
- data/test/test_helper.rb +9 -216
- metadata +9 -45
- data/lib/conditional_vendored_dependency_detection.rb +0 -7
- data/lib/new_relic/agent/hash_extensions.rb +0 -41
- data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -39
- data/lib/new_relic/agent/instrumentation/rails/errors.rb +0 -51
- data/lib/new_relic/agent/instrumentation/rails3/errors.rb +0 -47
- data/lib/new_relic/agent/instrumentation/rails4/errors.rb +0 -46
- data/lib/new_relic/agent/stats_engine/samplers.rb +0 -22
- data/lib/new_relic/agent/vm/rubinius_vm.rb +0 -140
- data/lib/new_relic/json_wrapper.rb +0 -78
- data/lib/new_relic/okjson.rb +0 -602
- data/lib/new_relic/rack/error_collector.rb +0 -27
- data/lib/new_relic/timer_lib.rb +0 -31
- data/test/helpers/runtime_detection.rb +0 -17
- data/test/multiverse/suites/no_json/Envfile +0 -12
- data/test/multiverse/suites/no_json/config/newrelic.yml +0 -27
- data/test/multiverse/suites/no_json/marshal_config_test.rb +0 -22
- data/test/new_relic/agent/hash_extensions_test.rb +0 -59
- data/test/new_relic/agent/instrumentation/metric_frame_test.rb +0 -22
- data/test/new_relic/agent/stats_engine/samplers_test.rb +0 -98
- data/test/new_relic/agent/vm/rubinius_vm_test.rb +0 -69
- data/test/new_relic/json_wrapper_test.rb +0 -32
- data/test/new_relic/rack/deferred_instrumentation_test.rb +0 -33
- data/test/new_relic/rack/error_collector_test.rb +0 -83
- data/test/new_relic/version_number_test.rb +0 -101
- data/test/script/before_install/revert_rubygems.sh +0 -15
- data/test/script/before_install/update_bundler.sh +0 -12
- data/vendor/gems/dependency_detection-0.0.1.build/lib/dependency_detection/version.rb +0 -7
@@ -25,15 +25,15 @@ DependencyDetection.defer do
|
|
25
25
|
# so we could safely subscribe and not be clobbered by future subscribers,
|
26
26
|
# but alas, it does not yet.
|
27
27
|
|
28
|
-
EXCON_MIN_VERSION = ::
|
29
|
-
EXCON_MIDDLEWARE_MIN_VERSION = ::
|
28
|
+
EXCON_MIN_VERSION = Gem::Version.new("0.10.1")
|
29
|
+
EXCON_MIDDLEWARE_MIN_VERSION = Gem::Version.new("0.19.0")
|
30
30
|
|
31
31
|
depends_on do
|
32
32
|
defined?(::Excon) && defined?(::Excon::VERSION)
|
33
33
|
end
|
34
34
|
|
35
35
|
executes do
|
36
|
-
excon_version =
|
36
|
+
excon_version = Gem::Version.new(::Excon::VERSION)
|
37
37
|
if excon_version >= EXCON_MIN_VERSION
|
38
38
|
install_excon_instrumentation(excon_version)
|
39
39
|
else
|
@@ -15,7 +15,7 @@ module NewRelic
|
|
15
15
|
FORMAT_REGEX = /\(\/?\.[\:\w]*\)/.freeze # either :format (< 0.12.0) or .ext (>= 0.12.0)
|
16
16
|
VERSION_REGEX = /:version(\/|$)/.freeze
|
17
17
|
EMPTY_STRING = ''.freeze
|
18
|
-
MIN_VERSION =
|
18
|
+
MIN_VERSION = Gem::Version.new("0.2.0")
|
19
19
|
PIPE_STRING = '|'.freeze
|
20
20
|
|
21
21
|
def handle_transaction(endpoint, class_name, version)
|
@@ -30,7 +30,7 @@ module NewRelic
|
|
30
30
|
Transaction.set_default_transaction_name(txn_name, :grape, node_name)
|
31
31
|
end
|
32
32
|
|
33
|
-
if defined?(Grape::VERSION) &&
|
33
|
+
if defined?(Grape::VERSION) && Gem::Version.new(::Grape::VERSION) >= Gem::Version.new("0.16.0")
|
34
34
|
def name_for_transaction(route, class_name, version)
|
35
35
|
action_name = route.path.sub(FORMAT_REGEX, EMPTY_STRING)
|
36
36
|
method_name = route.request_method
|
@@ -86,7 +86,7 @@ DependencyDetection.defer do
|
|
86
86
|
|
87
87
|
depends_on do
|
88
88
|
defined?(::Grape::VERSION) &&
|
89
|
-
::
|
89
|
+
Gem::Version.new(::Grape::VERSION) >= ::NewRelic::Agent::Instrumentation::GrapeInstrumentation::MIN_VERSION
|
90
90
|
end
|
91
91
|
|
92
92
|
depends_on do
|
@@ -12,8 +12,8 @@ DependencyDetection.defer do
|
|
12
12
|
end
|
13
13
|
|
14
14
|
depends_on do
|
15
|
-
minimum_supported_version =
|
16
|
-
current_version =
|
15
|
+
minimum_supported_version = Gem::Version.new(HTTPCLIENT_MIN_VERSION)
|
16
|
+
current_version = Gem::Version.new(HTTPClient::VERSION)
|
17
17
|
|
18
18
|
current_version >= minimum_supported_version
|
19
19
|
end
|
@@ -12,13 +12,13 @@ module NewRelic
|
|
12
12
|
MEMCACHED = "Memcached".freeze
|
13
13
|
METHODS = [:get, :set, :add, :incr, :decr, :delete, :replace, :append, :prepend, :cas]
|
14
14
|
SEND_MULTIGET_METRIC_NAME = "get_multi_request".freeze
|
15
|
-
DATASTORE_INSTANCES_SUPPORTED_VERSION = ::
|
15
|
+
DATASTORE_INSTANCES_SUPPORTED_VERSION = Gem::Version.new '2.6.4'
|
16
16
|
SLASH = '/'.freeze
|
17
17
|
UNKNOWN = 'unknown'.freeze
|
18
18
|
LOCALHOST = 'localhost'.freeze
|
19
19
|
|
20
20
|
def supports_datastore_instances?
|
21
|
-
DATASTORE_INSTANCES_SUPPORTED_VERSION <= ::Dalli::VERSION
|
21
|
+
DATASTORE_INSTANCES_SUPPORTED_VERSION <= Gem::Version.new(::Dalli::VERSION)
|
22
22
|
end
|
23
23
|
|
24
24
|
def instrument_methods
|
@@ -15,8 +15,8 @@ module NewRelic
|
|
15
15
|
class MiddlewareProxy
|
16
16
|
include MiddlewareTracing
|
17
17
|
|
18
|
-
ANONYMOUS_CLASS = "AnonymousClass".freeze
|
19
|
-
OBJECT_CLASS_NAME = "Object".freeze
|
18
|
+
ANONYMOUS_CLASS = "AnonymousClass".freeze
|
19
|
+
OBJECT_CLASS_NAME = "Object".freeze
|
20
20
|
|
21
21
|
# This class is used to wrap classes that are passed to
|
22
22
|
# Rack::Builder#use without synchronously instantiating those classes.
|
@@ -26,7 +26,7 @@ module NewRelic
|
|
26
26
|
module Agent
|
27
27
|
module Instrumentation
|
28
28
|
module MiddlewareTracing
|
29
|
-
TXN_STARTED_KEY = 'newrelic.transaction_started'.freeze
|
29
|
+
TXN_STARTED_KEY = 'newrelic.transaction_started'.freeze
|
30
30
|
|
31
31
|
def _nr_has_middleware_tracing
|
32
32
|
true
|
@@ -56,9 +56,7 @@ module NewRelic
|
|
56
56
|
end
|
57
57
|
end
|
58
58
|
|
59
|
-
|
60
|
-
# when it is deprecated.
|
61
|
-
CONTENT_TYPE = 'Content-Type'.freeze unless defined?(CONTENT_TYPE)
|
59
|
+
CONTENT_TYPE = 'Content-Type'.freeze
|
62
60
|
|
63
61
|
def capture_response_content_type(state, result)
|
64
62
|
if result.is_a?(Array) && state.current_transaction
|
@@ -67,9 +65,7 @@ module NewRelic
|
|
67
65
|
end
|
68
66
|
end
|
69
67
|
|
70
|
-
|
71
|
-
# when it is deprecated.
|
72
|
-
CONTENT_LENGTH = 'Content-Length'.freeze unless defined?(CONTENT_LENGTH)
|
68
|
+
CONTENT_LENGTH = 'Content-Length'.freeze
|
73
69
|
|
74
70
|
def capture_response_content_length(state, result)
|
75
71
|
if result.is_a?(Array) && state.current_transaction
|
@@ -9,23 +9,21 @@ module NewRelic
|
|
9
9
|
# Record queue time metrics based on any of three headers
|
10
10
|
# which can be set on the request.
|
11
11
|
module QueueTime
|
12
|
-
|
13
|
-
|
14
|
-
|
15
|
-
|
16
|
-
|
17
|
-
|
18
|
-
|
19
|
-
EARLIEST_ACCEPTABLE_TIME = Time.at(946684800)
|
12
|
+
REQUEST_START_HEADER = 'HTTP_X_REQUEST_START'.freeze
|
13
|
+
QUEUE_START_HEADER = 'HTTP_X_QUEUE_START'.freeze
|
14
|
+
MIDDLEWARE_START_HEADER = 'HTTP_X_MIDDLEWARE_START'.freeze
|
15
|
+
ALL_QUEUE_METRIC = 'WebFrontend/QueueTime'.freeze
|
16
|
+
# any timestamps before this are thrown out and the parser
|
17
|
+
# will try again with a larger unit (2000/1/1 UTC)
|
18
|
+
EARLIEST_ACCEPTABLE_TIME = Time.at(946684800)
|
20
19
|
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
20
|
+
CANDIDATE_HEADERS = [
|
21
|
+
REQUEST_START_HEADER,
|
22
|
+
QUEUE_START_HEADER,
|
23
|
+
MIDDLEWARE_START_HEADER
|
24
|
+
].freeze
|
26
25
|
|
27
|
-
|
28
|
-
end
|
26
|
+
DIVISORS = [1_000_000, 1_000, 1]
|
29
27
|
|
30
28
|
module_function
|
31
29
|
|
@@ -7,52 +7,6 @@ require 'new_relic/agent/instrumentation/controller_instrumentation'
|
|
7
7
|
module NewRelic
|
8
8
|
module Agent
|
9
9
|
module Instrumentation
|
10
|
-
# == Instrumentation for Rack
|
11
|
-
#
|
12
|
-
# Since version 3.9.0, New Relic instruments Rack middlewares by default.
|
13
|
-
# As a result, this entire module has been deprecated.
|
14
|
-
#
|
15
|
-
# @api public
|
16
|
-
# @deprecated
|
17
|
-
#
|
18
|
-
module Rack
|
19
|
-
include ControllerInstrumentation
|
20
|
-
|
21
|
-
def newrelic_request_headers(_)
|
22
|
-
@newrelic_request.env
|
23
|
-
end
|
24
|
-
|
25
|
-
def call_with_newrelic(*args)
|
26
|
-
@newrelic_request = ::Rack::Request.new(args.first)
|
27
|
-
perform_action_with_newrelic_trace(:category => :middleware, :request => @newrelic_request) do
|
28
|
-
result = call_without_newrelic(*args)
|
29
|
-
# Ignore cascaded calls
|
30
|
-
Transaction.abort_transaction! if result.first == 404
|
31
|
-
result
|
32
|
-
end
|
33
|
-
end
|
34
|
-
|
35
|
-
def self.included middleware #:nodoc:
|
36
|
-
middleware.class_eval do
|
37
|
-
alias call_without_newrelic call
|
38
|
-
alias call call_with_newrelic
|
39
|
-
end
|
40
|
-
end
|
41
|
-
|
42
|
-
def self.extended middleware #:nodoc:
|
43
|
-
middleware.class_eval do
|
44
|
-
class << self
|
45
|
-
alias call_without_newrelic call
|
46
|
-
alias call call_with_newrelic
|
47
|
-
end
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def _nr_has_middleware_tracing
|
52
|
-
true
|
53
|
-
end
|
54
|
-
end
|
55
|
-
|
56
10
|
module RackHelpers
|
57
11
|
def self.version_supported?
|
58
12
|
rack_version_supported? || puma_rack_version_supported?
|
@@ -61,16 +15,16 @@ module NewRelic
|
|
61
15
|
def self.rack_version_supported?
|
62
16
|
return false unless defined? ::Rack
|
63
17
|
|
64
|
-
version = ::
|
65
|
-
min_version = ::
|
18
|
+
version = Gem::Version.new(::Rack.release)
|
19
|
+
min_version = Gem::Version.new('1.1.0')
|
66
20
|
version >= min_version
|
67
21
|
end
|
68
22
|
|
69
23
|
def self.puma_rack_version_supported?
|
70
24
|
return false unless defined? ::Puma::Const::PUMA_VERSION
|
71
25
|
|
72
|
-
version = ::
|
73
|
-
min_version = ::
|
26
|
+
version = Gem::Version.new(::Puma::Const::PUMA_VERSION)
|
27
|
+
min_version = Gem::Version.new('2.12.0')
|
74
28
|
version >= min_version
|
75
29
|
end
|
76
30
|
|
@@ -58,7 +58,7 @@ module NewRelic
|
|
58
58
|
end
|
59
59
|
|
60
60
|
def self.is_supported_version?
|
61
|
-
::
|
61
|
+
Gem::Version.new(::Rake::VERSION) >= Gem::Version.new("10.0.0")
|
62
62
|
end
|
63
63
|
|
64
64
|
def self.safe_from_third_party_gem?
|
@@ -6,8 +6,7 @@ DependencyDetection.defer do
|
|
6
6
|
@name = :resque
|
7
7
|
|
8
8
|
depends_on do
|
9
|
-
defined?(::Resque::Job) && !NewRelic::Agent.config[:disable_resque]
|
10
|
-
!NewRelic::LanguageSupport.using_version?('1.9.1')
|
9
|
+
defined?(::Resque::Job) && !NewRelic::Agent.config[:disable_resque]
|
11
10
|
end
|
12
11
|
|
13
12
|
executes do
|
@@ -49,7 +49,6 @@ DependencyDetection.defer do
|
|
49
49
|
# we can't be sure that rack is available when this file is first required.
|
50
50
|
require 'new_relic/rack/agent_hooks'
|
51
51
|
require 'new_relic/rack/browser_monitoring'
|
52
|
-
require 'new_relic/rack/error_collector'
|
53
52
|
|
54
53
|
::Sinatra::Base.class_eval do
|
55
54
|
class << self
|
@@ -50,10 +50,10 @@ end
|
|
50
50
|
|
51
51
|
module NewRelic::Agent::Instrumentation::TyphoeusTracing
|
52
52
|
|
53
|
-
EARLIEST_VERSION =
|
53
|
+
EARLIEST_VERSION = Gem::Version.new("0.5.3")
|
54
54
|
|
55
55
|
def self.is_supported_version?
|
56
|
-
|
56
|
+
Gem::Version.new(Typhoeus::VERSION) >= NewRelic::Agent::Instrumentation::TyphoeusTracing::EARLIEST_VERSION
|
57
57
|
end
|
58
58
|
|
59
59
|
def self.request_is_hydra_enabled?(request)
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'base64'
|
6
|
+
require 'json'
|
6
7
|
require 'new_relic/agent/obfuscator'
|
7
8
|
require 'new_relic/agent/transaction_timings'
|
8
9
|
|
@@ -112,7 +113,7 @@ module NewRelic
|
|
112
113
|
|
113
114
|
txn.freeze_name_and_execute_if_not_ignored do
|
114
115
|
data = data_for_js_agent(state)
|
115
|
-
json =
|
116
|
+
json = ::JSON.dump(data)
|
116
117
|
return html_safe_if_needed("\n<script type=\"text/javascript\">window.NREUM||(NREUM={});NREUM.info=#{json}</script>")
|
117
118
|
end
|
118
119
|
|
@@ -168,7 +169,7 @@ module NewRelic
|
|
168
169
|
append_agent_attributes!(txn, atts)
|
169
170
|
|
170
171
|
unless atts.empty?
|
171
|
-
json =
|
172
|
+
json = ::JSON.dump(atts)
|
172
173
|
data[ATTS_KEY] = obfuscator.obfuscate(json)
|
173
174
|
end
|
174
175
|
end
|
@@ -93,65 +93,12 @@ module NewRelic
|
|
93
93
|
end
|
94
94
|
end
|
95
95
|
|
96
|
-
# Deprecated: original method preserved for API backward compatibility.
|
97
|
-
# Use either #trace_execution_scoped or #trace_execution_unscoped
|
98
|
-
#
|
99
|
-
# @api public
|
100
|
-
# @deprecated
|
101
|
-
#
|
102
|
-
def trace_method_execution(metric_names, push_scope, produce_metric, deduct_call_time_from_parent, &block) #:nodoc:
|
103
|
-
if push_scope
|
104
|
-
trace_execution_scoped(metric_names, :metric => produce_metric,
|
105
|
-
:deduct_call_time_from_parent => deduct_call_time_from_parent, &block)
|
106
|
-
else
|
107
|
-
trace_execution_unscoped(metric_names, &block)
|
108
|
-
end
|
109
|
-
end
|
110
|
-
|
111
|
-
# Deprecated. Use #trace_execution_scoped, a version with an options hash.
|
112
|
-
#
|
113
|
-
# @deprecated
|
114
|
-
#
|
115
|
-
def trace_method_execution_with_scope(metric_names, produce_metric, deduct_call_time_from_parent, scoped_metric_only=false, &block) #:nodoc:
|
116
|
-
trace_execution_scoped(metric_names,
|
117
|
-
:metric => produce_metric,
|
118
|
-
:deduct_call_time_from_parent => deduct_call_time_from_parent,
|
119
|
-
:scoped_metric_only => scoped_metric_only, &block)
|
120
|
-
end
|
121
|
-
|
122
|
-
alias trace_method_execution_no_scope trace_execution_unscoped #:nodoc:
|
123
|
-
|
124
|
-
#
|
125
|
-
# This method is deprecated and exists only for backwards-compatibility
|
126
|
-
# reasons. Usages should be replaced with calls to
|
127
|
-
# NewRelic::Agent.record_metric.
|
128
|
-
#
|
129
|
-
# @api public
|
130
|
-
# @deprecated
|
131
|
-
#
|
132
|
-
def get_stats_scoped(first_name, scoped_metric_only)
|
133
|
-
NewRelic::Agent.instance.stats_engine.get_stats(first_name, true, scoped_metric_only)
|
134
|
-
end
|
135
|
-
|
136
|
-
# This method is deprecated and exists only for backwards-compatibility
|
137
|
-
# reasons. Usages should be replaced with calls to
|
138
|
-
# NewRelic::Agent.record_metric.
|
139
|
-
#
|
140
|
-
# @api public
|
141
|
-
# @deprecated
|
142
|
-
#
|
143
|
-
def get_stats_unscoped(name)
|
144
|
-
NewRelic::Agent.instance.stats_engine.get_stats_no_scope(name)
|
145
|
-
end
|
146
|
-
|
147
96
|
# Defines methods used at the class level, for adding instrumentation
|
148
97
|
# @api public
|
149
98
|
module ClassMethods
|
150
99
|
# contains methods refactored out of the #add_method_tracer method
|
151
100
|
module AddMethodTracer
|
152
|
-
ALLOWED_KEYS = [:
|
153
|
-
|
154
|
-
DEPRECATED_KEYS = [:force, :scoped_metric_only, :deduct_call_time_from_parent].freeze
|
101
|
+
ALLOWED_KEYS = [:metric, :push_scope, :code_header, :code_footer].freeze
|
155
102
|
|
156
103
|
# raises an error when the
|
157
104
|
# NewRelic::Agent::MethodTracer::ClassMethods#add_method_tracer
|
@@ -159,17 +106,11 @@ module NewRelic
|
|
159
106
|
# debugging new instrumentation by failing fast
|
160
107
|
def check_for_illegal_keys!(method_name, options)
|
161
108
|
unrecognized_keys = options.keys - ALLOWED_KEYS
|
162
|
-
deprecated_keys = options.keys & DEPRECATED_KEYS
|
163
109
|
|
164
110
|
if unrecognized_keys.any?
|
165
111
|
raise "Unrecognized options when adding method tracer to #{method_name}: " +
|
166
112
|
unrecognized_keys.join(', ')
|
167
113
|
end
|
168
|
-
|
169
|
-
if deprecated_keys.any?
|
170
|
-
NewRelic::Agent.logger.warn("Deprecated options when adding method tracer to #{method_name}: "+
|
171
|
-
deprecated_keys.join(', '))
|
172
|
-
end
|
173
114
|
end
|
174
115
|
|
175
116
|
# validity checking - add_method_tracer must receive either
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'zlib'
|
6
|
+
require 'timeout'
|
6
7
|
require 'new_relic/agent/audit_logger'
|
7
8
|
require 'new_relic/agent/new_relic_service/encoders'
|
8
9
|
require 'new_relic/agent/new_relic_service/marshaller'
|
@@ -267,7 +268,7 @@ module NewRelic
|
|
267
268
|
|
268
269
|
def start_connection(conn)
|
269
270
|
NewRelic::Agent.logger.debug("Opening TCP connection to #{conn.address}:#{conn.port}")
|
270
|
-
|
271
|
+
Timeout.timeout(@request_timeout) { conn.start }
|
271
272
|
conn
|
272
273
|
end
|
273
274
|
|
@@ -457,7 +458,7 @@ module NewRelic
|
|
457
458
|
attempts += 1
|
458
459
|
conn = http_connection
|
459
460
|
::NewRelic::Agent.logger.debug "Sending request to #{opts[:collector]}#{opts[:uri]} with #{request.method}"
|
460
|
-
|
461
|
+
Timeout.timeout(@request_timeout) do
|
461
462
|
response = conn.request(request)
|
462
463
|
end
|
463
464
|
rescue *CONNECTION_ERRORS => e
|
@@ -3,8 +3,9 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'base64'
|
6
|
-
require '
|
6
|
+
require 'json'
|
7
7
|
require 'stringio'
|
8
|
+
require 'zlib'
|
8
9
|
|
9
10
|
module NewRelic
|
10
11
|
module Agent
|
@@ -40,12 +41,10 @@ module NewRelic
|
|
40
41
|
|
41
42
|
module Base64CompressedJSON
|
42
43
|
def self.encode(data, opts={})
|
43
|
-
|
44
|
-
|
45
|
-
else
|
46
|
-
Agent.config[:normalize_json_string_encodings]
|
44
|
+
if !opts[:skip_normalization] && Agent.config[:normalize_json_string_encodings]
|
45
|
+
data = NewRelic::Agent::EncodingNormalizer.normalize_object(data)
|
47
46
|
end
|
48
|
-
json = ::
|
47
|
+
json = ::JSON.dump(data)
|
49
48
|
Base64.encode64(Compressed::Deflate.encode(json))
|
50
49
|
end
|
51
50
|
end
|
@@ -2,6 +2,7 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
|
+
require 'json'
|
5
6
|
require 'new_relic/agent/new_relic_service/marshaller'
|
6
7
|
|
7
8
|
module NewRelic
|
@@ -10,19 +11,15 @@ module NewRelic
|
|
10
11
|
# Marshal collector protocol with JSON when available
|
11
12
|
class JsonMarshaller < Marshaller
|
12
13
|
def initialize
|
13
|
-
::NewRelic::Agent.logger.debug "Using JSON marshaller (#{NewRelic::JSONWrapper.backend_name})"
|
14
|
-
unless self.class.is_supported?
|
15
|
-
::NewRelic::Agent.logger.error "JSON backend #{NewRelic::JSONWrapper.backend_name} is not supported."
|
16
|
-
end
|
17
14
|
warn_for_yajl
|
18
15
|
end
|
19
16
|
|
20
|
-
OK_YAJL_VERSION =
|
17
|
+
OK_YAJL_VERSION = Gem::Version.new("1.2.1")
|
21
18
|
|
22
19
|
def warn_for_yajl
|
23
20
|
if defined?(::Yajl)
|
24
21
|
require 'yajl/version'
|
25
|
-
if
|
22
|
+
if Gem::Version.new(::Yajl::VERSION) < OK_YAJL_VERSION
|
26
23
|
::NewRelic::Agent.logger.warn "Detected yajl-ruby version #{::Yajl::VERSION} which can cause segfaults with newrelic_rpm's thread profiling features. We strongly recommend you upgrade to the latest yajl-ruby version available."
|
27
24
|
end
|
28
25
|
end
|
@@ -33,13 +30,11 @@ module NewRelic
|
|
33
30
|
def dump(ruby, opts={})
|
34
31
|
prepared = prepare(ruby, opts)
|
35
32
|
|
36
|
-
if opts[:skip_normalization]
|
37
|
-
|
38
|
-
else
|
39
|
-
normalize_encodings = Agent.config[:normalize_json_string_encodings]
|
33
|
+
if !opts[:skip_normalization] && Agent.config[:normalize_json_string_encodings]
|
34
|
+
prepared = NewRelic::Agent::EncodingNormalizer.normalize_object(prepared)
|
40
35
|
end
|
41
36
|
|
42
|
-
|
37
|
+
::JSON.dump(prepared)
|
43
38
|
end
|
44
39
|
|
45
40
|
def load(data)
|
@@ -48,7 +43,7 @@ module NewRelic
|
|
48
43
|
return nil
|
49
44
|
end
|
50
45
|
|
51
|
-
return_value(
|
46
|
+
return_value(::JSON.load(data))
|
52
47
|
rescue => e
|
53
48
|
::NewRelic::Agent.logger.debug "#{e.class.name} : #{e.message} encountered loading collector response: #{data}"
|
54
49
|
raise
|
@@ -66,10 +61,6 @@ module NewRelic
|
|
66
61
|
'json'
|
67
62
|
end
|
68
63
|
|
69
|
-
def self.is_supported?
|
70
|
-
NewRelic::JSONWrapper.usable_for_collector_serialization?
|
71
|
-
end
|
72
|
-
|
73
64
|
def self.human_readable?
|
74
65
|
true # for some definitions of 'human'
|
75
66
|
end
|