newrelic_rpm 8.16.0 → 9.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.rubocop.yml +0 -28
- data/.rubocop_todo.yml +41 -3
- data/CHANGELOG.md +126 -0
- data/CONTRIBUTING.md +1 -1
- data/README.md +3 -1
- data/bin/nrdebug +16 -16
- data/lib/new_relic/agent/agent_helpers/connect.rb +1 -1
- data/lib/new_relic/agent/agent_helpers/special_startup.rb +1 -2
- data/lib/new_relic/agent/attribute_filter.rb +0 -2
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +3 -3
- data/lib/new_relic/agent/configuration/default_source.rb +98 -474
- data/lib/new_relic/agent/configuration/high_security_source.rb +0 -2
- data/lib/new_relic/agent/configuration/security_policy_source.rb +0 -16
- data/lib/new_relic/agent/database.rb +0 -14
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +1 -2
- data/lib/new_relic/agent/error_collector.rb +1 -1
- data/lib/new_relic/agent/error_filter.rb +3 -3
- data/lib/new_relic/agent/instrumentation/active_job.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/fiber/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/fiber/instrumentation.rb +24 -0
- data/lib/new_relic/agent/instrumentation/fiber/prepend.rb +18 -0
- data/lib/new_relic/agent/instrumentation/fiber.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape.rb +1 -1
- data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
- data/lib/new_relic/agent/instrumentation/net_http.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +1 -8
- data/lib/new_relic/agent/instrumentation/rake.rb +1 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +1 -1
- data/lib/new_relic/agent/instrumentation/resque.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sequel.rb +4 -5
- data/lib/new_relic/agent/instrumentation/thread/instrumentation.rb +3 -7
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +0 -1
- data/lib/new_relic/agent/new_relic_service/security_policy_settings.rb +0 -1
- data/lib/new_relic/agent/new_relic_service.rb +1 -1
- data/lib/new_relic/agent/rules_engine/segment_terms_rule.rb +0 -1
- data/lib/new_relic/agent/samplers/delayed_job_sampler.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +10 -1
- data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -2
- data/lib/new_relic/agent/transaction/tracing.rb +2 -2
- data/lib/new_relic/agent/transaction.rb +17 -16
- data/lib/new_relic/agent.rb +1 -19
- data/lib/new_relic/cli/commands/install.rb +9 -9
- data/lib/new_relic/control/instance_methods.rb +1 -1
- data/lib/new_relic/local_environment.rb +0 -10
- data/lib/new_relic/supportability_helper.rb +0 -1
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +1 -1
- data/lib/sequel/extensions/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +3 -3
- data/lib/sequel/plugins/{newrelic_instrumentation.rb → new_relic_instrumentation.rb} +3 -3
- data/lib/tasks/helpers/format.rb +1 -1
- data/lib/tasks/instrumentation_generator/instrumentation.thor +7 -10
- data/lib/tasks/instrumentation_generator/templates/Envfile.tt +1 -1
- data/newrelic.yml +5 -8
- data/newrelic_rpm.gemspec +16 -13
- metadata +13 -14
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +0 -83
- data/lib/new_relic/agent/instrumentation/authlogic.rb +0 -33
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +0 -215
- data/lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb +0 -36
- data/lib/new_relic/agent/instrumentation/sunspot.rb +0 -41
@@ -11,8 +11,6 @@ module NewRelic
|
|
11
11
|
def initialize(local_settings)
|
12
12
|
super({
|
13
13
|
:capture_params => false,
|
14
|
-
:'resque.capture_params' => false,
|
15
|
-
:'sidekiq.capture_params' => false,
|
16
14
|
:'attributes.include' => [],
|
17
15
|
|
18
16
|
:'transaction_tracer.record_sql' => record_sql_setting(local_settings, :'transaction_tracer.record_sql'),
|
@@ -191,22 +191,6 @@ module NewRelic
|
|
191
191
|
disabled_value: false,
|
192
192
|
permitted_fn: nil
|
193
193
|
}
|
194
|
-
],
|
195
|
-
"job_arguments" => [
|
196
|
-
{
|
197
|
-
option: :'resque.capture_params',
|
198
|
-
supported: true,
|
199
|
-
enabled_fn: method(:enabled?),
|
200
|
-
disabled_value: false,
|
201
|
-
permitted_fn: nil
|
202
|
-
},
|
203
|
-
{
|
204
|
-
option: :'sidekiq.capture_params',
|
205
|
-
supported: true,
|
206
|
-
enabled_fn: method(:enabled?),
|
207
|
-
disabled_value: false,
|
208
|
-
permitted_fn: nil
|
209
|
-
}
|
210
194
|
]
|
211
195
|
}
|
212
196
|
|
@@ -7,20 +7,6 @@ require 'new_relic/agent/database/explain_plan_helpers'
|
|
7
7
|
require 'new_relic/agent/database/obfuscator'
|
8
8
|
|
9
9
|
module NewRelic
|
10
|
-
# columns for a mysql explain plan
|
11
|
-
MYSQL_EXPLAIN_COLUMNS = [
|
12
|
-
"Id",
|
13
|
-
"Select Type",
|
14
|
-
"Table",
|
15
|
-
"Type",
|
16
|
-
"Possible Keys",
|
17
|
-
"Key",
|
18
|
-
"Key Length",
|
19
|
-
"Ref",
|
20
|
-
"Rows",
|
21
|
-
"Extra"
|
22
|
-
].freeze
|
23
|
-
|
24
10
|
module Agent
|
25
11
|
module Database
|
26
12
|
MAX_QUERY_LENGTH = 16384
|
@@ -166,8 +166,7 @@ module NewRelic
|
|
166
166
|
|
167
167
|
def cross_application_tracer_enabled?
|
168
168
|
!NewRelic::Agent.config[:"distributed_tracing.enabled"] &&
|
169
|
-
|
170
|
-
NewRelic::Agent.config[:cross_application_tracing])
|
169
|
+
NewRelic::Agent.config[:"cross_application_tracer.enabled"]
|
171
170
|
end
|
172
171
|
|
173
172
|
def obfuscator
|
@@ -26,7 +26,7 @@ module NewRelic
|
|
26
26
|
@error_filter = NewRelic::Agent::ErrorFilter.new
|
27
27
|
|
28
28
|
%w[
|
29
|
-
|
29
|
+
ignore_classes ignore_messages ignore_status_codes
|
30
30
|
expected_classes expected_messages expected_status_codes
|
31
31
|
].each do |w|
|
32
32
|
Agent.config.register_callback(:"error_collector.#{w}") do |value|
|
@@ -19,7 +19,7 @@ module NewRelic
|
|
19
19
|
|
20
20
|
def load_all
|
21
21
|
%i[
|
22
|
-
|
22
|
+
ignore_classes ignore_messages ignore_status_codes
|
23
23
|
expected_classes expected_messages expected_status_codes
|
24
24
|
].each { |setting| load_from_config(setting) }
|
25
25
|
end
|
@@ -31,7 +31,7 @@ module NewRelic
|
|
31
31
|
return if new_value.nil? || (new_value.respond_to?(:empty?) && new_value.empty?)
|
32
32
|
|
33
33
|
case setting.to_sym
|
34
|
-
when :
|
34
|
+
when :ignore_classes
|
35
35
|
new_value = new_value.split(',').map!(&:strip) if new_value.is_a?(String)
|
36
36
|
errors = @ignore_classes = new_value
|
37
37
|
when :ignore_messages
|
@@ -120,7 +120,7 @@ module NewRelic
|
|
120
120
|
|
121
121
|
def log_filter(setting, errors)
|
122
122
|
case setting
|
123
|
-
when :
|
123
|
+
when :ignore_classes
|
124
124
|
errors.each do |error|
|
125
125
|
::NewRelic::Agent.logger.debug("Ignoring errors of type '#{error}'")
|
126
126
|
end
|
@@ -71,7 +71,7 @@ module NewRelic
|
|
71
71
|
end
|
72
72
|
|
73
73
|
def self.run_in_trace(job, block, event)
|
74
|
-
trace_execution_scoped("
|
74
|
+
trace_execution_scoped("ActiveJob/#{adapter.sub(/^ActiveJob::/, '')}/Queue/#{event}/Named/#{job.queue_name}",
|
75
75
|
code_information: code_information_for_job(job)) do
|
76
76
|
block.call
|
77
77
|
end
|
@@ -180,7 +180,7 @@ module NewRelic
|
|
180
180
|
code_info = NewRelic::Agent::MethodTracerHelpers.code_information(self, method)
|
181
181
|
argument_list = generate_argument_list(options.merge(code_info))
|
182
182
|
|
183
|
-
class_eval(
|
183
|
+
class_eval(<<~EOC)
|
184
184
|
def #{with_method_name}(*args, &block)
|
185
185
|
perform_action_with_newrelic_trace(#{argument_list.join(',')}) do
|
186
186
|
#{without_method_name}(*args, &block)
|
@@ -0,0 +1,20 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module MonitoredFiber
|
7
|
+
def self.instrument!
|
8
|
+
::Fiber.class_eval do
|
9
|
+
include NewRelic::Agent::Instrumentation::MonitoredFiber
|
10
|
+
|
11
|
+
alias_method(:initialize_without_new_relic, :initialize)
|
12
|
+
|
13
|
+
def initialize(*args, &block)
|
14
|
+
traced_block = add_thread_tracing(*args, &block)
|
15
|
+
initialize_with_newrelic_tracing { initialize_without_new_relic(*args, &traced_block) }
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
@@ -0,0 +1,24 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module MonitoredFiber
|
7
|
+
attr_reader :nr_parent_key
|
8
|
+
|
9
|
+
def initialize_with_newrelic_tracing
|
10
|
+
@nr_parent_key = NewRelic::Agent::Tracer.current_segment_key
|
11
|
+
yield
|
12
|
+
end
|
13
|
+
|
14
|
+
def add_thread_tracing(*args, &block)
|
15
|
+
return block if !NewRelic::Agent::Tracer.thread_tracing_enabled?
|
16
|
+
|
17
|
+
NewRelic::Agent::Tracer.thread_block_with_current_transaction(
|
18
|
+
*args,
|
19
|
+
segment_name: 'Ruby/Fiber',
|
20
|
+
&block
|
21
|
+
)
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
@@ -0,0 +1,18 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module MonitoredFiber
|
9
|
+
module Prepend
|
10
|
+
include NewRelic::Agent::Instrumentation::MonitoredFiber
|
11
|
+
|
12
|
+
def initialize(*args, &block)
|
13
|
+
traced_block = add_thread_tracing(*args, &block)
|
14
|
+
initialize_with_newrelic_tracing { super(*args, &traced_block) }
|
15
|
+
end
|
16
|
+
end
|
17
|
+
end
|
18
|
+
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'fiber/instrumentation'
|
6
|
+
require_relative 'fiber/chain'
|
7
|
+
require_relative 'fiber/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :fiber
|
11
|
+
|
12
|
+
depends_on do
|
13
|
+
defined?(Fiber)
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
NewRelic::Agent.logger.info('Installing Fiber instrumentation')
|
18
|
+
|
19
|
+
if use_prepend?
|
20
|
+
prepend_instrument Fiber, NewRelic::Agent::Instrumentation::MonitoredFiber::Prepend
|
21
|
+
else
|
22
|
+
chain_instrument NewRelic::Agent::Instrumentation::MonitoredFiber
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
@@ -9,7 +9,7 @@ require_relative 'grape/prepend'
|
|
9
9
|
DependencyDetection.defer do
|
10
10
|
# Why not just :grape? newrelic-grape used that name already, and while we're
|
11
11
|
# not shipping yet, overloading the name interferes with the plugin.
|
12
|
-
|
12
|
+
@name = :grape_instrumentation
|
13
13
|
configure_with :grape
|
14
14
|
|
15
15
|
depends_on do
|
@@ -46,7 +46,7 @@ DependencyDetection.defer do
|
|
46
46
|
end
|
47
47
|
|
48
48
|
DependencyDetection.defer do
|
49
|
-
|
49
|
+
@name = :dalli
|
50
50
|
configure_with :memcache
|
51
51
|
|
52
52
|
depends_on { defined? Dalli::Client }
|
@@ -67,7 +67,7 @@ end
|
|
67
67
|
# dalli/cas/client. Use a separate dependency block so it can potentially
|
68
68
|
# re-evaluate after they've done that require.
|
69
69
|
DependencyDetection.defer do
|
70
|
-
|
70
|
+
@name = :dalli_cas_client
|
71
71
|
configure_with :memcache
|
72
72
|
|
73
73
|
depends_on { defined? Dalli::Client }
|
@@ -73,10 +73,6 @@ module NewRelic
|
|
73
73
|
task.instance_eval do
|
74
74
|
def invoke_prerequisites_concurrently(*_)
|
75
75
|
NewRelic::Agent::MethodTracer.trace_execution_scoped("Rake/execute/multitask") do
|
76
|
-
prereqs = self.prerequisite_tasks.map(&:name).join(", ")
|
77
|
-
if txn = ::NewRelic::Agent::Tracer.current_transaction
|
78
|
-
txn.current_segment.params[:statement] = NewRelic::Agent::Database.truncate_query("Couldn't trace concurrent prereq tasks: #{prereqs}")
|
79
|
-
end
|
80
76
|
super
|
81
77
|
end
|
82
78
|
end
|
@@ -86,12 +82,9 @@ module NewRelic
|
|
86
82
|
def before_invoke_transaction(task)
|
87
83
|
ensure_at_exit
|
88
84
|
|
89
|
-
|
90
|
-
# make one node and annotate with prereq task names
|
85
|
+
instrument_execute_on_prereqs(task)
|
91
86
|
if task.application.options.always_multitask
|
92
87
|
instrument_invoke_prerequisites_concurrently(task)
|
93
|
-
else
|
94
|
-
instrument_execute_on_prereqs(task)
|
95
88
|
end
|
96
89
|
rescue => e
|
97
90
|
NewRelic::Agent.logger.error("Error during Rake task invoke", e)
|
@@ -8,7 +8,7 @@ require_relative 'rake/prepend'
|
|
8
8
|
|
9
9
|
DependencyDetection.defer do
|
10
10
|
# Why not :rake? newrelic-rake used that name, so avoid conflicting
|
11
|
-
|
11
|
+
@name = :rake_instrumentation
|
12
12
|
configure_with :rake
|
13
13
|
|
14
14
|
depends_on { defined?(Rake) && defined?(Rake::VERSION) }
|
@@ -11,8 +11,7 @@ DependencyDetection.defer do
|
|
11
11
|
end
|
12
12
|
|
13
13
|
depends_on do
|
14
|
-
!NewRelic::Agent.config[:disable_sequel_instrumentation]
|
15
|
-
!NewRelic::Agent.config[:disable_database_instrumentation]
|
14
|
+
!NewRelic::Agent.config[:disable_sequel_instrumentation]
|
16
15
|
end
|
17
16
|
|
18
17
|
def supported_sequel_version?
|
@@ -27,7 +26,7 @@ DependencyDetection.defer do
|
|
27
26
|
NewRelic::Agent.logger.info('Installing Sequel instrumentation')
|
28
27
|
|
29
28
|
if Sequel::Database.respond_to?(:extension)
|
30
|
-
Sequel::Database.extension(:
|
29
|
+
Sequel::Database.extension(:new_relic_instrumentation)
|
31
30
|
else
|
32
31
|
NewRelic::Agent.logger.info("Detected Sequel version %s." % [Sequel::VERSION])
|
33
32
|
NewRelic::Agent.logger.info("Please see additional documentation: " +
|
@@ -35,10 +34,10 @@ DependencyDetection.defer do
|
|
35
34
|
end
|
36
35
|
|
37
36
|
Sequel.synchronize { Sequel::DATABASES.dup }.each do |db|
|
38
|
-
db.extension(:
|
37
|
+
db.extension(:new_relic_instrumentation)
|
39
38
|
end
|
40
39
|
|
41
|
-
Sequel::Model.plugin(:
|
40
|
+
Sequel::Model.plugin(:new_relic_instrumentation) if defined?(Sequel::Model)
|
42
41
|
else
|
43
42
|
|
44
43
|
NewRelic::Agent.logger.info("Sequel instrumentation requires at least version 3.37.0.")
|
@@ -6,15 +6,15 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Instrumentation
|
8
8
|
module MonitoredThread
|
9
|
-
attr_reader :
|
9
|
+
attr_reader :nr_parent_key
|
10
10
|
|
11
11
|
def initialize_with_newrelic_tracing
|
12
|
-
@
|
12
|
+
@nr_parent_key = NewRelic::Agent::Tracer.current_segment_key
|
13
13
|
yield
|
14
14
|
end
|
15
15
|
|
16
16
|
def add_thread_tracing(*args, &block)
|
17
|
-
return block if
|
17
|
+
return block if !NewRelic::Agent::Tracer.thread_tracing_enabled?
|
18
18
|
|
19
19
|
NewRelic::Agent::Tracer.thread_block_with_current_transaction(
|
20
20
|
*args,
|
@@ -22,10 +22,6 @@ module NewRelic
|
|
22
22
|
&block
|
23
23
|
)
|
24
24
|
end
|
25
|
-
|
26
|
-
def skip_tracing?
|
27
|
-
!NewRelic::Agent.config[:'instrumentation.thread.tracing']
|
28
|
-
end
|
29
25
|
end
|
30
26
|
end
|
31
27
|
end
|
@@ -12,7 +12,6 @@ module NewRelic
|
|
12
12
|
module Agent
|
13
13
|
module DistributedTracing
|
14
14
|
class CrossAppMonitor < InboundRequestMonitor
|
15
|
-
NEWRELIC_ID_HEADER = 'X-NewRelic-ID'.freeze
|
16
15
|
NEWRELIC_TXN_HEADER = 'X-NewRelic-Transaction'.freeze
|
17
16
|
NEWRELIC_APPDATA_HEADER = 'X-NewRelic-App-Data'.freeze
|
18
17
|
|
@@ -595,7 +595,7 @@ module NewRelic
|
|
595
595
|
return if post_string.size < Agent.config[:max_payload_size_in_bytes]
|
596
596
|
|
597
597
|
::NewRelic::Agent.logger.debug("Tried to send too much data: #{post_string.size} bytes")
|
598
|
-
NewRelic::Agent.increment_metric("Supportability/
|
598
|
+
NewRelic::Agent.increment_metric("Supportability/Ruby/Collector/#{endpoint}/MaxPayloadSizeLimit")
|
599
599
|
raise UnrecoverableServerException.new('413 Request Entity Too Large')
|
600
600
|
end
|
601
601
|
|
@@ -25,7 +25,7 @@ module NewRelic
|
|
25
25
|
end
|
26
26
|
|
27
27
|
def initialize
|
28
|
-
raise Unsupported, "DJ queue sampler disabled" if Agent.config[:
|
28
|
+
raise Unsupported, "DJ queue sampler disabled" if Agent.config[:'instrumentation.delayed_job'] == 'disabled'
|
29
29
|
raise Unsupported, "DJ queue sampling unsupported with backend '#{::Delayed::Worker.backend}'" unless self.class.supported_backend?
|
30
30
|
raise Unsupported, "No DJ worker present. Skipping DJ queue sampler" unless NewRelic::DelayedJobInjection.worker_name
|
31
31
|
end
|
@@ -410,8 +410,17 @@ module NewRelic
|
|
410
410
|
|
411
411
|
alias_method :tl_clear, :clear_state
|
412
412
|
|
413
|
+
def current_segment_key
|
414
|
+
::Fiber.current.object_id
|
415
|
+
end
|
416
|
+
|
417
|
+
def thread_tracing_enabled?
|
418
|
+
NewRelic::Agent.config[:'instrumentation.thread.tracing']
|
419
|
+
end
|
420
|
+
|
413
421
|
def thread_block_with_current_transaction(*args, segment_name:, parent: nil, &block)
|
414
|
-
|
422
|
+
parent ||= current_segment
|
423
|
+
current_txn = ::Thread.current[:newrelic_tracer_state]&.current_transaction if ::Thread.current[:newrelic_tracer_state]&.is_execution_traced?
|
415
424
|
proc do
|
416
425
|
begin
|
417
426
|
if current_txn
|
@@ -20,14 +20,14 @@ module NewRelic
|
|
20
20
|
# after its parent. We will use the optimized exclusive duration
|
21
21
|
# calculation in all other cases.
|
22
22
|
#
|
23
|
-
attr_reader :start_time, :end_time, :duration, :exclusive_duration, :guid, :
|
23
|
+
attr_reader :start_time, :end_time, :duration, :exclusive_duration, :guid, :starting_segment_key
|
24
24
|
attr_accessor :name, :parent, :children_time, :transaction, :transaction_name
|
25
25
|
attr_writer :record_metrics, :record_scoped_metric, :record_on_finish
|
26
26
|
attr_reader :noticed_error
|
27
27
|
|
28
28
|
def initialize(name = nil, start_time = nil)
|
29
29
|
@name = name
|
30
|
-
@
|
30
|
+
@starting_segment_key = NewRelic::Agent::Tracer.current_segment_key
|
31
31
|
@transaction_name = nil
|
32
32
|
@transaction = nil
|
33
33
|
@guid = NewRelic::Agent::GuidGenerator.generate_guid
|
@@ -35,8 +35,8 @@ module NewRelic
|
|
35
35
|
|
36
36
|
def segment_complete(segment)
|
37
37
|
# if parent was in another thread, remove the current_segment entry for this thread
|
38
|
-
if segment.parent && segment.parent.
|
39
|
-
remove_current_segment_by_thread_id(::
|
38
|
+
if segment.parent && segment.parent.starting_segment_key != NewRelic::Agent::Tracer.current_segment_key
|
39
|
+
remove_current_segment_by_thread_id(NewRelic::Agent::Tracer.current_segment_key)
|
40
40
|
else
|
41
41
|
set_current_segment(segment.parent)
|
42
42
|
end
|
@@ -53,9 +53,6 @@ module NewRelic
|
|
53
53
|
|
54
54
|
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time"
|
55
55
|
|
56
|
-
# reference to the transaction state managing this transaction
|
57
|
-
attr_accessor :state
|
58
|
-
|
59
56
|
# A Time instance for the start time, never nil
|
60
57
|
attr_accessor :start_time
|
61
58
|
|
@@ -121,7 +118,6 @@ module NewRelic
|
|
121
118
|
def self.start_new_transaction(state, category, options)
|
122
119
|
txn = Transaction.new(category, options)
|
123
120
|
state.reset(txn)
|
124
|
-
txn.state = state
|
125
121
|
txn.start(options)
|
126
122
|
txn
|
127
123
|
end
|
@@ -248,6 +244,7 @@ module NewRelic
|
|
248
244
|
@priority = nil
|
249
245
|
|
250
246
|
@starting_thread_id = Thread.current.object_id
|
247
|
+
@starting_segment_key = current_segment_key
|
251
248
|
|
252
249
|
@attributes = Attributes.new(NewRelic::Agent.instance.attribute_filter)
|
253
250
|
|
@@ -260,20 +257,26 @@ module NewRelic
|
|
260
257
|
end
|
261
258
|
end
|
262
259
|
|
263
|
-
def
|
264
|
-
::
|
260
|
+
def state
|
261
|
+
NewRelic::Agent::Tracer.state
|
265
262
|
end
|
266
263
|
|
267
|
-
def
|
268
|
-
|
269
|
-
|
270
|
-
return current_segment_by_thread[parent_thread_id] if current_segment_by_thread[parent_thread_id]
|
264
|
+
def current_segment_key
|
265
|
+
Tracer.current_segment_key
|
266
|
+
end
|
271
267
|
|
272
|
-
|
268
|
+
def parent_segment_key
|
269
|
+
(::Fiber.current.nr_parent_key if ::Fiber.current.respond_to?(:nr_parent_key)) || (::Thread.current.nr_parent_key if ::Thread.current.respond_to?(:nr_parent_key))
|
270
|
+
end
|
271
|
+
|
272
|
+
def current_segment
|
273
|
+
current_segment_by_thread[current_segment_key] ||
|
274
|
+
current_segment_by_thread[parent_segment_key] ||
|
275
|
+
current_segment_by_thread[@starting_segment_key]
|
273
276
|
end
|
274
277
|
|
275
278
|
def set_current_segment(new_segment)
|
276
|
-
@current_segment_lock.synchronize { current_segment_by_thread[
|
279
|
+
@current_segment_lock.synchronize { current_segment_by_thread[current_segment_key] = new_segment }
|
277
280
|
end
|
278
281
|
|
279
282
|
def remove_current_segment_by_thread_id(id)
|
@@ -359,10 +362,8 @@ module NewRelic
|
|
359
362
|
def set_overriding_transaction_name(name, category)
|
360
363
|
return log_frozen_name(name) if name_frozen?
|
361
364
|
|
362
|
-
|
363
|
-
|
364
|
-
@category = category if category
|
365
|
-
end
|
365
|
+
self.overridden_name = name
|
366
|
+
@category = category if category
|
366
367
|
end
|
367
368
|
|
368
369
|
def log_frozen_name(name)
|
data/lib/new_relic/agent.rb
CHANGED
@@ -371,7 +371,7 @@ module NewRelic
|
|
371
371
|
# jobs or other work. If you are doing this with a web dispatcher
|
372
372
|
# that forks worker processes then you will need to force the
|
373
373
|
# agent to reconnect, which it won't do by default. Passenger and
|
374
|
-
#
|
374
|
+
# Unicorn are already handled, nothing special needed for them.
|
375
375
|
#
|
376
376
|
# Options:
|
377
377
|
# * <tt>:force_reconnect => true</tt> to force the spawned process to
|
@@ -511,18 +511,6 @@ module NewRelic
|
|
511
511
|
end
|
512
512
|
end
|
513
513
|
|
514
|
-
# This method disables the recording of transaction traces in the given
|
515
|
-
# block. See also #disable_all_tracing
|
516
|
-
#
|
517
|
-
# @api public
|
518
|
-
#
|
519
|
-
def disable_transaction_tracing
|
520
|
-
Deprecator.deprecate(:disable_transaction_tracing,
|
521
|
-
'disable_all_tracing or ignore_transaction')
|
522
|
-
record_api_supportability_metric(:disable_transaction_tracing)
|
523
|
-
yield
|
524
|
-
end
|
525
|
-
|
526
514
|
# This method sets the state of sql recording in the transaction
|
527
515
|
# sampler feature. Within the given block, no sql will be recorded
|
528
516
|
#
|
@@ -554,12 +542,6 @@ module NewRelic
|
|
554
542
|
NewRelic::Agent::Tracer.state.is_execution_traced?
|
555
543
|
end
|
556
544
|
|
557
|
-
# helper method to check the thread local to determine whether sql
|
558
|
-
# is being recorded or not
|
559
|
-
def tl_is_sql_recorded?
|
560
|
-
NewRelic::Agent::Tracer.state.is_sql_recorded?
|
561
|
-
end
|
562
|
-
|
563
545
|
# @!group Adding custom attributes to traces
|
564
546
|
|
565
547
|
# Add attributes to the transaction trace, Insights Transaction event, and
|
@@ -45,20 +45,20 @@ class NewRelic::Cli::Install < NewRelic::Cli::Command
|
|
45
45
|
|
46
46
|
File.open(dest_file, 'w') { |out| out.puts(content) }
|
47
47
|
|
48
|
-
puts
|
48
|
+
puts <<~EOF unless quiet
|
49
49
|
|
50
|
-
Installed a default configuration file at
|
51
|
-
#{dest_file}.
|
50
|
+
Installed a default configuration file at
|
51
|
+
#{dest_file}.
|
52
52
|
EOF
|
53
|
-
puts
|
53
|
+
puts <<~EOF unless quiet || @license_key != NO_LICENSE_KEY
|
54
54
|
|
55
|
-
To monitor your application in production mode, sign up for an account
|
56
|
-
at www.newrelic.com, and replace the newrelic.yml file with the one
|
57
|
-
you receive upon registration.
|
55
|
+
To monitor your application in production mode, sign up for an account
|
56
|
+
at www.newrelic.com, and replace the newrelic.yml file with the one
|
57
|
+
you receive upon registration.
|
58
58
|
EOF
|
59
|
-
puts
|
59
|
+
puts <<~EOF unless quiet
|
60
60
|
|
61
|
-
Visit support.newrelic.com if you are experiencing installation issues.
|
61
|
+
Visit support.newrelic.com if you are experiencing installation issues.
|
62
62
|
EOF
|
63
63
|
end
|
64
64
|
|
@@ -65,7 +65,7 @@ module NewRelic
|
|
65
65
|
# An artifact of earlier implementation, we put both #add_method_tracer and #trace_execution
|
66
66
|
# methods in the module methods.
|
67
67
|
# Rails applications load the next two lines before any other initializers are run
|
68
|
-
unless defined?(Rails::VERSION) &&
|
68
|
+
unless defined?(Rails::VERSION) && ENV['NEW_RELIC_DEFER_RAILS_INITIALIZATION']
|
69
69
|
Module.send(:include, NewRelic::Agent::MethodTracer::ClassMethods)
|
70
70
|
Module.send(:include, NewRelic::Agent::MethodTracer)
|
71
71
|
end
|
@@ -74,9 +74,7 @@ module NewRelic
|
|
74
74
|
unicorn
|
75
75
|
webrick
|
76
76
|
fastcgi
|
77
|
-
rainbows
|
78
77
|
]
|
79
|
-
# TODO: MAJOR VERSION - remove rainbows
|
80
78
|
while dispatchers.any? && @discovered_dispatcher.nil?
|
81
79
|
send('check_for_' + (dispatchers.shift))
|
82
80
|
end
|
@@ -134,14 +132,6 @@ module NewRelic
|
|
134
132
|
end
|
135
133
|
end
|
136
134
|
|
137
|
-
# TODO: MAJOR VERSION - remove this method
|
138
|
-
def check_for_rainbows
|
139
|
-
if (defined?(::Rainbows) && defined?(::Rainbows::HttpServer)) && NewRelic::LanguageSupport.object_space_usable?
|
140
|
-
v = find_class_in_object_space(::Rainbows::HttpServer)
|
141
|
-
@discovered_dispatcher = :rainbows if v
|
142
|
-
end
|
143
|
-
end
|
144
|
-
|
145
135
|
def check_for_puma
|
146
136
|
if defined?(::Puma) && File.basename($0) == 'puma'
|
147
137
|
@discovered_dispatcher = :puma
|