newrelic_rpm 5.7.0.350 → 6.0.0.351
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.travis.yml +0 -1
- data/.yardopts +1 -0
- data/CHANGELOG.md +41 -0
- data/lib/new_relic/agent.rb +3 -3
- data/lib/new_relic/agent/agent.rb +4 -4
- data/lib/new_relic/agent/configuration/default_source.rb +3 -1
- data/lib/new_relic/agent/cross_app_monitor.rb +3 -3
- data/lib/new_relic/agent/datastores.rb +6 -8
- data/lib/new_relic/agent/datastores/metric_helper.rb +1 -2
- data/lib/new_relic/agent/distributed_trace_monitor.rb +1 -2
- data/lib/new_relic/agent/error_collector.rb +1 -1
- data/lib/new_relic/agent/external.rb +6 -4
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +8 -5
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +12 -8
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_job.rb +6 -7
- data/lib/new_relic/agent/instrumentation/active_record.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +2 -2
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/acts_as_solr.rb +1 -1
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +9 -3
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +1 -1
- data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grape.rb +4 -2
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +1 -1
- data/lib/new_relic/agent/instrumentation/middleware_tracing.rb +11 -4
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rake.rb +2 -3
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +3 -3
- data/lib/new_relic/agent/javascript_instrumentor.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +9 -8
- data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +3 -3
- data/lib/new_relic/agent/stats_engine.rb +2 -2
- data/lib/new_relic/agent/synthetics_monitor.rb +1 -2
- data/lib/new_relic/agent/threading/agent_thread.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +462 -0
- data/lib/new_relic/agent/transaction.rb +40 -87
- data/lib/new_relic/agent/transaction/abstract_segment.rb +1 -1
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +1 -2
- data/lib/new_relic/agent/transaction/tracing.rb +0 -99
- data/lib/new_relic/agent/transaction_time_aggregator.rb +1 -2
- data/lib/new_relic/control/frameworks/rails6.rb +14 -0
- data/lib/new_relic/rack/agent_middleware.rb +1 -1
- data/lib/new_relic/version.rb +2 -2
- data/test/agent_helper.rb +2 -2
- metadata +4 -3
- data/lib/new_relic/agent/transaction_state.rb +0 -186
@@ -11,6 +11,7 @@ require 'new_relic/agent/transaction/tracing'
|
|
11
11
|
require 'new_relic/agent/transaction/distributed_tracing'
|
12
12
|
require 'new_relic/agent/cross_app_tracing'
|
13
13
|
require 'new_relic/agent/transaction_time_aggregator'
|
14
|
+
require 'new_relic/agent/deprecator'
|
14
15
|
|
15
16
|
module NewRelic
|
16
17
|
module Agent
|
@@ -36,7 +37,7 @@ module NewRelic
|
|
36
37
|
ACTION_CABLE_PREFIX = 'Controller/ActionCable/'.freeze
|
37
38
|
OTHER_TRANSACTION_PREFIX = 'OtherTransaction/'.freeze
|
38
39
|
|
39
|
-
WEB_TRANSACTION_CATEGORIES = [:controller, :uri, :rack, :sinatra, :grape, :middleware, :action_cable].freeze
|
40
|
+
WEB_TRANSACTION_CATEGORIES = [:web, :controller, :uri, :rack, :sinatra, :grape, :middleware, :action_cable].freeze
|
40
41
|
TRANSACTION_NAMING_SOURCES = [:child, :api].freeze
|
41
42
|
|
42
43
|
MIDDLEWARE_SUMMARY_METRICS = ['Middleware/all'.freeze].freeze
|
@@ -64,7 +65,6 @@ module NewRelic
|
|
64
65
|
:metrics,
|
65
66
|
:gc_start_snapshot,
|
66
67
|
:category,
|
67
|
-
:frame_stack,
|
68
68
|
:attributes,
|
69
69
|
:payload,
|
70
70
|
:nesting_max_depth,
|
@@ -83,28 +83,37 @@ module NewRelic
|
|
83
83
|
|
84
84
|
# Return the currently active transaction, or nil.
|
85
85
|
def self.tl_current
|
86
|
-
|
86
|
+
Tracer.current_transaction
|
87
87
|
end
|
88
88
|
|
89
|
-
def self.set_default_transaction_name(
|
89
|
+
def self.set_default_transaction_name(partial_name, category = nil) #THREAD_LOCAL_ACCESS
|
90
90
|
txn = tl_current
|
91
|
-
name =
|
92
|
-
txn.name_last_frame(node_name || name)
|
91
|
+
name = name_from_partial(partial_name, category || txn.category)
|
93
92
|
txn.set_default_transaction_name(name, category)
|
94
93
|
end
|
95
94
|
|
96
|
-
def self.set_overriding_transaction_name(
|
95
|
+
def self.set_overriding_transaction_name(partial_name, category = nil) #THREAD_LOCAL_ACCESS
|
97
96
|
txn = tl_current
|
98
97
|
return unless txn
|
99
98
|
|
100
|
-
name =
|
101
|
-
|
102
|
-
txn.name_last_frame(name)
|
99
|
+
name = name_from_partial(partial_name, category || txn.category)
|
103
100
|
txn.set_overriding_transaction_name(name, category)
|
104
101
|
end
|
105
102
|
|
103
|
+
def self.name_from_partial(partial_name, category)
|
104
|
+
namer = Instrumentation::ControllerInstrumentation::TransactionNamer
|
105
|
+
"#{namer.prefix_for_category(self, category)}#{partial_name}"
|
106
|
+
end
|
107
|
+
|
106
108
|
def self.wrap(state, name, category, options = {})
|
107
|
-
Transaction.
|
109
|
+
Deprecator.deprecate 'Transaction.wrap',
|
110
|
+
'Tracer#in_transaction'
|
111
|
+
|
112
|
+
finishable = Tracer.start_transaction_or_segment(
|
113
|
+
name: name,
|
114
|
+
category: category,
|
115
|
+
options: options
|
116
|
+
)
|
108
117
|
|
109
118
|
begin
|
110
119
|
# We shouldn't raise from Transaction.start, but only wrap the yield
|
@@ -114,26 +123,10 @@ module NewRelic
|
|
114
123
|
Transaction.notice_error(e)
|
115
124
|
raise e
|
116
125
|
ensure
|
117
|
-
|
126
|
+
finishable.finish if finishable
|
118
127
|
end
|
119
128
|
end
|
120
129
|
|
121
|
-
def self.start(state, category, options)
|
122
|
-
category ||= :controller
|
123
|
-
txn = state.current_transaction
|
124
|
-
|
125
|
-
if txn
|
126
|
-
txn.create_nested_frame(category, options)
|
127
|
-
else
|
128
|
-
txn = start_new_transaction(state, category, options)
|
129
|
-
end
|
130
|
-
|
131
|
-
txn
|
132
|
-
rescue => e
|
133
|
-
NewRelic::Agent.logger.error("Exception during Transaction.start", e)
|
134
|
-
nil
|
135
|
-
end
|
136
|
-
|
137
130
|
def self.start_new_transaction(state, category, options)
|
138
131
|
txn = Transaction.new(category, options)
|
139
132
|
state.reset(txn)
|
@@ -142,32 +135,6 @@ module NewRelic
|
|
142
135
|
txn
|
143
136
|
end
|
144
137
|
|
145
|
-
FAILED_TO_STOP_MESSAGE = "Failed during Transaction.stop because there is no current transaction"
|
146
|
-
|
147
|
-
def self.stop(state)
|
148
|
-
txn = state.current_transaction
|
149
|
-
|
150
|
-
if txn.nil?
|
151
|
-
NewRelic::Agent.logger.error(FAILED_TO_STOP_MESSAGE)
|
152
|
-
return
|
153
|
-
end
|
154
|
-
|
155
|
-
nested_frame = txn.frame_stack.pop
|
156
|
-
|
157
|
-
if txn.frame_stack.empty?
|
158
|
-
txn.stop(nested_frame) if nested_frame
|
159
|
-
state.reset
|
160
|
-
else
|
161
|
-
nested_frame.finish
|
162
|
-
end
|
163
|
-
|
164
|
-
:transaction_stopped
|
165
|
-
rescue => e
|
166
|
-
state.reset
|
167
|
-
NewRelic::Agent.logger.error("Exception during Transaction.stop", e)
|
168
|
-
nil
|
169
|
-
end
|
170
|
-
|
171
138
|
def self.nested_transaction_name(name)
|
172
139
|
if name.start_with?(CONTROLLER_PREFIX) || name.start_with?(OTHER_TRANSACTION_PREFIX)
|
173
140
|
"#{SUBTRANSACTION_PREFIX}#{name}"
|
@@ -179,15 +146,13 @@ module NewRelic
|
|
179
146
|
# Indicate that you don't want to keep the currently saved transaction
|
180
147
|
# information
|
181
148
|
def self.abort_transaction! #THREAD_LOCAL_ACCESS
|
182
|
-
|
183
|
-
txn = state.current_transaction
|
149
|
+
txn = Tracer.current_transaction
|
184
150
|
txn.abort_transaction! if txn
|
185
151
|
end
|
186
152
|
|
187
153
|
# See NewRelic::Agent.notice_error for options and commentary
|
188
154
|
def self.notice_error(e, options={}) #THREAD_LOCAL_ACCESS
|
189
|
-
|
190
|
-
txn = state.current_transaction
|
155
|
+
txn = Tracer.current_transaction
|
191
156
|
if txn
|
192
157
|
txn.notice_error(e, options)
|
193
158
|
elsif NewRelic::Agent.instance
|
@@ -260,7 +225,6 @@ module NewRelic
|
|
260
225
|
@nesting_max_depth = 0
|
261
226
|
@current_segment = nil
|
262
227
|
@segments = []
|
263
|
-
@frame_stack = []
|
264
228
|
|
265
229
|
self.default_name = options[:transaction_name]
|
266
230
|
@overridden_name = nil
|
@@ -359,11 +323,6 @@ module NewRelic
|
|
359
323
|
merge_untrusted_agent_attributes(params, :'request.parameters', AttributeFilter::DST_NONE)
|
360
324
|
end
|
361
325
|
|
362
|
-
def make_transaction_name(name, category=nil)
|
363
|
-
namer = Instrumentation::ControllerInstrumentation::TransactionNamer
|
364
|
-
"#{namer.prefix_for_category(self, category)}#{name}"
|
365
|
-
end
|
366
|
-
|
367
326
|
def set_default_transaction_name(name, category)
|
368
327
|
return log_frozen_name(name) if name_frozen?
|
369
328
|
if influences_transaction_name?(category)
|
@@ -380,18 +339,13 @@ module NewRelic
|
|
380
339
|
end
|
381
340
|
end
|
382
341
|
|
383
|
-
def name_last_frame(name)
|
384
|
-
name = self.class.nested_transaction_name(name) if nesting_max_depth > 1
|
385
|
-
frame_stack.last.name = name
|
386
|
-
end
|
387
|
-
|
388
342
|
def log_frozen_name(name)
|
389
343
|
NewRelic::Agent.logger.warn("Attempted to rename transaction to '#{name}' after transaction name was already frozen as '#{@frozen_name}'.")
|
390
344
|
nil
|
391
345
|
end
|
392
346
|
|
393
347
|
def influences_transaction_name?(category)
|
394
|
-
!category ||
|
348
|
+
!category || nesting_max_depth == 1 || similar_category?(category)
|
395
349
|
end
|
396
350
|
|
397
351
|
def best_name
|
@@ -405,10 +359,6 @@ module NewRelic
|
|
405
359
|
attr_accessor :xray_session_id
|
406
360
|
# End common interface
|
407
361
|
|
408
|
-
def name_set?
|
409
|
-
(@overridden_name || @default_name) ? true : false
|
410
|
-
end
|
411
|
-
|
412
362
|
def promoted_transaction_name(name)
|
413
363
|
if name.start_with?(MIDDLEWARE_PREFIX)
|
414
364
|
"#{CONTROLLER_PREFIX}#{name}"
|
@@ -449,14 +399,14 @@ module NewRelic
|
|
449
399
|
|
450
400
|
ignore! if user_defined_rules_ignore?
|
451
401
|
|
452
|
-
create_initial_segment
|
402
|
+
create_initial_segment
|
453
403
|
end
|
454
404
|
|
455
405
|
def initial_segment
|
456
406
|
segments.first
|
457
407
|
end
|
458
408
|
|
459
|
-
def create_initial_segment
|
409
|
+
def create_initial_segment
|
460
410
|
segment = create_segment @default_name
|
461
411
|
segment.record_scoped_metric = false
|
462
412
|
end
|
@@ -470,16 +420,15 @@ module NewRelic
|
|
470
420
|
|
471
421
|
@nesting_max_depth += 1
|
472
422
|
|
473
|
-
segment =
|
423
|
+
segment = Tracer.start_segment(
|
474
424
|
name: name,
|
475
425
|
unscoped_metrics: summary_metrics
|
476
426
|
)
|
477
427
|
|
478
|
-
frame_stack.push segment
|
479
428
|
segment
|
480
429
|
end
|
481
430
|
|
482
|
-
def
|
431
|
+
def create_nested_segment(category, options)
|
483
432
|
if options[:filtered_params] && !options[:filtered_params].empty?
|
484
433
|
@filtered_params = options[:filtered_params]
|
485
434
|
merge_request_parameters(options[:filtered_params])
|
@@ -490,8 +439,9 @@ module NewRelic
|
|
490
439
|
|
491
440
|
nest_initial_segment if nesting_max_depth == 1
|
492
441
|
nested_name = self.class.nested_transaction_name options[:transaction_name]
|
493
|
-
create_segment nested_name
|
442
|
+
result = create_segment nested_name
|
494
443
|
set_default_transaction_name(options[:transaction_name], category)
|
444
|
+
result
|
495
445
|
end
|
496
446
|
|
497
447
|
def nest_initial_segment
|
@@ -529,23 +479,26 @@ module NewRelic
|
|
529
479
|
name.start_with?(MIDDLEWARE_PREFIX)
|
530
480
|
end
|
531
481
|
|
532
|
-
def
|
533
|
-
return
|
534
|
-
return self.class.stop(state) unless outermost_frame
|
535
|
-
|
482
|
+
def finish
|
483
|
+
return unless state.is_execution_traced?
|
536
484
|
@end_time = Time.now
|
537
485
|
@duration = @end_time.to_f - @start_time.to_f
|
538
486
|
freeze_name_and_execute_if_not_ignored
|
539
487
|
|
540
488
|
if nesting_max_depth == 1
|
541
|
-
|
489
|
+
initial_segment.name = @frozen_name
|
542
490
|
end
|
543
491
|
|
544
|
-
|
492
|
+
initial_segment.finish
|
545
493
|
|
546
494
|
NewRelic::Agent::TransactionTimeAggregator.transaction_stop(@end_time, @starting_thread_id)
|
547
495
|
|
548
|
-
commit!(
|
496
|
+
commit!(initial_segment.name) unless @ignore_this_transaction
|
497
|
+
rescue => e
|
498
|
+
NewRelic::Agent.logger.error("Exception during Transaction#finish", e)
|
499
|
+
nil
|
500
|
+
ensure
|
501
|
+
state.reset
|
549
502
|
end
|
550
503
|
|
551
504
|
def user_defined_rules_ignore?
|
@@ -156,8 +156,7 @@ module NewRelic
|
|
156
156
|
!payload.parent_type.nil? &&
|
157
157
|
(!payload.transaction_id.nil? || !payload.id.nil?) &&
|
158
158
|
!payload.trace_id.nil? &&
|
159
|
-
!payload.timestamp.nil?
|
160
|
-
!payload.parent_account_id.nil?
|
159
|
+
!payload.timestamp.nil?
|
161
160
|
|
162
161
|
true
|
163
162
|
else
|
@@ -2,109 +2,10 @@
|
|
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 'new_relic/agent/transaction/segment'
|
6
|
-
require 'new_relic/agent/transaction/datastore_segment'
|
7
|
-
require 'new_relic/agent/transaction/external_request_segment'
|
8
|
-
require 'new_relic/agent/transaction/message_broker_segment'
|
9
|
-
|
10
5
|
module NewRelic
|
11
6
|
module Agent
|
12
7
|
class Transaction
|
13
8
|
module Tracing
|
14
|
-
module ClassMethods
|
15
|
-
def start_segment(name:nil,
|
16
|
-
unscoped_metrics:nil,
|
17
|
-
start_time: nil,
|
18
|
-
parent: nil)
|
19
|
-
|
20
|
-
# ruby 2.0.0 does not support required kwargs
|
21
|
-
raise ArgumentError, 'missing required argument: name' if name.nil?
|
22
|
-
|
23
|
-
segment = Segment.new name, unscoped_metrics, start_time
|
24
|
-
|
25
|
-
start_and_add_segment segment, parent
|
26
|
-
end
|
27
|
-
|
28
|
-
UNKNOWN_PRODUCT = "Unknown".freeze
|
29
|
-
UNKNOWN_OPERATION = "other".freeze
|
30
|
-
|
31
|
-
def start_datastore_segment(product: nil,
|
32
|
-
operation: nil,
|
33
|
-
collection: nil,
|
34
|
-
host: nil,
|
35
|
-
port_path_or_id: nil,
|
36
|
-
database_name: nil,
|
37
|
-
start_time: nil,
|
38
|
-
parent: nil)
|
39
|
-
|
40
|
-
product ||= UNKNOWN_PRODUCT
|
41
|
-
operation ||= UNKNOWN_OPERATION
|
42
|
-
|
43
|
-
segment = DatastoreSegment.new product, operation, collection, host, port_path_or_id, database_name
|
44
|
-
start_and_add_segment segment, parent
|
45
|
-
end
|
46
|
-
|
47
|
-
def start_external_request_segment(library: nil,
|
48
|
-
uri: nil,
|
49
|
-
procedure: nil,
|
50
|
-
start_time: nil,
|
51
|
-
parent: nil)
|
52
|
-
|
53
|
-
# ruby 2.0.0 does not support required kwargs
|
54
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
55
|
-
raise ArgumentError, 'missing required argument: uri' if uri.nil?
|
56
|
-
raise ArgumentError, 'missing required argument: procedure' if procedure.nil?
|
57
|
-
|
58
|
-
segment = ExternalRequestSegment.new library, uri, procedure, start_time
|
59
|
-
start_and_add_segment segment, parent
|
60
|
-
end
|
61
|
-
|
62
|
-
# @api private
|
63
|
-
#
|
64
|
-
def start_message_broker_segment(action: nil,
|
65
|
-
library: nil,
|
66
|
-
destination_type: nil,
|
67
|
-
destination_name: nil,
|
68
|
-
headers: nil,
|
69
|
-
parameters: nil,
|
70
|
-
start_time: nil,
|
71
|
-
parent: nil)
|
72
|
-
|
73
|
-
# ruby 2.0.0 does not support required kwargs
|
74
|
-
raise ArgumentError, 'missing required argument: action' if action.nil?
|
75
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
76
|
-
raise ArgumentError, 'missing required argument: destination_type' if destination_type.nil?
|
77
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
78
|
-
|
79
|
-
segment = MessageBrokerSegment.new(
|
80
|
-
action: action,
|
81
|
-
library: library,
|
82
|
-
destination_type: destination_type,
|
83
|
-
destination_name: destination_name,
|
84
|
-
headers: headers,
|
85
|
-
parameters: parameters,
|
86
|
-
start_time: start_time
|
87
|
-
)
|
88
|
-
start_and_add_segment segment, parent
|
89
|
-
end
|
90
|
-
|
91
|
-
private
|
92
|
-
|
93
|
-
def start_and_add_segment segment, parent = nil
|
94
|
-
state = NewRelic::Agent::TransactionState.tl_get
|
95
|
-
if (txn = state.current_transaction) && state.is_execution_traced?
|
96
|
-
txn.add_segment segment, parent
|
97
|
-
else
|
98
|
-
segment.record_metrics = false
|
99
|
-
end
|
100
|
-
segment.start
|
101
|
-
segment
|
102
|
-
end
|
103
|
-
end
|
104
|
-
|
105
|
-
def self.included base
|
106
|
-
base.extend ClassMethods
|
107
|
-
end
|
108
9
|
|
109
10
|
attr_reader :current_segment
|
110
11
|
|
@@ -131,8 +131,7 @@ module NewRelic
|
|
131
131
|
end
|
132
132
|
|
133
133
|
def log_missing_elapsed_transaction_time
|
134
|
-
|
135
|
-
transaction_name = state.current_transaction.best_name
|
134
|
+
transaction_name = Tracer.current_transaction.best_name
|
136
135
|
NewRelic::Agent.logger.warn("Unable to calculate elapsed transaction time for #{transaction_name}")
|
137
136
|
end
|
138
137
|
end
|
@@ -0,0 +1,14 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
|
4
|
+
|
5
|
+
require 'new_relic/control/frameworks/rails4'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
class Control
|
9
|
+
module Frameworks
|
10
|
+
class Rails6 < NewRelic::Control::Frameworks::Rails4
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
14
|
+
end
|
@@ -2,7 +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 'new_relic/agent/
|
5
|
+
require 'new_relic/agent/tracer'
|
6
6
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
7
7
|
require 'new_relic/agent/instrumentation/middleware_tracing'
|
8
8
|
|