newrelic_rpm 6.4.0.356 → 6.9.0.363
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +1 -0
- data/.travis.yml +50 -5
- data/CHANGELOG.md +218 -0
- data/Guardfile +16 -1
- data/lib/new_relic/agent.rb +86 -5
- data/lib/new_relic/agent/agent.rb +124 -56
- 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 +133 -14
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +45 -0
- data/lib/new_relic/agent/configuration/manager.rb +13 -9
- data/lib/new_relic/agent/configuration/server_source.rb +34 -10
- data/lib/new_relic/agent/configuration/yaml_source.rb +11 -6
- data/lib/new_relic/agent/connect/request_builder.rb +8 -15
- data/lib/new_relic/agent/connect/response_handler.rb +1 -1
- data/lib/new_relic/agent/database.rb +1 -2
- 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 +5 -7
- data/lib/new_relic/agent/error_event_aggregator.rb +5 -2
- data/lib/new_relic/agent/error_trace_aggregator.rb +1 -0
- data/lib/new_relic/agent/event_aggregator.rb +26 -32
- data/lib/new_relic/agent/external.rb +7 -7
- data/lib/new_relic/agent/guid_generator.rb +28 -0
- data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +1 -2
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +24 -38
- data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +2 -2
- data/lib/new_relic/agent/instrumentation/bunny.rb +1 -1
- data/lib/new_relic/agent/instrumentation/curb.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grape.rb +5 -10
- data/lib/new_relic/agent/instrumentation/http.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient.rb +1 -1
- data/lib/new_relic/agent/instrumentation/net.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb +2 -3
- data/lib/new_relic/agent/instrumentation/resque.rb +3 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +1 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +1 -1
- 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 +1 -1
- 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} +3 -3
- 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/priority_sampled_buffer.rb +2 -0
- data/lib/new_relic/agent/span_event_aggregator.rb +2 -4
- data/lib/new_relic/agent/span_event_primitive.rb +43 -25
- 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 +35 -3
- data/lib/new_relic/agent/transaction.rb +37 -36
- data/lib/new_relic/agent/transaction/abstract_segment.rb +2 -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 +8 -31
- 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 +5 -12
- data/lib/new_relic/agent/transaction_event_primitive.rb +28 -39
- data/lib/new_relic/agent/transaction_event_recorder.rb +3 -3
- data/lib/new_relic/cli/commands/deployments.rb +1 -1
- 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 +10 -8
- data/lib/new_relic/rack/browser_monitoring.rb +4 -0
- data/lib/new_relic/supportability_helper.rb +14 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/tests.rake +6 -1
- data/newrelic_rpm.gemspec +16 -5
- data/test/agent_helper.rb +115 -9
- data/true +0 -0
- metadata +97 -30
- data/lib/new_relic/agent/configuration/event_data.rb +0 -39
- 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/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
@@ -0,0 +1,27 @@
|
|
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_relative 'monitors/inbound_request_monitor'
|
6
|
+
|
7
|
+
require_relative 'monitors/synthetics_monitor'
|
8
|
+
|
9
|
+
require_relative 'monitors/cross_app_monitor'
|
10
|
+
require_relative 'monitors/distributed_tracing_monitor'
|
11
|
+
|
12
|
+
module NewRelic
|
13
|
+
module Agent
|
14
|
+
class Monitors
|
15
|
+
attr_reader :cross_app_monitor
|
16
|
+
attr_reader :synthetics_monitor
|
17
|
+
attr_reader :distributed_tracing_monitor
|
18
|
+
|
19
|
+
def initialize events
|
20
|
+
@synthetics_monitor = NewRelic::Agent::SyntheticsMonitor.new events
|
21
|
+
@cross_app_monitor = NewRelic::Agent::DistributedTracing::CrossAppMonitor.new events
|
22
|
+
@distributed_tracing_monitor = NewRelic::Agent::DistributedTracing::Monitor.new events
|
23
|
+
end
|
24
|
+
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -0,0 +1,110 @@
|
|
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 'digest'
|
6
|
+
require 'json'
|
7
|
+
|
8
|
+
require 'new_relic/agent/tracer'
|
9
|
+
require 'new_relic/agent/threading/agent_thread'
|
10
|
+
|
11
|
+
module NewRelic
|
12
|
+
module Agent
|
13
|
+
module DistributedTracing
|
14
|
+
class CrossAppMonitor < InboundRequestMonitor
|
15
|
+
|
16
|
+
NEWRELIC_ID_HEADER = 'X-NewRelic-ID'.freeze
|
17
|
+
NEWRELIC_TXN_HEADER = 'X-NewRelic-Transaction'.freeze
|
18
|
+
NEWRELIC_APPDATA_HEADER = 'X-NewRelic-App-Data'.freeze
|
19
|
+
|
20
|
+
NEWRELIC_ID_HEADER_KEY = 'HTTP_X_NEWRELIC_ID'.freeze
|
21
|
+
NEWRELIC_TXN_HEADER_KEY = 'HTTP_X_NEWRELIC_TRANSACTION'.freeze
|
22
|
+
CONTENT_LENGTH_HEADER_KEY = 'HTTP_CONTENT_LENGTH'.freeze
|
23
|
+
|
24
|
+
def on_finished_configuring(events)
|
25
|
+
register_event_listeners(events)
|
26
|
+
end
|
27
|
+
|
28
|
+
def path_hash(txn_name, seed)
|
29
|
+
rotated = ((seed << 1) | (seed >> 31)) & 0xffffffff
|
30
|
+
app_name = NewRelic::Agent.config[:app_name].first
|
31
|
+
identifier = "#{app_name};#{txn_name}"
|
32
|
+
sprintf("%08x", rotated ^ hash_transaction_name(identifier))
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
# Expected sequence of events:
|
38
|
+
# :before_call will save our cross application request id to the thread
|
39
|
+
# :after_call will write our response headers/metrics and clean up the thread
|
40
|
+
def register_event_listeners(events)
|
41
|
+
NewRelic::Agent.logger.
|
42
|
+
debug("Wiring up Cross Application Tracing to events after finished configuring")
|
43
|
+
|
44
|
+
events.subscribe(:before_call) do |env| #THREAD_LOCAL_ACCESS
|
45
|
+
if id = decoded_id(env) and should_process_request?(id)
|
46
|
+
state = NewRelic::Agent::Tracer.state
|
47
|
+
|
48
|
+
if (txn = state.current_transaction)
|
49
|
+
transaction_info = referring_transaction_info(state, env)
|
50
|
+
|
51
|
+
payload = CrossAppPayload.new(id, txn, transaction_info)
|
52
|
+
txn.distributed_tracer.cross_app_payload = payload
|
53
|
+
end
|
54
|
+
|
55
|
+
CrossAppTracing.assign_intrinsic_transaction_attributes state
|
56
|
+
end
|
57
|
+
end
|
58
|
+
|
59
|
+
events.subscribe(:after_call) do |env, (_status_code, headers, _body)| #THREAD_LOCAL_ACCESS
|
60
|
+
state = NewRelic::Agent::Tracer.state
|
61
|
+
|
62
|
+
insert_response_header(state, env, headers)
|
63
|
+
end
|
64
|
+
end
|
65
|
+
|
66
|
+
def referring_transaction_info(state, request_headers)
|
67
|
+
txn_header = request_headers[NEWRELIC_TXN_HEADER_KEY] or return
|
68
|
+
deserialize_header(txn_header, NEWRELIC_TXN_HEADER)
|
69
|
+
end
|
70
|
+
|
71
|
+
def insert_response_header(state, request_headers, response_headers)
|
72
|
+
txn = state.current_transaction
|
73
|
+
unless txn.nil? || txn.distributed_tracer.cross_app_payload.nil?
|
74
|
+
txn.freeze_name_and_execute_if_not_ignored do
|
75
|
+
content_length = content_length_from_request(request_headers)
|
76
|
+
set_response_headers(txn, response_headers, content_length)
|
77
|
+
end
|
78
|
+
end
|
79
|
+
end
|
80
|
+
|
81
|
+
def should_process_request? id
|
82
|
+
CrossAppTracing.cross_app_enabled? && CrossAppTracing.trusts?(id)
|
83
|
+
end
|
84
|
+
|
85
|
+
def set_response_headers(transaction, response_headers, content_length)
|
86
|
+
payload = obfuscator.obfuscate(
|
87
|
+
::JSON.dump(
|
88
|
+
transaction.distributed_tracer.cross_app_payload.as_json_array(content_length)))
|
89
|
+
|
90
|
+
response_headers[NEWRELIC_APPDATA_HEADER] = payload
|
91
|
+
end
|
92
|
+
|
93
|
+
def decoded_id(request)
|
94
|
+
encoded_id = request[NEWRELIC_ID_HEADER_KEY]
|
95
|
+
return "" if encoded_id.nil? || encoded_id.empty?
|
96
|
+
|
97
|
+
obfuscator.deobfuscate(encoded_id)
|
98
|
+
end
|
99
|
+
|
100
|
+
def content_length_from_request(request)
|
101
|
+
request[CONTENT_LENGTH_HEADER_KEY] || -1
|
102
|
+
end
|
103
|
+
|
104
|
+
def hash_transaction_name(identifier)
|
105
|
+
Digest::MD5.digest(identifier).unpack("@12N").first & 0xffffffff
|
106
|
+
end
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
@@ -0,0 +1,27 @@
|
|
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
|
+
module NewRelic
|
6
|
+
module Agent
|
7
|
+
module DistributedTracing
|
8
|
+
class Monitor < InboundRequestMonitor
|
9
|
+
def on_finished_configuring(events)
|
10
|
+
return unless NewRelic::Agent.config[:'distributed_tracing.enabled']
|
11
|
+
events.subscribe(:before_call, &method(:on_before_call))
|
12
|
+
end
|
13
|
+
|
14
|
+
def on_before_call(request)
|
15
|
+
unless NewRelic::Agent.config[:'distributed_tracing.enabled']
|
16
|
+
NewRelic::Agent.logger.warn "Not configured to accept distributed trace headers"
|
17
|
+
return
|
18
|
+
end
|
19
|
+
|
20
|
+
return unless txn = Tracer.current_transaction
|
21
|
+
|
22
|
+
txn.distributed_tracer.accept_incoming_request request
|
23
|
+
end
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
27
|
+
end
|
@@ -20,15 +20,15 @@ module NewRelic
|
|
20
20
|
attr_reader :obfuscator
|
21
21
|
|
22
22
|
def initialize(events)
|
23
|
-
events.subscribe(:
|
24
|
-
# This requires :encoding_key, so must wait until :
|
23
|
+
events.subscribe(:initial_configuration_complete) do
|
24
|
+
# This requires :encoding_key, so must wait until :initial_configuration_complete
|
25
25
|
setup_obfuscator
|
26
26
|
on_finished_configuring(events)
|
27
27
|
end
|
28
28
|
end
|
29
29
|
|
30
30
|
def setup_obfuscator
|
31
|
-
@obfuscator =
|
31
|
+
@obfuscator = Obfuscator.new(Agent.config[:encoding_key])
|
32
32
|
end
|
33
33
|
|
34
34
|
def deserialize_header(encoded_header, key)
|
@@ -2,8 +2,6 @@
|
|
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/inbound_request_monitor'
|
6
|
-
|
7
5
|
module NewRelic
|
8
6
|
module Agent
|
9
7
|
class SyntheticsMonitor < InboundRequestMonitor
|
@@ -40,7 +38,7 @@ module NewRelic
|
|
40
38
|
|
41
39
|
def is_trusted?(incoming_payload)
|
42
40
|
account_id = incoming_payload[1]
|
43
|
-
|
41
|
+
Agent.config[:trusted_account_ids].include?(account_id)
|
44
42
|
end
|
45
43
|
|
46
44
|
def is_valid_payload?(incoming_payload)
|
@@ -48,7 +46,7 @@ module NewRelic
|
|
48
46
|
end
|
49
47
|
|
50
48
|
def reject_messaging_synthetics_header headers
|
51
|
-
headers.reject {|k,_| k ==
|
49
|
+
headers.reject {|k,_| k == CrossAppTracing::NR_MESSAGE_BROKER_SYNTHETICS_HEADER}
|
52
50
|
end
|
53
51
|
|
54
52
|
end
|
@@ -92,14 +92,16 @@ module NewRelic
|
|
92
92
|
token = Agent.config[:security_policies_token]
|
93
93
|
|
94
94
|
if token && !token.empty?
|
95
|
-
response = invoke_remote(:preconnect, [{'security_policies_token' => token}])
|
95
|
+
response = invoke_remote(:preconnect, [{'security_policies_token' => token, 'high_security' => false}])
|
96
96
|
|
97
97
|
validator = SecurityPolicySettings::Validator.new(response)
|
98
98
|
validator.validate_matching_agent_config!
|
99
99
|
|
100
100
|
response
|
101
|
+
elsif Agent.config[:high_security]
|
102
|
+
invoke_remote(:preconnect, [{'high_security' => true}])
|
101
103
|
else
|
102
|
-
invoke_remote(:preconnect, [])
|
104
|
+
invoke_remote(:preconnect, [{'high_security' => false}])
|
103
105
|
end
|
104
106
|
end
|
105
107
|
|
@@ -196,10 +198,10 @@ module NewRelic
|
|
196
198
|
encoding = 'identity'
|
197
199
|
if data.size > 64 * 1024
|
198
200
|
encoding = Agent.config[:compressed_content_encoding]
|
199
|
-
data = if encoding == '
|
200
|
-
Encoders::Compressed::Gzip.encode(data)
|
201
|
-
else
|
201
|
+
data = if encoding == 'deflate'
|
202
202
|
Encoders::Compressed::Deflate.encode(data)
|
203
|
+
else
|
204
|
+
Encoders::Compressed::Gzip.encode(data)
|
203
205
|
end
|
204
206
|
end
|
205
207
|
check_post_size(data, endpoint)
|
@@ -13,10 +13,8 @@ module NewRelic
|
|
13
13
|
named :SpanEventAggregator
|
14
14
|
capacity_key :'span_events.max_samples_stored'
|
15
15
|
|
16
|
-
|
17
|
-
|
18
|
-
NewRelic::Agent.config[:'distributed_tracing.enabled']
|
19
|
-
}
|
16
|
+
enabled_keys :'span_events.enabled',
|
17
|
+
:'distributed_tracing.enabled'
|
20
18
|
|
21
19
|
def record priority: nil, event:nil, &blk
|
22
20
|
unless(event || priority && blk)
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# event for a segment.
|
7
7
|
|
8
8
|
require 'new_relic/agent/payload_metric_mapping'
|
9
|
-
require 'new_relic/agent/distributed_trace_payload'
|
9
|
+
require 'new_relic/agent/distributed_tracing/distributed_trace_payload'
|
10
10
|
|
11
11
|
module NewRelic
|
12
12
|
module Agent
|
@@ -15,6 +15,7 @@ module NewRelic
|
|
15
15
|
extend self
|
16
16
|
|
17
17
|
# Strings for static keys of the event structure
|
18
|
+
ELLIPSIS = '...'.freeze
|
18
19
|
TYPE_KEY = 'type'.freeze
|
19
20
|
TRACE_ID_KEY = 'traceId'.freeze
|
20
21
|
GUID_KEY = 'guid'.freeze
|
@@ -36,6 +37,8 @@ module NewRelic
|
|
36
37
|
PEER_HOSTNAME_KEY = 'peer.hostname'.freeze
|
37
38
|
SPAN_KIND_KEY = 'span.kind'.freeze
|
38
39
|
ENTRY_POINT_KEY = 'nr.entryPoint'.freeze
|
40
|
+
TRUSTED_PARENT_KEY = "trustedParentId".freeze
|
41
|
+
TRACING_VENDORS_KEY = "tracingVendors".freeze
|
39
42
|
|
40
43
|
# Strings for static values of the event structure
|
41
44
|
EVENT_TYPE = 'Span'.freeze
|
@@ -44,17 +47,14 @@ module NewRelic
|
|
44
47
|
DATASTORE_CATEGORY = 'datastore'.freeze
|
45
48
|
CLIENT = 'client'.freeze
|
46
49
|
|
47
|
-
|
48
|
-
EMPTY_HASH = {}.freeze
|
49
|
-
|
50
|
-
def for_segment(segment)
|
50
|
+
def for_segment segment
|
51
51
|
intrinsics = intrinsics_for(segment)
|
52
52
|
intrinsics[CATEGORY_KEY] = GENERIC_CATEGORY
|
53
53
|
|
54
|
-
[intrinsics,
|
54
|
+
[intrinsics, custom_attributes(segment.attributes), NewRelic::EMPTY_HASH]
|
55
55
|
end
|
56
56
|
|
57
|
-
def for_external_request_segment
|
57
|
+
def for_external_request_segment segment
|
58
58
|
intrinsics = intrinsics_for(segment)
|
59
59
|
|
60
60
|
intrinsics[COMPONENT_KEY] = segment.library
|
@@ -68,10 +68,10 @@ module NewRelic
|
|
68
68
|
agent_attributes[HTTP_URL_KEY] = truncate(segment.uri)
|
69
69
|
end
|
70
70
|
|
71
|
-
[intrinsics,
|
71
|
+
[intrinsics, custom_attributes(segment.attributes), agent_attributes]
|
72
72
|
end
|
73
73
|
|
74
|
-
def for_datastore_segment
|
74
|
+
def for_datastore_segment segment
|
75
75
|
intrinsics = intrinsics_for(segment)
|
76
76
|
|
77
77
|
intrinsics[COMPONENT_KEY] = segment.product
|
@@ -96,14 +96,13 @@ module NewRelic
|
|
96
96
|
agent_attributes[DB_STATEMENT_KEY] = truncate(segment.nosql_statement, 2000)
|
97
97
|
end
|
98
98
|
|
99
|
-
[intrinsics,
|
99
|
+
[intrinsics, custom_attributes(segment.attributes), agent_attributes]
|
100
100
|
end
|
101
101
|
|
102
102
|
private
|
103
103
|
|
104
|
-
def intrinsics_for
|
105
|
-
intrinsics =
|
106
|
-
{
|
104
|
+
def intrinsics_for segment
|
105
|
+
intrinsics = {
|
107
106
|
TYPE_KEY => EVENT_TYPE,
|
108
107
|
TRACE_ID_KEY => segment.transaction.trace_id,
|
109
108
|
GUID_KEY => segment.guid,
|
@@ -115,29 +114,48 @@ module NewRelic
|
|
115
114
|
NAME_KEY => segment.name
|
116
115
|
}
|
117
116
|
|
118
|
-
|
119
|
-
|
120
|
-
|
121
|
-
|
117
|
+
if segment.parent.nil?
|
118
|
+
intrinsics[ENTRY_POINT_KEY] = true
|
119
|
+
if txn = segment.transaction
|
120
|
+
if header_data = txn.distributed_tracer.trace_context_header_data
|
121
|
+
if trace_state_vendors = header_data.trace_state_vendors
|
122
|
+
intrinsics[TRACING_VENDORS_KEY] = trace_state_vendors unless trace_state_vendors == NewRelic::EMPTY_STR
|
123
|
+
end
|
124
|
+
end
|
125
|
+
if trace_state_payload = txn.distributed_tracer.trace_state_payload
|
126
|
+
intrinsics[TRUSTED_PARENT_KEY] = trace_state_payload.id if trace_state_payload.id
|
127
|
+
end
|
128
|
+
end
|
129
|
+
end
|
122
130
|
|
131
|
+
if parent_id = parent_guid(segment)
|
132
|
+
intrinsics[PARENT_ID_KEY] = parent_id
|
133
|
+
end
|
123
134
|
intrinsics
|
124
135
|
end
|
125
136
|
|
126
|
-
def
|
137
|
+
def custom_attributes attributes
|
138
|
+
if attributes
|
139
|
+
result = attributes.custom_attributes_for(NewRelic::Agent::AttributeFilter::DST_SPAN_EVENTS)
|
140
|
+
result.freeze
|
141
|
+
else
|
142
|
+
NewRelic::EMPTY_HASH
|
143
|
+
end
|
144
|
+
end
|
145
|
+
|
146
|
+
def parent_guid segment
|
127
147
|
if segment.parent
|
128
148
|
segment.parent.guid
|
129
|
-
elsif
|
130
|
-
|
149
|
+
elsif txn = segment.transaction
|
150
|
+
txn.distributed_tracer.parent_guid
|
131
151
|
end
|
132
152
|
end
|
133
153
|
|
134
|
-
def milliseconds_since_epoch
|
154
|
+
def milliseconds_since_epoch segment
|
135
155
|
Integer(segment.start_time.to_f * 1000.0)
|
136
156
|
end
|
137
157
|
|
138
|
-
|
139
|
-
|
140
|
-
def truncate(value, max_size=255)
|
158
|
+
def truncate value, max_size=255
|
141
159
|
value = value.to_s
|
142
160
|
if value.bytesize > max_size
|
143
161
|
value.byteslice(0, max_size - 2).chop! << ELLIPSIS
|
@@ -146,7 +164,7 @@ module NewRelic
|
|
146
164
|
end
|
147
165
|
end
|
148
166
|
|
149
|
-
def allowed?
|
167
|
+
def allowed? key
|
150
168
|
NewRelic::Agent.instance.attribute_filter.allows_key?(key, AttributeFilter::DST_SPAN_EVENTS)
|
151
169
|
end
|
152
170
|
end
|
@@ -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
|
@@ -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
|
#
|
@@ -164,12 +196,12 @@ module NewRelic
|
|
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
|