newrelic_rpm 6.6.0.358 → 6.11.0
Sign up to get free protection for your applications and to get access to all the features.
Potentially problematic release.
This version of newrelic_rpm might be problematic. Click here for more details.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +65 -5
- data/CHANGELOG.md +222 -0
- data/Gemfile +5 -2
- data/Guardfile +18 -1
- data/LICENSE +1 -1
- data/Rakefile +2 -0
- data/lib/new_relic/agent.rb +89 -7
- data/lib/new_relic/agent/agent.rb +114 -55
- data/lib/new_relic/agent/agent_logger.rb +4 -0
- data/lib/new_relic/agent/attribute_filter.rb +7 -7
- data/lib/new_relic/agent/attributes.rb +150 -0
- data/lib/new_relic/agent/autostart.rb +19 -14
- data/lib/new_relic/agent/configuration/default_source.rb +127 -9
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +11 -5
- data/lib/new_relic/agent/configuration/manager.rb +0 -8
- data/lib/new_relic/agent/configuration/server_source.rb +3 -2
- data/lib/new_relic/agent/configuration/yaml_source.rb +11 -6
- data/lib/new_relic/agent/connect/request_builder.rb +5 -13
- data/lib/new_relic/agent/database.rb +1 -2
- data/lib/new_relic/agent/datastores/mongo.rb +1 -1
- data/lib/new_relic/agent/datastores/mongo/event_formatter.rb +2 -2
- data/lib/new_relic/agent/datastores/mongo/obfuscator.rb +8 -8
- data/lib/new_relic/agent/distributed_tracing.rb +155 -6
- data/lib/new_relic/agent/{cross_app_payload.rb → distributed_tracing/cross_app_payload.rb} +0 -0
- data/lib/new_relic/agent/{cross_app_tracing.rb → distributed_tracing/cross_app_tracing.rb} +60 -45
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_intrinsics.rb +80 -0
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_metrics.rb +75 -0
- data/lib/new_relic/agent/{distributed_trace_payload.rb → distributed_tracing/distributed_trace_payload.rb} +23 -99
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_transport_type.rb +39 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context.rb +246 -0
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +126 -0
- data/lib/new_relic/agent/error_collector.rb +33 -16
- data/lib/new_relic/agent/error_event_aggregator.rb +7 -5
- data/lib/new_relic/agent/external.rb +7 -7
- data/lib/new_relic/agent/guid_generator.rb +28 -0
- data/lib/new_relic/agent/hostname.rb +7 -1
- data/lib/new_relic/agent/http_clients/abstract.rb +82 -0
- data/lib/new_relic/agent/http_clients/curb_wrappers.rb +24 -19
- data/lib/new_relic/agent/http_clients/excon_wrappers.rb +28 -13
- data/lib/new_relic/agent/http_clients/http_rb_wrappers.rb +17 -21
- data/lib/new_relic/agent/http_clients/httpclient_wrappers.rb +10 -11
- data/lib/new_relic/agent/http_clients/net_http_wrappers.rb +16 -4
- data/lib/new_relic/agent/http_clients/typhoeus_wrappers.rb +4 -6
- data/lib/new_relic/agent/http_clients/uri_util.rb +3 -2
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +5 -7
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +4 -0
- data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +11 -2
- data/lib/new_relic/agent/instrumentation/active_record.rb +4 -2
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +7 -2
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +8 -4
- data/lib/new_relic/agent/instrumentation/bunny.rb +45 -28
- data/lib/new_relic/agent/instrumentation/curb.rb +59 -18
- data/lib/new_relic/agent/instrumentation/data_mapper.rb +3 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +6 -3
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +2 -1
- data/lib/new_relic/agent/instrumentation/grape.rb +5 -10
- data/lib/new_relic/agent/instrumentation/http.rb +6 -3
- data/lib/new_relic/agent/instrumentation/httpclient.rb +5 -3
- data/lib/new_relic/agent/instrumentation/memcache.rb +3 -1
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +6 -2
- data/lib/new_relic/agent/instrumentation/mongo.rb +9 -3
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +13 -0
- data/lib/new_relic/agent/instrumentation/net.rb +6 -3
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +25 -1
- data/lib/new_relic/agent/instrumentation/redis.rb +9 -3
- data/lib/new_relic/agent/instrumentation/resque.rb +3 -0
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +0 -1
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +23 -6
- data/lib/new_relic/agent/logging.rb +139 -0
- data/lib/new_relic/agent/messaging.rb +5 -73
- data/lib/new_relic/agent/method_tracer.rb +3 -2
- data/lib/new_relic/agent/method_tracer_helpers.rb +2 -2
- data/lib/new_relic/agent/monitors.rb +27 -0
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +110 -0
- data/lib/new_relic/agent/monitors/distributed_tracing_monitor.rb +27 -0
- data/lib/new_relic/agent/{inbound_request_monitor.rb → monitors/inbound_request_monitor.rb} +1 -1
- data/lib/new_relic/agent/{synthetics_monitor.rb → monitors/synthetics_monitor.rb} +2 -4
- data/lib/new_relic/agent/new_relic_service.rb +7 -5
- data/lib/new_relic/agent/noticible_error.rb +22 -0
- data/lib/new_relic/agent/span_event_aggregator.rb +1 -0
- data/lib/new_relic/agent/span_event_primitive.rb +82 -53
- data/lib/new_relic/agent/sql_sampler.rb +3 -3
- data/lib/new_relic/agent/supported_versions.rb +2 -2
- data/lib/new_relic/agent/tracer.rb +65 -18
- data/lib/new_relic/agent/transaction.rb +84 -79
- data/lib/new_relic/agent/transaction/abstract_segment.rb +28 -2
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +171 -0
- data/lib/new_relic/agent/transaction/distributed_tracing.rb +57 -146
- data/lib/new_relic/agent/transaction/external_request_segment.rb +29 -36
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +3 -11
- data/lib/new_relic/agent/transaction/segment.rb +7 -1
- data/lib/new_relic/agent/transaction/trace.rb +2 -4
- data/lib/new_relic/agent/transaction/trace_context.rb +168 -0
- data/lib/new_relic/agent/transaction/trace_node.rb +10 -8
- data/lib/new_relic/agent/transaction_error_primitive.rb +10 -15
- data/lib/new_relic/agent/transaction_event_primitive.rb +28 -39
- data/lib/new_relic/cli/commands/deployments.rb +1 -1
- data/lib/new_relic/cli/commands/install.rb +3 -2
- data/lib/new_relic/coerce.rb +31 -6
- data/lib/new_relic/constants.rb +34 -0
- data/lib/new_relic/control/instance_methods.rb +10 -1
- data/lib/new_relic/dependency_detection.rb +4 -4
- data/lib/new_relic/noticed_error.rb +38 -17
- data/lib/new_relic/rack/browser_monitoring.rb +5 -0
- data/lib/new_relic/supportability_helper.rb +14 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/multiverse.rb +25 -0
- data/lib/tasks/tests.rake +6 -1
- data/newrelic_rpm.gemspec +18 -7
- data/test/agent_helper.rb +322 -70
- metadata +98 -32
- data/lib/new_relic/agent/cross_app_monitor.rb +0 -110
- data/lib/new_relic/agent/distributed_trace_monitor.rb +0 -40
- data/lib/new_relic/agent/http_clients/abstract_request.rb +0 -31
- data/lib/new_relic/agent/transaction/attributes.rb +0 -154
- data/lib/tasks/versions.html.erb +0 -28
- data/lib/tasks/versions.postface.html +0 -8
- data/lib/tasks/versions.preface.html +0 -9
- data/lib/tasks/versions.rake +0 -65
- data/lib/tasks/versions.txt.erb +0 -14
@@ -159,10 +159,10 @@ module NewRelic
|
|
159
159
|
def distributed_trace_intrinsics(state)
|
160
160
|
transaction = state.current_transaction
|
161
161
|
params = nil
|
162
|
-
if transaction && transaction.distributed_trace_payload
|
162
|
+
if transaction && transaction.distributed_tracer.distributed_trace_payload
|
163
163
|
params = {}
|
164
|
-
payload = transaction.distributed_trace_payload
|
165
|
-
|
164
|
+
payload = transaction.distributed_tracer.distributed_trace_payload
|
165
|
+
DistributedTraceIntrinsics.copy_from_transaction transaction, payload, params
|
166
166
|
params[PRIORITY] = transaction.priority
|
167
167
|
end
|
168
168
|
params
|
@@ -11,7 +11,7 @@ module NewRelic
|
|
11
11
|
{
|
12
12
|
:type => :ruby,
|
13
13
|
:name => "MRI",
|
14
|
-
:supported => ["2.0.0", "~>2.1.0", "~>2.2.0", "~>2.3.0", "~>2.4.0", "~>2.5.0"],
|
14
|
+
:supported => ["2.0.0", "~>2.1.0", "~>2.2.0", "~>2.3.0", "~>2.4.0", "~>2.5.0", "~>2.6.0", "~>2.7.0"],
|
15
15
|
:deprecated => ["1.8.6", "1.8.7", "1.9.2", "1.9.3"],
|
16
16
|
:url => "https://www.ruby-lang.org",
|
17
17
|
:feed => "https://www.ruby-lang.org/en/feeds/news.rss",
|
@@ -119,7 +119,7 @@ module NewRelic
|
|
119
119
|
:activerecord =>
|
120
120
|
{
|
121
121
|
:type => :database,
|
122
|
-
:supported => ["~>3.0.0", "~>3.1.0", "~>3.2.0", "~>4.0.0", "~>4.1.0", "~>4.2.0", "~>5.0.0", "~>5.1.0"],
|
122
|
+
:supported => ["~>3.0.0", "~>3.1.0", "~>3.2.0", "~>4.0.0", "~>4.1.0", "~>4.2.0", "~>5.0.0", "~>5.1.0", "~>6.0.0"],
|
123
123
|
:deprecated => ["~>2.0.0", "~>2.1.0", "~>2.2.0", "~>2.3.0",],
|
124
124
|
:url => "https://rubygems.org/gems/activerecord",
|
125
125
|
:feed => "https://rubygems.org/gems/activerecord/versions.atom",
|
@@ -39,6 +39,38 @@ module NewRelic
|
|
39
39
|
state.current_transaction
|
40
40
|
end
|
41
41
|
|
42
|
+
# Returns the trace_id of the current_transaction, or +nil+ if
|
43
|
+
# none exists.
|
44
|
+
#
|
45
|
+
# @api public
|
46
|
+
def current_trace_id
|
47
|
+
if txn = current_transaction
|
48
|
+
txn.trace_id
|
49
|
+
end
|
50
|
+
end
|
51
|
+
alias_method :trace_id, :current_trace_id
|
52
|
+
|
53
|
+
# Returns the id of the current span, or +nil+ if none exists.
|
54
|
+
#
|
55
|
+
# @api public
|
56
|
+
def current_span_id
|
57
|
+
if span = current_segment
|
58
|
+
span.guid
|
59
|
+
end
|
60
|
+
end
|
61
|
+
alias_method :span_id, :current_span_id
|
62
|
+
|
63
|
+
# Returns a boolean indicating whether the current_transaction
|
64
|
+
# is sampled, or +nil+ if there is no current transaction.
|
65
|
+
#
|
66
|
+
# @api public
|
67
|
+
def transaction_sampled?
|
68
|
+
if txn = current_transaction
|
69
|
+
txn.sampled?
|
70
|
+
end
|
71
|
+
end
|
72
|
+
alias_method :sampled?, :transaction_sampled?
|
73
|
+
|
42
74
|
# Runs the given block of code in a transaction.
|
43
75
|
#
|
44
76
|
# @param [String] name reserved for New Relic internal use
|
@@ -70,9 +102,9 @@ module NewRelic
|
|
70
102
|
# only wrap the yield to be absolutely sure we don't report agent
|
71
103
|
# problems as app errors
|
72
104
|
yield
|
73
|
-
rescue =>
|
74
|
-
current_transaction.notice_error(
|
75
|
-
raise
|
105
|
+
rescue => exception
|
106
|
+
current_transaction.notice_error(exception)
|
107
|
+
raise
|
76
108
|
ensure
|
77
109
|
finishable.finish if finishable
|
78
110
|
end
|
@@ -88,7 +120,7 @@ module NewRelic
|
|
88
120
|
# New-Relic-specific prefix
|
89
121
|
#
|
90
122
|
# @param [Symbol] category +:web+ for web transactions or
|
91
|
-
# +:
|
123
|
+
# +:task+ for background transactions
|
92
124
|
#
|
93
125
|
# @param [Hash] options reserved for New Relic internal use
|
94
126
|
#
|
@@ -125,8 +157,8 @@ module NewRelic
|
|
125
157
|
|
126
158
|
rescue ArgumentError
|
127
159
|
raise
|
128
|
-
rescue =>
|
129
|
-
log_error('start_transaction_or_segment',
|
160
|
+
rescue => exception
|
161
|
+
log_error('start_transaction_or_segment', exception)
|
130
162
|
end
|
131
163
|
|
132
164
|
# Takes name or partial_name and a category.
|
@@ -158,18 +190,18 @@ module NewRelic
|
|
158
190
|
options)
|
159
191
|
rescue ArgumentError
|
160
192
|
raise
|
161
|
-
rescue =>
|
162
|
-
log_error('start_transaction',
|
193
|
+
rescue => exception
|
194
|
+
log_error('start_transaction', exception)
|
163
195
|
end
|
164
196
|
|
165
197
|
def create_distributed_trace_payload
|
166
198
|
return unless txn = current_transaction
|
167
|
-
txn.create_distributed_trace_payload
|
199
|
+
txn.distributed_tracer.create_distributed_trace_payload
|
168
200
|
end
|
169
201
|
|
170
202
|
def accept_distributed_trace_payload(payload)
|
171
203
|
return unless txn = current_transaction
|
172
|
-
txn.accept_distributed_trace_payload(payload)
|
204
|
+
txn.distributed_tracer.accept_distributed_trace_payload(payload)
|
173
205
|
end
|
174
206
|
|
175
207
|
# Returns the currently active segment in the transaction in
|
@@ -219,8 +251,8 @@ module NewRelic
|
|
219
251
|
|
220
252
|
rescue ArgumentError
|
221
253
|
raise
|
222
|
-
rescue =>
|
223
|
-
log_error('start_segment',
|
254
|
+
rescue => exception
|
255
|
+
log_error('start_segment', exception)
|
224
256
|
end
|
225
257
|
|
226
258
|
UNKNOWN = "Unknown".freeze
|
@@ -278,8 +310,8 @@ module NewRelic
|
|
278
310
|
|
279
311
|
rescue ArgumentError
|
280
312
|
raise
|
281
|
-
rescue =>
|
282
|
-
log_error('start_datastore_segment',
|
313
|
+
rescue => exception
|
314
|
+
log_error('start_datastore_segment', exception)
|
283
315
|
end
|
284
316
|
|
285
317
|
# Creates and starts an external request segment using the
|
@@ -325,8 +357,23 @@ module NewRelic
|
|
325
357
|
|
326
358
|
rescue ArgumentError
|
327
359
|
raise
|
328
|
-
rescue =>
|
329
|
-
log_error('start_external_request_segment',
|
360
|
+
rescue => exception
|
361
|
+
log_error('start_external_request_segment', exception)
|
362
|
+
end
|
363
|
+
|
364
|
+
# Will potentially capture and notice an error at the
|
365
|
+
# segment that was executing when error occurred.
|
366
|
+
# if passed +segment+ is something that doesn't
|
367
|
+
# respond to +notice_segment_error+ then this method
|
368
|
+
# is effectively just a yield to the given &block
|
369
|
+
def capture_segment_error segment
|
370
|
+
return unless block_given?
|
371
|
+
yield
|
372
|
+
rescue => exception
|
373
|
+
if segment && segment.is_a?(Transaction::AbstractSegment)
|
374
|
+
segment.notice_error exception
|
375
|
+
end
|
376
|
+
raise
|
330
377
|
end
|
331
378
|
|
332
379
|
# For New Relic internal use only.
|
@@ -358,8 +405,8 @@ module NewRelic
|
|
358
405
|
|
359
406
|
rescue ArgumentError
|
360
407
|
raise
|
361
|
-
rescue =>
|
362
|
-
log_error('start_datastore_segment',
|
408
|
+
rescue => exception
|
409
|
+
log_error('start_datastore_segment', exception)
|
363
410
|
end
|
364
411
|
|
365
412
|
# This method should only be used by Tracer for access to the
|
@@ -1,17 +1,18 @@
|
|
1
1
|
# encoding: utf-8
|
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
|
+
# frozen_string_literal: true
|
4
5
|
|
5
6
|
require 'new_relic/agent/instrumentation/queue_time'
|
6
7
|
require 'new_relic/agent/transaction_metrics'
|
7
8
|
require 'new_relic/agent/method_tracer_helpers'
|
8
|
-
require 'new_relic/agent/
|
9
|
+
require 'new_relic/agent/attributes'
|
9
10
|
require 'new_relic/agent/transaction/request_attributes'
|
10
11
|
require 'new_relic/agent/transaction/tracing'
|
11
|
-
require 'new_relic/agent/transaction/
|
12
|
-
require 'new_relic/agent/cross_app_tracing'
|
12
|
+
require 'new_relic/agent/transaction/distributed_tracer'
|
13
13
|
require 'new_relic/agent/transaction_time_aggregator'
|
14
14
|
require 'new_relic/agent/deprecator'
|
15
|
+
require 'new_relic/agent/guid_generator'
|
15
16
|
|
16
17
|
module NewRelic
|
17
18
|
module Agent
|
@@ -21,26 +22,38 @@ module NewRelic
|
|
21
22
|
# @api public
|
22
23
|
class Transaction
|
23
24
|
include Tracing
|
24
|
-
include DistributedTracing
|
25
|
-
include CrossAppTracing
|
26
25
|
|
27
26
|
# for nested transactions
|
28
|
-
|
29
|
-
CONTROLLER_PREFIX =
|
30
|
-
MIDDLEWARE_PREFIX =
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
27
|
+
NESTED_TRANSACTION_PREFIX = "Nested/"
|
28
|
+
CONTROLLER_PREFIX = "Controller/"
|
29
|
+
MIDDLEWARE_PREFIX = "Middleware/Rack/"
|
30
|
+
OTHER_TRANSACTION_PREFIX = "OtherTransaction/"
|
31
|
+
TASK_PREFIX = "#{OTHER_TRANSACTION_PREFIX}Background/"
|
32
|
+
RAKE_PREFIX = "#{OTHER_TRANSACTION_PREFIX}Rake/"
|
33
|
+
MESSAGE_PREFIX = "#{OTHER_TRANSACTION_PREFIX}Message/"
|
34
|
+
RACK_PREFIX = "#{CONTROLLER_PREFIX}Rack/"
|
35
|
+
SINATRA_PREFIX = "#{CONTROLLER_PREFIX}Sinatra/"
|
36
|
+
GRAPE_PREFIX = "#{CONTROLLER_PREFIX}Grape/"
|
37
|
+
ACTION_CABLE_PREFIX = "#{CONTROLLER_PREFIX}ActionCable/"
|
39
38
|
|
40
39
|
WEB_TRANSACTION_CATEGORIES = [:web, :controller, :uri, :rack, :sinatra, :grape, :middleware, :action_cable].freeze
|
41
40
|
TRANSACTION_NAMING_SOURCES = [:child, :api].freeze
|
42
41
|
|
43
|
-
MIDDLEWARE_SUMMARY_METRICS = [
|
42
|
+
MIDDLEWARE_SUMMARY_METRICS = ["Middleware/all"].freeze
|
43
|
+
WEB_SUMMARY_METRIC = "HttpDispatcher"
|
44
|
+
OTHER_SUMMARY_METRIC = "#{OTHER_TRANSACTION_PREFIX}all"
|
45
|
+
QUEUE_TIME_METRIC = "WebFrontend/QueueTime"
|
46
|
+
|
47
|
+
APDEX_S = "S"
|
48
|
+
APDEX_T = "T"
|
49
|
+
APDEX_F = "F"
|
50
|
+
APDEX_ALL_METRIC = "ApdexAll"
|
51
|
+
APDEX_METRIC = "Apdex"
|
52
|
+
APDEX_OTHER_METRIC = "ApdexOther"
|
53
|
+
APDEX_TXN_METRIC_PREFIX = "Apdex/"
|
54
|
+
APDEX_OTHER_TXN_METRIC_PREFIX = "ApdexOther/Transaction/"
|
55
|
+
|
56
|
+
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time"
|
44
57
|
|
45
58
|
# reference to the transaction state managing this transaction
|
46
59
|
attr_accessor :state
|
@@ -59,7 +72,8 @@ module NewRelic
|
|
59
72
|
:process_cpu_start,
|
60
73
|
:http_response_code,
|
61
74
|
:response_content_length,
|
62
|
-
:response_content_type
|
75
|
+
:response_content_type,
|
76
|
+
:parent_span_id
|
63
77
|
|
64
78
|
attr_reader :guid,
|
65
79
|
:metrics,
|
@@ -137,23 +151,22 @@ module NewRelic
|
|
137
151
|
|
138
152
|
def self.nested_transaction_name(name)
|
139
153
|
if name.start_with?(CONTROLLER_PREFIX) || name.start_with?(OTHER_TRANSACTION_PREFIX)
|
140
|
-
"#{
|
154
|
+
"#{NESTED_TRANSACTION_PREFIX}#{name}"
|
141
155
|
else
|
142
156
|
name
|
143
157
|
end
|
144
158
|
end
|
145
159
|
|
146
|
-
#
|
147
|
-
|
148
|
-
|
149
|
-
|
150
|
-
|
160
|
+
# discards the currently saved transaction information
|
161
|
+
def self.abort_transaction!
|
162
|
+
if txn = Tracer.current_transaction
|
163
|
+
txn.abort_transaction!
|
164
|
+
end
|
151
165
|
end
|
152
166
|
|
153
167
|
# See NewRelic::Agent.notice_error for options and commentary
|
154
|
-
def self.notice_error(e, options={})
|
155
|
-
txn = Tracer.current_transaction
|
156
|
-
if txn
|
168
|
+
def self.notice_error(e, options={})
|
169
|
+
if txn = Tracer.current_transaction
|
157
170
|
txn.notice_error(e, options)
|
158
171
|
elsif NewRelic::Agent.instance
|
159
172
|
NewRelic::Agent.instance.error_collector.notice_error(e, options)
|
@@ -242,7 +255,7 @@ module NewRelic
|
|
242
255
|
|
243
256
|
@exceptions = {}
|
244
257
|
@metrics = TransactionMetrics.new
|
245
|
-
@guid = generate_guid
|
258
|
+
@guid = NewRelic::Agent::GuidGenerator.generate_guid
|
246
259
|
|
247
260
|
@ignore_this_transaction = false
|
248
261
|
@ignore_apdex = options.fetch(:ignore_apdex, false)
|
@@ -265,6 +278,10 @@ module NewRelic
|
|
265
278
|
end
|
266
279
|
end
|
267
280
|
|
281
|
+
def distributed_tracer
|
282
|
+
@distributed_tracer ||= DistributedTracer.new(self)
|
283
|
+
end
|
284
|
+
|
268
285
|
def sampled?
|
269
286
|
return unless Agent.config[:'distributed_tracing.enabled']
|
270
287
|
if @sampled.nil?
|
@@ -273,12 +290,16 @@ module NewRelic
|
|
273
290
|
@sampled
|
274
291
|
end
|
275
292
|
|
293
|
+
def trace_id
|
294
|
+
@trace_id ||= NewRelic::Agent::GuidGenerator.generate_guid 32
|
295
|
+
end
|
296
|
+
|
297
|
+
def trace_id=(value)
|
298
|
+
@trace_id = value
|
299
|
+
end
|
300
|
+
|
276
301
|
def priority
|
277
|
-
|
278
|
-
@priority = rand.round(6)
|
279
|
-
@priority += 1 if sampled?
|
280
|
-
end
|
281
|
-
@priority
|
302
|
+
@priority ||= (sampled? ? 1.0 + rand : rand).round(NewRelic::PRIORITY_PRECISION)
|
282
303
|
end
|
283
304
|
|
284
305
|
def referer
|
@@ -349,8 +370,10 @@ module NewRelic
|
|
349
370
|
end
|
350
371
|
|
351
372
|
def best_name
|
352
|
-
@frozen_name
|
353
|
-
|
373
|
+
@frozen_name ||
|
374
|
+
@overridden_name ||
|
375
|
+
@default_name ||
|
376
|
+
NewRelic::Agent::UNKNOWN_METRIC
|
354
377
|
end
|
355
378
|
|
356
379
|
# For common interface with Trace
|
@@ -437,9 +460,9 @@ module NewRelic
|
|
437
460
|
|
438
461
|
nest_initial_segment if nesting_max_depth == 1
|
439
462
|
nested_name = self.class.nested_transaction_name options[:transaction_name]
|
440
|
-
|
463
|
+
segment = create_segment nested_name
|
441
464
|
set_default_transaction_name(options[:transaction_name], category)
|
442
|
-
|
465
|
+
segment
|
443
466
|
end
|
444
467
|
|
445
468
|
def nest_initial_segment
|
@@ -453,9 +476,6 @@ module NewRelic
|
|
453
476
|
@ignore_trace = true
|
454
477
|
end
|
455
478
|
|
456
|
-
WEB_SUMMARY_METRIC = 'HttpDispatcher'.freeze
|
457
|
-
OTHER_SUMMARY_METRIC = 'OtherTransaction/all'.freeze
|
458
|
-
|
459
479
|
def summary_metrics
|
460
480
|
if @frozen_name.start_with?(CONTROLLER_PREFIX)
|
461
481
|
[WEB_SUMMARY_METRIC]
|
@@ -523,8 +543,7 @@ module NewRelic
|
|
523
543
|
record_total_time_metrics
|
524
544
|
record_apdex unless ignore_apdex?
|
525
545
|
record_queue_time
|
526
|
-
|
527
|
-
record_distributed_tracing_metrics
|
546
|
+
distributed_tracer.record_metrics
|
528
547
|
|
529
548
|
record_exceptions
|
530
549
|
record_transaction_event
|
@@ -576,11 +595,7 @@ module NewRelic
|
|
576
595
|
attributes.add_intrinsic_attribute(:synthetics_monitor_id, synthetics_monitor_id)
|
577
596
|
end
|
578
597
|
|
579
|
-
|
580
|
-
assign_distributed_trace_intrinsics
|
581
|
-
elsif is_cross_app?
|
582
|
-
assign_cross_app_intrinsics
|
583
|
-
end
|
598
|
+
distributed_tracer.assign_intrinsics
|
584
599
|
end
|
585
600
|
|
586
601
|
def calculate_gc_time
|
@@ -588,6 +603,16 @@ module NewRelic
|
|
588
603
|
NewRelic::Agent::StatsEngine::GCProfiler.record_delta(gc_start_snapshot, gc_stop_snapshot)
|
589
604
|
end
|
590
605
|
|
606
|
+
# This method returns transport_duration in seconds. Transport duration
|
607
|
+
# is stored in milliseconds on the payload, but it's needed in seconds
|
608
|
+
# for metrics and intrinsics.
|
609
|
+
def calculate_transport_duration distributed_trace_payload
|
610
|
+
return unless distributed_trace_payload
|
611
|
+
|
612
|
+
duration = (start_time.to_f * 1000 - distributed_trace_payload.timestamp) / 1000
|
613
|
+
duration < 0 ? 0 : duration
|
614
|
+
end
|
615
|
+
|
591
616
|
# The summary metrics recorded by this method all end up with a duration
|
592
617
|
# equal to the transaction itself, and an exclusive time of zero.
|
593
618
|
def record_summary_metrics(outermost_node_name)
|
@@ -614,14 +639,13 @@ module NewRelic
|
|
614
639
|
:priority => priority
|
615
640
|
}
|
616
641
|
|
617
|
-
|
618
|
-
append_distributed_trace_info(@payload)
|
642
|
+
distributed_tracer.append_payload(@payload)
|
619
643
|
append_apdex_perf_zone(@payload)
|
620
644
|
append_synthetics_to(@payload)
|
621
645
|
end
|
622
646
|
|
623
647
|
def include_guid?
|
624
|
-
is_cross_app? || is_synthetics_request?
|
648
|
+
distributed_tracer.is_cross_app? || is_synthetics_request?
|
625
649
|
end
|
626
650
|
|
627
651
|
def is_synthetics_request?
|
@@ -653,10 +677,6 @@ module NewRelic
|
|
653
677
|
info[4]
|
654
678
|
end
|
655
679
|
|
656
|
-
APDEX_S = 'S'.freeze
|
657
|
-
APDEX_T = 'T'.freeze
|
658
|
-
APDEX_F = 'F'.freeze
|
659
|
-
|
660
680
|
def append_apdex_perf_zone(payload)
|
661
681
|
if recording_web_transaction?
|
662
682
|
bucket = apdex_bucket(duration, apdex_t)
|
@@ -695,13 +715,21 @@ module NewRelic
|
|
695
715
|
options[:metric] = best_name
|
696
716
|
options[:attributes] = @attributes
|
697
717
|
|
698
|
-
|
718
|
+
span_id = options.delete :span_id
|
719
|
+
error_recorded = !!agent.error_collector.notice_error(exception, options, span_id) || error_recorded
|
699
720
|
end
|
700
721
|
payload[:error] = error_recorded if payload
|
701
722
|
end
|
702
723
|
|
703
724
|
# Do not call this. Invoke the class method instead.
|
704
725
|
def notice_error(error, options={}) # :nodoc:
|
726
|
+
|
727
|
+
# Only the last error is kept
|
728
|
+
if @current_segment
|
729
|
+
@current_segment.notice_error error, expected: options[:expected]
|
730
|
+
options[:span_id] = @current_segment.guid
|
731
|
+
end
|
732
|
+
|
705
733
|
if @exceptions[error]
|
706
734
|
@exceptions[error].merge! options
|
707
735
|
else
|
@@ -713,8 +741,6 @@ module NewRelic
|
|
713
741
|
agent.transaction_event_recorder.record payload
|
714
742
|
end
|
715
743
|
|
716
|
-
QUEUE_TIME_METRIC = 'WebFrontend/QueueTime'.freeze
|
717
|
-
|
718
744
|
def queue_time
|
719
745
|
@apdex_start ? @start_time - @apdex_start : 0
|
720
746
|
end
|
@@ -730,17 +756,9 @@ module NewRelic
|
|
730
756
|
end
|
731
757
|
end
|
732
758
|
|
733
|
-
APDEX_ALL_METRIC = 'ApdexAll'.freeze
|
734
|
-
|
735
|
-
APDEX_METRIC = 'Apdex'.freeze
|
736
|
-
APDEX_OTHER_METRIC = 'ApdexOther'.freeze
|
737
|
-
|
738
|
-
APDEX_TXN_METRIC_PREFIX = 'Apdex/'.freeze
|
739
|
-
APDEX_OTHER_TXN_METRIC_PREFIX = 'ApdexOther/Transaction/'.freeze
|
740
|
-
|
741
759
|
def had_error_affecting_apdex?
|
742
760
|
@exceptions.each do |exception, options|
|
743
|
-
ignored
|
761
|
+
ignored = NewRelic::Agent.instance.error_collector.error_is_ignored?(exception)
|
744
762
|
expected = options[:expected]
|
745
763
|
|
746
764
|
return true unless ignored || expected
|
@@ -879,7 +897,6 @@ module NewRelic
|
|
879
897
|
p.stime + p.utime
|
880
898
|
end
|
881
899
|
|
882
|
-
JRUBY_CPU_TIME_ERROR = "Error calculating JRuby CPU Time".freeze
|
883
900
|
def jruby_cpu_time
|
884
901
|
return nil unless @@java_classes_loaded
|
885
902
|
threadMBean = Java::JavaLangManagement::ManagementFactory.getThreadMXBean()
|
@@ -905,18 +922,6 @@ module NewRelic
|
|
905
922
|
def sql_sampler
|
906
923
|
agent.sql_sampler
|
907
924
|
end
|
908
|
-
|
909
|
-
HEX_DIGITS = (0..15).map{|i| i.to_s(16)}
|
910
|
-
GUID_LENGTH = 16
|
911
|
-
|
912
|
-
# generate a random 64 bit uuid
|
913
|
-
def generate_guid
|
914
|
-
guid = ''
|
915
|
-
GUID_LENGTH.times do |a|
|
916
|
-
guid << HEX_DIGITS[rand(16)]
|
917
|
-
end
|
918
|
-
guid
|
919
|
-
end
|
920
925
|
end
|
921
926
|
end
|
922
927
|
end
|