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
@@ -376,32 +376,16 @@ module NewRelic
|
|
376
376
|
|
377
377
|
def should_install_exit_handler?
|
378
378
|
(
|
379
|
-
Agent.config[:send_data_on_exit]
|
380
|
-
!NewRelic::LanguageSupport.
|
379
|
+
Agent.config[:send_data_on_exit] &&
|
380
|
+
!NewRelic::LanguageSupport.jruby? &&
|
381
381
|
!sinatra_classic_app?
|
382
382
|
)
|
383
383
|
end
|
384
384
|
|
385
|
-
# There's an MRI 1.9 bug that loses exit codes in at_exit blocks.
|
386
|
-
# A workaround is necessary to get correct exit codes for the agent's
|
387
|
-
# test suites.
|
388
|
-
# http://bugs.ruby-lang.org/issues/5218
|
389
|
-
def need_exit_code_workaround?
|
390
|
-
defined?(RUBY_ENGINE) && RUBY_ENGINE == "ruby" && RUBY_VERSION.match(/^1\.9/)
|
391
|
-
end
|
392
|
-
|
393
385
|
def install_exit_handler
|
394
386
|
return unless should_install_exit_handler?
|
395
387
|
NewRelic::Agent.logger.debug("Installing at_exit handler")
|
396
|
-
at_exit
|
397
|
-
if need_exit_code_workaround?
|
398
|
-
exit_status = $!.status if $!.is_a?(SystemExit)
|
399
|
-
shutdown
|
400
|
-
exit exit_status if exit_status
|
401
|
-
else
|
402
|
-
shutdown
|
403
|
-
end
|
404
|
-
end
|
388
|
+
at_exit { shutdown }
|
405
389
|
end
|
406
390
|
|
407
391
|
# Classy logging of the agent version and the current pid,
|
@@ -535,14 +519,6 @@ module NewRelic
|
|
535
519
|
return false
|
536
520
|
end
|
537
521
|
|
538
|
-
unless NewRelic::Agent::NewRelicService::JsonMarshaller.is_supported?
|
539
|
-
NewRelic::Agent.logger.error "JSON marshaller requested, but the 'json' gem was not available. ",
|
540
|
-
"You will need to: 1) upgrade to Ruby 1.9.3 or newer (strongly recommended), ",
|
541
|
-
"2) add the 'json' gem to your Gemfile or operating environment, ",
|
542
|
-
"or 3) use a version of newrelic_rpm prior to 3.14.0."
|
543
|
-
return false
|
544
|
-
end
|
545
|
-
|
546
522
|
return true
|
547
523
|
end
|
548
524
|
|
@@ -569,11 +545,6 @@ module NewRelic
|
|
569
545
|
@sql_sampler.reset!
|
570
546
|
end
|
571
547
|
|
572
|
-
# Deprecated, and not part of the public API, but here for backwards
|
573
|
-
# compatibility because some 3rd-party gems call it.
|
574
|
-
# @deprecated
|
575
|
-
def reset_stats; drop_buffered_data; end
|
576
|
-
|
577
548
|
# Clear out state for any objects that we know lock from our parents
|
578
549
|
# This is necessary for cases where we're in a forked child and Ruby
|
579
550
|
# might be holding locks for background thread that aren't there anymore.
|
@@ -87,12 +87,8 @@ module NewRelic
|
|
87
87
|
|
88
88
|
def raise_unsupported_error
|
89
89
|
msg = <<-EOF
|
90
|
-
Thread profiling is
|
91
|
-
|
92
|
-
an agent running Ruby #{RUBY_VERSION}.
|
93
|
-
|
94
|
-
Profiling again might select an appropriate agent, but we recommend running a
|
95
|
-
consistent version of Ruby across your application for better results.
|
90
|
+
Thread profiling is not supported for Resque processes. If you did not intend to
|
91
|
+
profile a Resque process, profiling again might select an appropriate agent.
|
96
92
|
EOF
|
97
93
|
raise_command_error(msg)
|
98
94
|
end
|
@@ -127,13 +127,6 @@ module NewRelic
|
|
127
127
|
Proc.new { NewRelic::Control.instance.local_env.discovered_dispatcher }
|
128
128
|
end
|
129
129
|
|
130
|
-
# On Rubies with string encodings support (1.9.x+), default to always
|
131
|
-
# normalize encodings since it's safest and fast. Without that support
|
132
|
-
# the conversions are too expensive, so only enable if overridden to.
|
133
|
-
def self.normalize_json_string_encodings
|
134
|
-
Proc.new { NewRelic::LanguageSupport.supports_string_encodings? }
|
135
|
-
end
|
136
|
-
|
137
130
|
def self.thread_profiler_enabled
|
138
131
|
Proc.new { NewRelic::Agent::Threading::BacktraceService.is_supported? }
|
139
132
|
end
|
@@ -1204,7 +1197,7 @@ module NewRelic
|
|
1204
1197
|
:description => 'Controls whether to check on running a transaction whether to respawn the harvest thread.'
|
1205
1198
|
},
|
1206
1199
|
:normalize_json_string_encodings => {
|
1207
|
-
:default =>
|
1200
|
+
:default => true,
|
1208
1201
|
:public => false,
|
1209
1202
|
:type => Boolean,
|
1210
1203
|
:allowed_from_server => false,
|
@@ -100,7 +100,7 @@ module NewRelic
|
|
100
100
|
|
101
101
|
def process_yaml(file, env, config, path)
|
102
102
|
if file
|
103
|
-
confighash =
|
103
|
+
confighash = YAML.load(file)
|
104
104
|
unless confighash.key?(env)
|
105
105
|
log_failure("Config file at #{path} doesn't include a '#{env}' section!")
|
106
106
|
end
|
@@ -119,17 +119,6 @@ module NewRelic
|
|
119
119
|
end
|
120
120
|
end
|
121
121
|
|
122
|
-
def with_yaml_engine
|
123
|
-
return yield unless NewRelic::LanguageSupport.needs_syck?
|
124
|
-
|
125
|
-
yamler = ::YAML::ENGINE.yamler
|
126
|
-
::YAML::ENGINE.yamler = 'syck'
|
127
|
-
result = yield
|
128
|
-
::YAML::ENGINE.yamler = yamler
|
129
|
-
result
|
130
|
-
end
|
131
|
-
|
132
|
-
|
133
122
|
def booleanify_values(config, *keys)
|
134
123
|
# auto means defer ro default
|
135
124
|
keys.each do |option|
|
@@ -3,6 +3,7 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'digest'
|
6
|
+
require 'json'
|
6
7
|
|
7
8
|
require 'new_relic/agent/inbound_request_monitor'
|
8
9
|
require 'new_relic/agent/transaction_state'
|
@@ -129,7 +130,7 @@ module NewRelic
|
|
129
130
|
content_length,
|
130
131
|
state.request_guid
|
131
132
|
]
|
132
|
-
payload = obfuscator.obfuscate(
|
133
|
+
payload = obfuscator.obfuscate(::JSON.dump(payload))
|
133
134
|
end
|
134
135
|
|
135
136
|
def set_transaction_attributes(state)
|
@@ -3,6 +3,8 @@
|
|
3
3
|
# This file is distributed under New Relic's license terms.
|
4
4
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
5
5
|
|
6
|
+
require 'json'
|
7
|
+
|
6
8
|
module NewRelic
|
7
9
|
module Agent
|
8
10
|
module CrossAppTracing
|
@@ -57,7 +59,7 @@ module NewRelic
|
|
57
59
|
|
58
60
|
def insert_request_headers(request, txn_guid, trip_id, path_hash, synthetics_header)
|
59
61
|
cross_app_id = NewRelic::Agent.config[:cross_process_id]
|
60
|
-
txn_data =
|
62
|
+
txn_data = ::JSON.dump([txn_guid, false, trip_id, path_hash])
|
61
63
|
|
62
64
|
request[NR_ID_HEADER] = obfuscator.obfuscate(cross_app_id)
|
63
65
|
request[NR_TXN_HEADER] = obfuscator.obfuscate(txn_data)
|
@@ -93,7 +95,7 @@ module NewRelic
|
|
93
95
|
decoded_appdata.set_encoding(::Encoding::UTF_8) if
|
94
96
|
decoded_appdata.respond_to?(:set_encoding)
|
95
97
|
|
96
|
-
|
98
|
+
::JSON.load(decoded_appdata)
|
97
99
|
end
|
98
100
|
|
99
101
|
def valid_cross_app_id?(xp_id)
|
@@ -16,7 +16,7 @@ module NewRelic
|
|
16
16
|
end
|
17
17
|
|
18
18
|
def self.is_unsupported_2x?
|
19
|
-
defined?(::Mongo::VERSION) &&
|
19
|
+
defined?(::Mongo::VERSION) && Gem::Version.new(::Mongo::VERSION).segments[0] == 2 &&
|
20
20
|
!self.is_monitoring_enabled?
|
21
21
|
end
|
22
22
|
|
@@ -89,7 +89,7 @@ module NewRelic
|
|
89
89
|
end
|
90
90
|
|
91
91
|
def self.is_supported_version?
|
92
|
-
::
|
92
|
+
Gem::Version.new(::Redis::VERSION) >= Gem::Version.new("3.0.0")
|
93
93
|
end
|
94
94
|
|
95
95
|
def self.ellipsize(result, string)
|
@@ -8,8 +8,7 @@ module NewRelic
|
|
8
8
|
module Agent
|
9
9
|
module EncodingNormalizer
|
10
10
|
def self.normalize_string(raw_string)
|
11
|
-
|
12
|
-
@normalizer.normalize(raw_string)
|
11
|
+
EncodingNormalizer.normalize(raw_string)
|
13
12
|
end
|
14
13
|
|
15
14
|
def self.normalize_object(object)
|
@@ -37,14 +36,6 @@ module NewRelic
|
|
37
36
|
end
|
38
37
|
end
|
39
38
|
|
40
|
-
def self.choose_normalizer
|
41
|
-
if NewRelic::LanguageSupport.supports_string_encodings?
|
42
|
-
EncodingNormalizer
|
43
|
-
else
|
44
|
-
IconvNormalizer
|
45
|
-
end
|
46
|
-
end
|
47
|
-
|
48
39
|
module EncodingNormalizer
|
49
40
|
def self.normalize(raw_string)
|
50
41
|
encoding = raw_string.encoding
|
@@ -69,16 +60,6 @@ module NewRelic
|
|
69
60
|
normalized
|
70
61
|
end
|
71
62
|
end
|
72
|
-
|
73
|
-
module IconvNormalizer
|
74
|
-
def self.normalize(raw_string)
|
75
|
-
if @iconv.nil?
|
76
|
-
require 'iconv'
|
77
|
-
@iconv = Iconv.new('utf-8', 'iso-8859-1')
|
78
|
-
end
|
79
|
-
@iconv.iconv(raw_string)
|
80
|
-
end
|
81
|
-
end
|
82
63
|
end
|
83
64
|
end
|
84
65
|
end
|
@@ -14,8 +14,8 @@ module NewRelic
|
|
14
14
|
# Maximum possible length of the queue - defaults to 20, may be
|
15
15
|
# made configurable in the future. This is a tradeoff between
|
16
16
|
# memory and data retention
|
17
|
-
MAX_ERROR_QUEUE_LENGTH = 20
|
18
|
-
EXCEPTION_TAG_IVAR = :'@__nr_seen_exception'
|
17
|
+
MAX_ERROR_QUEUE_LENGTH = 20
|
18
|
+
EXCEPTION_TAG_IVAR = :'@__nr_seen_exception'
|
19
19
|
|
20
20
|
attr_reader :error_trace_aggregator, :error_event_aggregator
|
21
21
|
|
@@ -180,12 +180,16 @@ module NewRelic
|
|
180
180
|
# detection and soft fail-safe. Returns nil if the method does
|
181
181
|
# not exist
|
182
182
|
def sense_method(object, method)
|
183
|
-
object.
|
183
|
+
object.__send__(method) if object.respond_to?(method)
|
184
184
|
end
|
185
185
|
|
186
186
|
# extracts a stack trace from the exception for debugging purposes
|
187
187
|
def extract_stack_trace(exception)
|
188
|
-
actual_exception =
|
188
|
+
actual_exception = if defined?(Rails) && Rails::VERSION::MAJOR < 5
|
189
|
+
sense_method(exception, :original_exception) || exception
|
190
|
+
else
|
191
|
+
exception
|
192
|
+
end
|
189
193
|
sense_method(actual_exception, :backtrace) || '<no stack trace>'
|
190
194
|
end
|
191
195
|
|
@@ -225,8 +229,6 @@ module NewRelic
|
|
225
229
|
noticed_error.line_number = sense_method(exception, :line_number)
|
226
230
|
noticed_error.stack_trace = extract_stack_trace(exception)
|
227
231
|
|
228
|
-
handle_deprecated_options(options)
|
229
|
-
|
230
232
|
noticed_error.attributes_from_notice_error = options.delete(:custom_params) || {}
|
231
233
|
|
232
234
|
# Any options that are passed to notice_error which aren't known keys
|
@@ -236,21 +238,6 @@ module NewRelic
|
|
236
238
|
noticed_error
|
237
239
|
end
|
238
240
|
|
239
|
-
DEPRECATED_OPTIONS_MSG = "Passing %s to notice_error is no longer supported. Set values on the enclosing transaction or record them as custom attributes instead.".freeze
|
240
|
-
DEPRECATED_OPTIONS = [:request_params, :request, :referer].freeze
|
241
|
-
|
242
|
-
# Old options no longer used by notice_error can still be passed. If they
|
243
|
-
# are, they shouldn't get merged into custom attributes. Delete and
|
244
|
-
# warn callers so they can fix their calls to notice_error.
|
245
|
-
def handle_deprecated_options(options)
|
246
|
-
DEPRECATED_OPTIONS.each do |deprecated|
|
247
|
-
if options.include?(deprecated)
|
248
|
-
NewRelic::Agent.logger.warn(DEPRECATED_OPTIONS_MSG % deprecated)
|
249
|
-
options.delete(deprecated)
|
250
|
-
end
|
251
|
-
end
|
252
|
-
end
|
253
|
-
|
254
241
|
# *Use sparingly for difficult to track bugs.*
|
255
242
|
#
|
256
243
|
# Track internal agent errors for communication back to New Relic.
|
@@ -10,6 +10,9 @@
|
|
10
10
|
# be called when the agent is fully configured. That method is expected to
|
11
11
|
# subscribe to the necessary request events, such as before_call and after_call
|
12
12
|
# for the monitor to do its work.
|
13
|
+
|
14
|
+
require 'json'
|
15
|
+
|
13
16
|
module NewRelic
|
14
17
|
module Agent
|
15
18
|
class InboundRequestMonitor
|
@@ -30,7 +33,7 @@ module NewRelic
|
|
30
33
|
|
31
34
|
def deserialize_header(encoded_header, key)
|
32
35
|
decoded_header = obfuscator.deobfuscate(encoded_header)
|
33
|
-
|
36
|
+
::JSON.load(decoded_header)
|
34
37
|
rescue => err
|
35
38
|
# If we have a failure of any type here, just return nil and carry on
|
36
39
|
NewRelic::Agent.logger.debug("Failure deserializing encoded header '#{key}' in #{self.class}, #{err.class}, #{err.message}")
|
@@ -3,7 +3,6 @@
|
|
3
3
|
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
4
|
|
5
5
|
require 'new_relic/agent/datastores/metric_helper'
|
6
|
-
require 'new_relic/agent/deprecator'
|
7
6
|
|
8
7
|
module NewRelic
|
9
8
|
module Agent
|
@@ -83,8 +82,8 @@ module NewRelic
|
|
83
82
|
end
|
84
83
|
end
|
85
84
|
|
86
|
-
ACTIVE_RECORD = "ActiveRecord".freeze
|
87
|
-
OTHER = "other".freeze
|
85
|
+
ACTIVE_RECORD = "ActiveRecord".freeze
|
86
|
+
OTHER = "other".freeze
|
88
87
|
|
89
88
|
def product_operation_collection_for name, sql, adapter_name
|
90
89
|
product = map_product(adapter_name)
|
@@ -94,23 +93,8 @@ module NewRelic
|
|
94
93
|
NewRelic::Agent::Datastores::MetricHelper.product_operation_collection_for product, operation, model, ACTIVE_RECORD
|
95
94
|
end
|
96
95
|
|
97
|
-
|
98
|
-
|
99
|
-
NewRelic::Agent::Deprecator.deprecate("ActiveRecordHelper.rollup_metrics_for",
|
100
|
-
"NewRelic::Agent::Datastores::MetricHelper.metrics_for")
|
101
|
-
|
102
|
-
rollup_metric = if NewRelic::Agent::Transaction.recording_web_transaction?
|
103
|
-
NewRelic::Agent::Datastores::MetricHelper::WEB_ROLLUP_METRIC
|
104
|
-
else
|
105
|
-
NewRelic::Agent::Datastores::MetricHelper::OTHER_ROLLUP_METRIC
|
106
|
-
end
|
107
|
-
|
108
|
-
[rollup_metric,
|
109
|
-
NewRelic::Agent::Datastores::MetricHelper::ROLLUP_METRIC]
|
110
|
-
end
|
111
|
-
|
112
|
-
SPACE = ' '.freeze unless defined?(SPACE)
|
113
|
-
EMPTY = [].freeze unless defined?(EMPTY)
|
96
|
+
SPACE = ' '.freeze
|
97
|
+
EMPTY = [].freeze
|
114
98
|
|
115
99
|
def split_name(name)
|
116
100
|
if name && name.respond_to?(:split)
|
@@ -150,7 +134,7 @@ module NewRelic
|
|
150
134
|
'Destroy' => 'destroy',
|
151
135
|
'Update' => 'update',
|
152
136
|
'Save' => 'save'
|
153
|
-
}.freeze
|
137
|
+
}.freeze
|
154
138
|
|
155
139
|
def map_operation(raw_operation)
|
156
140
|
direct_op = OPERATION_NAMES[raw_operation]
|
@@ -195,9 +179,9 @@ module NewRelic
|
|
195
179
|
|
196
180
|
# https://rubygems.org/gems/activerecord-oracle_enhanced-adapter
|
197
181
|
"oracle_enhanced" => "Oracle"
|
198
|
-
}.freeze
|
182
|
+
}.freeze
|
199
183
|
|
200
|
-
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME = "ActiveRecord".freeze
|
184
|
+
ACTIVE_RECORD_DEFAULT_PRODUCT_NAME = "ActiveRecord".freeze
|
201
185
|
|
202
186
|
def map_product(adapter_name)
|
203
187
|
PRODUCT_NAMES.fetch(adapter_name,
|
@@ -214,17 +198,17 @@ module NewRelic
|
|
214
198
|
|
215
199
|
"postgresql" => :postgres,
|
216
200
|
"jdbcpostgresql" => :postgres
|
217
|
-
}.freeze
|
201
|
+
}.freeze
|
218
202
|
|
219
203
|
DATASTORE_DEFAULT_PORTS = {
|
220
204
|
:mysql => "3306",
|
221
205
|
:postgres => "5432"
|
222
|
-
}.freeze
|
206
|
+
}.freeze
|
223
207
|
|
224
|
-
DEFAULT = "default".freeze
|
225
|
-
UNKNOWN = "unknown".freeze
|
226
|
-
SLASH = "/".freeze
|
227
|
-
LOCALHOST = "localhost".freeze
|
208
|
+
DEFAULT = "default".freeze
|
209
|
+
UNKNOWN = "unknown".freeze
|
210
|
+
SLASH = "/".freeze
|
211
|
+
LOCALHOST = "localhost".freeze
|
228
212
|
|
229
213
|
def host(config)
|
230
214
|
return UNKNOWN unless config
|
@@ -267,7 +251,7 @@ module NewRelic
|
|
267
251
|
UNKNOWN
|
268
252
|
end
|
269
253
|
|
270
|
-
SUPPORTED_ADAPTERS = [:mysql, :postgres].freeze
|
254
|
+
SUPPORTED_ADAPTERS = [:mysql, :postgres].freeze
|
271
255
|
|
272
256
|
def supported_adapter? config
|
273
257
|
config && SUPPORTED_ADAPTERS.include?(PRODUCT_SYMBOLS[config[:adapter]])
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
module Agent
|
12
12
|
module Instrumentation
|
13
13
|
class ActiveRecordSubscriber < EventedSubscriber
|
14
|
-
CACHED_QUERY_NAME = 'CACHE'.freeze
|
14
|
+
CACHED_QUERY_NAME = 'CACHE'.freeze
|
15
15
|
|
16
16
|
def initialize
|
17
17
|
# We cache this in an instance variable to avoid re-calling method
|
@@ -38,15 +38,14 @@ module NewRelic
|
|
38
38
|
def self.included(clazz)
|
39
39
|
clazz.extend(ClassMethodsShim)
|
40
40
|
end
|
41
|
-
def newrelic_notice_error(*args); end
|
42
41
|
def new_relic_trace_controller_action(*args); yield; end
|
43
42
|
def perform_action_with_newrelic_trace(*args); yield; end
|
44
43
|
end
|
45
44
|
|
46
|
-
NR_DO_NOT_TRACE_KEY = :'@do_not_trace'
|
47
|
-
NR_IGNORE_APDEX_KEY = :'@ignore_apdex'
|
48
|
-
NR_IGNORE_ENDUSER_KEY = :'@ignore_enduser'
|
49
|
-
NR_DEFAULT_OPTIONS = {}.freeze
|
45
|
+
NR_DO_NOT_TRACE_KEY = :'@do_not_trace'
|
46
|
+
NR_IGNORE_APDEX_KEY = :'@ignore_apdex'
|
47
|
+
NR_IGNORE_ENDUSER_KEY = :'@ignore_enduser'
|
48
|
+
NR_DEFAULT_OPTIONS = {}.freeze
|
50
49
|
|
51
50
|
# @api public
|
52
51
|
module ClassMethods
|
@@ -5,11 +5,11 @@
|
|
5
5
|
DependencyDetection.defer do
|
6
6
|
named :curb
|
7
7
|
|
8
|
-
CURB_MIN_VERSION = ::
|
8
|
+
CURB_MIN_VERSION = Gem::Version.new("0.8.1")
|
9
9
|
|
10
10
|
depends_on do
|
11
11
|
defined?(::Curl) && defined?(::Curl::CURB_VERSION) &&
|
12
|
-
::
|
12
|
+
Gem::Version.new(::Curl::CURB_VERSION) >= CURB_MIN_VERSION
|
13
13
|
end
|
14
14
|
|
15
15
|
executes do
|