newrelic_rpm 6.6.0.358 → 6.11.0.365
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +3 -0
- data/.travis.yml +81 -5
- data/CHANGELOG.md +262 -0
- data/Gemfile +6 -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 +115 -58
- 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 +154 -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/database/obfuscation_helpers.rb +1 -1
- 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} +2 -1
- 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} +24 -101
- 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 +47 -23
- 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 +18 -6
- 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 -6
- 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 +86 -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/system_info.rb +12 -3
- 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 +38 -0
- data/lib/new_relic/control/instance_methods.rb +10 -1
- data/lib/new_relic/dependency_detection.rb +4 -4
- data/lib/new_relic/environment_report.rb +5 -1
- 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 +19 -8
- data/test/agent_helper.rb +323 -71
- metadata +100 -33
- 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
@@ -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
|
@@ -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
|
@@ -65,7 +65,6 @@ module NewRelic
|
|
65
65
|
# clear out our cached values whenever the run ID changes.
|
66
66
|
#
|
67
67
|
reset_remote_method_uris
|
68
|
-
|
69
68
|
@agent_id = id
|
70
69
|
end
|
71
70
|
|
@@ -92,14 +91,16 @@ module NewRelic
|
|
92
91
|
token = Agent.config[:security_policies_token]
|
93
92
|
|
94
93
|
if token && !token.empty?
|
95
|
-
response = invoke_remote(:preconnect, [{'security_policies_token' => token}])
|
94
|
+
response = invoke_remote(:preconnect, [{'security_policies_token' => token, 'high_security' => false}])
|
96
95
|
|
97
96
|
validator = SecurityPolicySettings::Validator.new(response)
|
98
97
|
validator.validate_matching_agent_config!
|
99
98
|
|
100
99
|
response
|
100
|
+
elsif Agent.config[:high_security]
|
101
|
+
invoke_remote(:preconnect, [{'high_security' => true}])
|
101
102
|
else
|
102
|
-
invoke_remote(:preconnect, [])
|
103
|
+
invoke_remote(:preconnect, [{'high_security' => false}])
|
103
104
|
end
|
104
105
|
end
|
105
106
|
|
@@ -196,10 +197,10 @@ module NewRelic
|
|
196
197
|
encoding = 'identity'
|
197
198
|
if data.size > 64 * 1024
|
198
199
|
encoding = Agent.config[:compressed_content_encoding]
|
199
|
-
data = if encoding == '
|
200
|
-
Encoders::Compressed::Gzip.encode(data)
|
201
|
-
else
|
200
|
+
data = if encoding == 'deflate'
|
202
201
|
Encoders::Compressed::Deflate.encode(data)
|
202
|
+
else
|
203
|
+
Encoders::Compressed::Gzip.encode(data)
|
203
204
|
end
|
204
205
|
end
|
205
206
|
check_post_size(data, endpoint)
|
@@ -0,0 +1,22 @@
|
|
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
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
module NewRelic
|
7
|
+
module Agent
|
8
|
+
|
9
|
+
# This class is used for instrumentations that have exceptions or error classes
|
10
|
+
# not derived from Ruby's usual Exception or StandardError or in situations
|
11
|
+
# where we do not have such Exception object to work with.
|
12
|
+
class NoticibleError
|
13
|
+
attr_reader :class_name, :message
|
14
|
+
|
15
|
+
def initialize class_name, message
|
16
|
+
@class_name = class_name
|
17
|
+
@message = message
|
18
|
+
end
|
19
|
+
end
|
20
|
+
|
21
|
+
end
|
22
|
+
end
|
@@ -1,12 +1,13 @@
|
|
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
|
# This module builds the data structures necessary to create a Span
|
6
7
|
# event for a segment.
|
7
8
|
|
8
9
|
require 'new_relic/agent/payload_metric_mapping'
|
9
|
-
require 'new_relic/agent/distributed_trace_payload'
|
10
|
+
require 'new_relic/agent/distributed_tracing/distributed_trace_payload'
|
10
11
|
|
11
12
|
module NewRelic
|
12
13
|
module Agent
|
@@ -15,70 +16,80 @@ module NewRelic
|
|
15
16
|
extend self
|
16
17
|
|
17
18
|
# Strings for static keys of the event structure
|
18
|
-
|
19
|
-
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
|
29
|
-
|
30
|
-
|
31
|
-
|
32
|
-
|
33
|
-
|
34
|
-
|
35
|
-
|
36
|
-
|
37
|
-
|
38
|
-
|
19
|
+
ELLIPSIS = '...'
|
20
|
+
TYPE_KEY = 'type'
|
21
|
+
TRACE_ID_KEY = 'traceId'
|
22
|
+
GUID_KEY = 'guid'
|
23
|
+
PARENT_ID_KEY = 'parentId'
|
24
|
+
GRANDPARENT_ID_KEY = 'grandparentId'
|
25
|
+
TRANSACTION_ID_KEY = 'transactionId'
|
26
|
+
SAMPLED_KEY = 'sampled'
|
27
|
+
PRIORITY_KEY = 'priority'
|
28
|
+
TIMESTAMP_KEY = 'timestamp'
|
29
|
+
DURATION_KEY = 'duration'
|
30
|
+
NAME_KEY = 'name'
|
31
|
+
CATEGORY_KEY = 'category'
|
32
|
+
HTTP_URL_KEY = 'http.url'
|
33
|
+
HTTP_METHOD_KEY = 'http.method'
|
34
|
+
HTTP_STATUS_CODE_KEY = 'http.statusCode'
|
35
|
+
COMPONENT_KEY = 'component'
|
36
|
+
DB_INSTANCE_KEY = 'db.instance'
|
37
|
+
DB_STATEMENT_KEY = 'db.statement'
|
38
|
+
PEER_ADDRESS_KEY = 'peer.address'
|
39
|
+
PEER_HOSTNAME_KEY = 'peer.hostname'
|
40
|
+
SPAN_KIND_KEY = 'span.kind'
|
41
|
+
ENTRY_POINT_KEY = 'nr.entryPoint'
|
42
|
+
TRUSTED_PARENT_KEY = "trustedParentId"
|
43
|
+
TRACING_VENDORS_KEY = "tracingVendors"
|
39
44
|
|
40
45
|
# Strings for static values of the event structure
|
41
|
-
EVENT_TYPE = 'Span'
|
42
|
-
GENERIC_CATEGORY = 'generic'
|
43
|
-
HTTP_CATEGORY = 'http'
|
44
|
-
DATASTORE_CATEGORY = 'datastore'
|
45
|
-
CLIENT = 'client'
|
46
|
-
|
47
|
-
#
|
48
|
-
|
46
|
+
EVENT_TYPE = 'Span'
|
47
|
+
GENERIC_CATEGORY = 'generic'
|
48
|
+
HTTP_CATEGORY = 'http'
|
49
|
+
DATASTORE_CATEGORY = 'datastore'
|
50
|
+
CLIENT = 'client'
|
51
|
+
|
52
|
+
# Builds a Hash of error attributes as well as the Span ID when
|
53
|
+
# an error is present. Otherwise, returns nil when no error present.
|
54
|
+
def error_attributes segment
|
55
|
+
return if Agent.config[:high_security] || !segment.noticed_error
|
56
|
+
segment.noticed_error.build_error_attributes
|
57
|
+
segment.noticed_error_attributes
|
58
|
+
end
|
49
59
|
|
50
|
-
def for_segment
|
60
|
+
def for_segment segment
|
51
61
|
intrinsics = intrinsics_for(segment)
|
52
62
|
intrinsics[CATEGORY_KEY] = GENERIC_CATEGORY
|
53
63
|
|
54
|
-
[intrinsics,
|
64
|
+
[intrinsics, custom_attributes(segment.attributes), error_attributes(segment) || NewRelic::EMPTY_HASH]
|
55
65
|
end
|
56
66
|
|
57
|
-
def for_external_request_segment
|
67
|
+
def for_external_request_segment segment
|
58
68
|
intrinsics = intrinsics_for(segment)
|
59
69
|
|
60
70
|
intrinsics[COMPONENT_KEY] = segment.library
|
61
71
|
intrinsics[HTTP_METHOD_KEY] = segment.procedure
|
72
|
+
intrinsics[HTTP_STATUS_CODE_KEY] = segment.http_status_code if segment.http_status_code
|
62
73
|
intrinsics[CATEGORY_KEY] = HTTP_CATEGORY
|
63
74
|
intrinsics[SPAN_KIND_KEY] = CLIENT
|
64
75
|
|
65
|
-
agent_attributes = {}
|
76
|
+
agent_attributes = error_attributes(segment) || {}
|
66
77
|
|
67
78
|
if allowed?(HTTP_URL_KEY)
|
68
79
|
agent_attributes[HTTP_URL_KEY] = truncate(segment.uri)
|
69
80
|
end
|
70
81
|
|
71
|
-
[intrinsics,
|
82
|
+
[intrinsics, custom_attributes(segment.attributes), agent_attributes]
|
72
83
|
end
|
73
84
|
|
74
|
-
def for_datastore_segment
|
85
|
+
def for_datastore_segment segment
|
75
86
|
intrinsics = intrinsics_for(segment)
|
76
87
|
|
77
88
|
intrinsics[COMPONENT_KEY] = segment.product
|
78
89
|
intrinsics[SPAN_KIND_KEY] = CLIENT
|
79
90
|
intrinsics[CATEGORY_KEY] = DATASTORE_CATEGORY
|
80
91
|
|
81
|
-
agent_attributes = {}
|
92
|
+
agent_attributes = error_attributes(segment) || {}
|
82
93
|
|
83
94
|
if segment.database_name && allowed?(DB_INSTANCE_KEY)
|
84
95
|
agent_attributes[DB_INSTANCE_KEY] = truncate(segment.database_name)
|
@@ -96,48 +107,70 @@ module NewRelic
|
|
96
107
|
agent_attributes[DB_STATEMENT_KEY] = truncate(segment.nosql_statement, 2000)
|
97
108
|
end
|
98
109
|
|
99
|
-
[intrinsics,
|
110
|
+
[intrinsics, custom_attributes(segment.attributes), agent_attributes]
|
100
111
|
end
|
101
112
|
|
102
113
|
private
|
103
114
|
|
104
|
-
def intrinsics_for
|
105
|
-
intrinsics =
|
106
|
-
{
|
115
|
+
def intrinsics_for segment
|
116
|
+
intrinsics = {
|
107
117
|
TYPE_KEY => EVENT_TYPE,
|
108
118
|
TRACE_ID_KEY => segment.transaction.trace_id,
|
109
119
|
GUID_KEY => segment.guid,
|
110
120
|
TRANSACTION_ID_KEY => segment.transaction.guid,
|
111
|
-
SAMPLED_KEY => segment.transaction.sampled?,
|
112
121
|
PRIORITY_KEY => segment.transaction.priority,
|
113
122
|
TIMESTAMP_KEY => milliseconds_since_epoch(segment),
|
114
123
|
DURATION_KEY => segment.duration,
|
115
124
|
NAME_KEY => segment.name
|
116
125
|
}
|
117
126
|
|
118
|
-
|
119
|
-
|
127
|
+
# with infinite-tracing, transactions may or may not be sampled!
|
128
|
+
if segment.transaction.sampled?
|
129
|
+
intrinsics[SAMPLED_KEY] = true
|
130
|
+
end
|
120
131
|
|
121
|
-
|
132
|
+
if segment.parent.nil?
|
133
|
+
intrinsics[ENTRY_POINT_KEY] = true
|
134
|
+
if txn = segment.transaction
|
135
|
+
if header_data = txn.distributed_tracer.trace_context_header_data
|
136
|
+
if trace_state_vendors = header_data.trace_state_vendors
|
137
|
+
intrinsics[TRACING_VENDORS_KEY] = trace_state_vendors unless trace_state_vendors == NewRelic::EMPTY_STR
|
138
|
+
end
|
139
|
+
end
|
140
|
+
if trace_state_payload = txn.distributed_tracer.trace_state_payload
|
141
|
+
intrinsics[TRUSTED_PARENT_KEY] = trace_state_payload.id if trace_state_payload.id
|
142
|
+
end
|
143
|
+
end
|
144
|
+
end
|
122
145
|
|
146
|
+
if parent_id = parent_guid(segment)
|
147
|
+
intrinsics[PARENT_ID_KEY] = parent_id
|
148
|
+
end
|
123
149
|
intrinsics
|
124
150
|
end
|
125
151
|
|
126
|
-
def
|
152
|
+
def custom_attributes attributes
|
153
|
+
if attributes
|
154
|
+
result = attributes.custom_attributes_for(NewRelic::Agent::AttributeFilter::DST_SPAN_EVENTS)
|
155
|
+
result.freeze
|
156
|
+
else
|
157
|
+
NewRelic::EMPTY_HASH
|
158
|
+
end
|
159
|
+
end
|
160
|
+
|
161
|
+
def parent_guid segment
|
127
162
|
if segment.parent
|
128
163
|
segment.parent.guid
|
129
|
-
elsif
|
130
|
-
|
164
|
+
elsif txn = segment.transaction
|
165
|
+
txn.distributed_tracer.parent_guid
|
131
166
|
end
|
132
167
|
end
|
133
168
|
|
134
|
-
def milliseconds_since_epoch
|
169
|
+
def milliseconds_since_epoch segment
|
135
170
|
Integer(segment.start_time.to_f * 1000.0)
|
136
171
|
end
|
137
172
|
|
138
|
-
|
139
|
-
|
140
|
-
def truncate(value, max_size=255)
|
173
|
+
def truncate value, max_size=255
|
141
174
|
value = value.to_s
|
142
175
|
if value.bytesize > max_size
|
143
176
|
value.byteslice(0, max_size - 2).chop! << ELLIPSIS
|
@@ -146,7 +179,7 @@ module NewRelic
|
|
146
179
|
end
|
147
180
|
end
|
148
181
|
|
149
|
-
def allowed?
|
182
|
+
def allowed? key
|
150
183
|
NewRelic::Agent.instance.attribute_filter.allows_key?(key, AttributeFilter::DST_SPAN_EVENTS)
|
151
184
|
end
|
152
185
|
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",
|
@@ -170,11 +170,20 @@ module NewRelic
|
|
170
170
|
|
171
171
|
container_id = case cpu_cgroup
|
172
172
|
# docker native driver w/out systemd (fs)
|
173
|
-
when /[0-9a-f]{64}/
|
173
|
+
when /[0-9a-f]{64,}/
|
174
|
+
if $&.length == 64
|
175
|
+
$&
|
176
|
+
else # container ID is too long
|
177
|
+
::NewRelic::Agent.logger.debug("Ignoring docker ID of invalid length: '#{cpu_cgroup}'")
|
178
|
+
return
|
179
|
+
end
|
174
180
|
# docker native driver with systemd
|
175
|
-
when '/'
|
181
|
+
when '/' then nil
|
176
182
|
# in a cgroup, but we don't recognize its format
|
177
|
-
when /docker/
|
183
|
+
when /docker\/.*[^0-9a-f]/ then
|
184
|
+
::NewRelic::Agent.logger.debug("Cgroup indicates docker but container_id has invalid characters: '#{cpu_cgroup}'")
|
185
|
+
return
|
186
|
+
when /docker/ then
|
178
187
|
::NewRelic::Agent.logger.debug("Cgroup indicates docker but container_id unrecognized: '#{cpu_cgroup}'")
|
179
188
|
::NewRelic::Agent.increment_metric "Supportability/utilization/docker/error"
|
180
189
|
return
|
@@ -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
|