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
@@ -25,11 +25,11 @@ module NewRelic
|
|
25
25
|
segment = Tracer.start_segment name: metric_name(name, payload)
|
26
26
|
segment.params[:key] = payload[:key]
|
27
27
|
segment.params[:exist] = payload[:exist] if payload.key? :exist
|
28
|
-
|
28
|
+
push_segment id, segment
|
29
29
|
end
|
30
30
|
|
31
31
|
def finish_segment id
|
32
|
-
segment =
|
32
|
+
segment = pop_segment id
|
33
33
|
segment.finish if segment
|
34
34
|
end
|
35
35
|
|
@@ -11,7 +11,7 @@ DependencyDetection.defer do
|
|
11
11
|
|
12
12
|
executes do
|
13
13
|
::NewRelic::Agent.logger.info 'Installing Bunny instrumentation'
|
14
|
-
require 'new_relic/agent/cross_app_tracing'
|
14
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
15
15
|
require 'new_relic/agent/messaging'
|
16
16
|
require 'new_relic/agent/transaction/message_broker_segment'
|
17
17
|
end
|
@@ -14,7 +14,7 @@ DependencyDetection.defer do
|
|
14
14
|
|
15
15
|
executes do
|
16
16
|
::NewRelic::Agent.logger.info 'Installing Curb instrumentation'
|
17
|
-
require 'new_relic/agent/cross_app_tracing'
|
17
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
18
18
|
require 'new_relic/agent/http_clients/curb_wrappers'
|
19
19
|
end
|
20
20
|
|
@@ -42,7 +42,7 @@ DependencyDetection.defer do
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def install_excon_instrumentation(excon_version)
|
45
|
-
require 'new_relic/agent/cross_app_tracing'
|
45
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
46
46
|
require 'new_relic/agent/http_clients/excon_wrappers'
|
47
47
|
|
48
48
|
if excon_version >= EXCON_MIDDLEWARE_MIN_VERSION
|
@@ -14,7 +14,6 @@ module NewRelic
|
|
14
14
|
API_VERSION = 'api.version'.freeze
|
15
15
|
FORMAT_REGEX = /\(\/?\.[\:\w]*\)/.freeze # either :format (< 0.12.0) or .ext (>= 0.12.0)
|
16
16
|
VERSION_REGEX = /:version(\/|$)/.freeze
|
17
|
-
EMPTY_STRING = ''.freeze
|
18
17
|
MIN_VERSION = Gem::Version.new("0.2.0")
|
19
18
|
PIPE_STRING = '|'.freeze
|
20
19
|
|
@@ -33,7 +32,7 @@ module NewRelic
|
|
33
32
|
end
|
34
33
|
|
35
34
|
def name_for_transaction(route, class_name, version)
|
36
|
-
action_name = route.path.sub(FORMAT_REGEX,
|
35
|
+
action_name = route.path.sub(FORMAT_REGEX, NewRelic::EMPTY_STR)
|
37
36
|
method_name = route.request_method
|
38
37
|
version ||= route.version
|
39
38
|
|
@@ -42,7 +41,7 @@ module NewRelic
|
|
42
41
|
version = version.join(PIPE_STRING) if Array === version
|
43
42
|
|
44
43
|
if version
|
45
|
-
action_name = action_name.sub(VERSION_REGEX,
|
44
|
+
action_name = action_name.sub(VERSION_REGEX, NewRelic::EMPTY_STR)
|
46
45
|
"#{class_name}-#{version}#{action_name} (#{method_name})"
|
47
46
|
else
|
48
47
|
"#{class_name}#{action_name} (#{method_name})"
|
@@ -50,12 +49,12 @@ module NewRelic
|
|
50
49
|
end
|
51
50
|
|
52
51
|
def name_for_transaction_deprecated(route, class_name, version)
|
53
|
-
action_name = route.route_path.sub(FORMAT_REGEX,
|
52
|
+
action_name = route.route_path.sub(FORMAT_REGEX, NewRelic::EMPTY_STR)
|
54
53
|
method_name = route.route_method
|
55
54
|
version ||= route.route_version
|
56
55
|
|
57
56
|
if version
|
58
|
-
action_name = action_name.sub(VERSION_REGEX,
|
57
|
+
action_name = action_name.sub(VERSION_REGEX, NewRelic::EMPTY_STR)
|
59
58
|
"#{class_name}-#{version}#{action_name} (#{method_name})"
|
60
59
|
else
|
61
60
|
"#{class_name}#{action_name} (#{method_name})"
|
@@ -118,11 +117,7 @@ DependencyDetection.defer do
|
|
118
117
|
|
119
118
|
# Since 1.2.0, the class `Grape::API` no longer refers to an API instance, rather, what used to be `Grape::API` is `Grape::API::Instance`
|
120
119
|
# https://github.com/ruby-grape/grape/blob/c20a73ac1e3f3ba1082005ed61bf69452373ba87/UPGRADING.md#upgrading-to--120
|
121
|
-
grape_api_class =
|
122
|
-
::Grape::API::Instance
|
123
|
-
else
|
124
|
-
::Grape::API
|
125
|
-
end
|
120
|
+
grape_api_class = defined?(Grape::API::Instance) ? ::Grape::API::Instance : ::Grape::API
|
126
121
|
|
127
122
|
grape_api_class.class_eval do
|
128
123
|
def call_with_new_relic(env)
|
@@ -11,7 +11,7 @@ DependencyDetection.defer do
|
|
11
11
|
|
12
12
|
executes do
|
13
13
|
::NewRelic::Agent.logger.info 'Installing http.rb instrumentation'
|
14
|
-
require 'new_relic/agent/cross_app_tracing'
|
14
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
15
15
|
require 'new_relic/agent/http_clients/http_rb_wrappers'
|
16
16
|
end
|
17
17
|
|
@@ -20,7 +20,7 @@ DependencyDetection.defer do
|
|
20
20
|
|
21
21
|
executes do
|
22
22
|
::NewRelic::Agent.logger.info 'Installing HTTPClient instrumentation'
|
23
|
-
require 'new_relic/agent/cross_app_tracing'
|
23
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
24
24
|
require 'new_relic/agent/http_clients/httpclient_wrappers'
|
25
25
|
end
|
26
26
|
|
@@ -11,7 +11,7 @@ DependencyDetection.defer do
|
|
11
11
|
|
12
12
|
executes do
|
13
13
|
::NewRelic::Agent.logger.info 'Installing Net instrumentation'
|
14
|
-
require 'new_relic/agent/cross_app_tracing'
|
14
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
15
15
|
require 'new_relic/agent/http_clients/net_http_wrappers'
|
16
16
|
end
|
17
17
|
|
@@ -28,9 +28,8 @@ DependencyDetection.defer do
|
|
28
28
|
NewRelic::Agent::Instrumentation::ActionCableSubscriber.new)
|
29
29
|
|
30
30
|
ActiveSupport.on_load(:action_cable) do
|
31
|
-
::NewRelic::Agent::PrependSupportability.record_metrics_for(
|
32
|
-
|
33
|
-
::ActionCable::RemoteConnections)
|
31
|
+
::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActionCable::Engine) if defined?(::ActionCable::Engine)
|
32
|
+
::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActionCable::RemoteConnections) if defined?(::ActionCable::RemoteConnections)
|
34
33
|
end
|
35
34
|
end
|
36
35
|
end
|
@@ -43,6 +43,9 @@ DependencyDetection.defer do
|
|
43
43
|
perform_without_instrumentation
|
44
44
|
end
|
45
45
|
ensure
|
46
|
+
# Stopping the event loop before flushing the pipe.
|
47
|
+
# The goal is to avoid conflict during write.
|
48
|
+
NewRelic::Agent.agent.stop_event_loop
|
46
49
|
NewRelic::Agent.agent.flush_pipe_data
|
47
50
|
end
|
48
51
|
end
|
@@ -15,7 +15,7 @@ DependencyDetection.defer do
|
|
15
15
|
|
16
16
|
executes do
|
17
17
|
::NewRelic::Agent.logger.info 'Installing Typhoeus instrumentation'
|
18
|
-
require 'new_relic/agent/cross_app_tracing'
|
18
|
+
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
19
19
|
require 'new_relic/agent/http_clients/typhoeus_wrappers'
|
20
20
|
end
|
21
21
|
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
RUM_KEY_LENGTH = 13
|
15
15
|
|
16
16
|
def initialize(event_listener)
|
17
|
-
event_listener.subscribe(:
|
17
|
+
event_listener.subscribe(:initial_configuration_complete, &method(:log_configuration))
|
18
18
|
end
|
19
19
|
|
20
20
|
def log_configuration
|
@@ -0,0 +1,139 @@
|
|
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 'json'
|
6
|
+
require 'new_relic/agent/hostname'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module Logging
|
11
|
+
|
12
|
+
# This class can be used as the formatter for an existing logger. It
|
13
|
+
# decorates log messages with trace and entity metadata, and formats each
|
14
|
+
# log messages as a JSON object.
|
15
|
+
#
|
16
|
+
# It can be added to a Rails application like this:
|
17
|
+
#
|
18
|
+
# require 'newrelic_rpm'
|
19
|
+
#
|
20
|
+
# Rails.application.configure do
|
21
|
+
# config.log_formatter = ::NewRelic::Agent::Logging::DecoratingFormatter.new
|
22
|
+
# end
|
23
|
+
#
|
24
|
+
# @api public
|
25
|
+
class DecoratingFormatter < ::Logger::Formatter
|
26
|
+
TIMESTAMP_KEY = 'timestamp'.freeze
|
27
|
+
MESSAGE_KEY = 'message'.freeze
|
28
|
+
LOG_LEVEL_KEY = 'log.level'.freeze
|
29
|
+
LOG_NAME_KEY = 'logger.name'.freeze
|
30
|
+
NEWLINE = "\n".freeze
|
31
|
+
|
32
|
+
QUOTE = '"'.freeze
|
33
|
+
COLON = ':'.freeze
|
34
|
+
COMMA = ','.freeze
|
35
|
+
CLOSING_BRACE = '}'.freeze
|
36
|
+
|
37
|
+
def initialize
|
38
|
+
Agent.config.register_callback :app_name do
|
39
|
+
@app_name = nil
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
def call severity, time, progname, msg
|
44
|
+
message = '{'
|
45
|
+
if app_name
|
46
|
+
add_key_value message, ENTITY_NAME_KEY, app_name
|
47
|
+
message << COMMA
|
48
|
+
end
|
49
|
+
add_key_value message, ENTITY_TYPE_KEY, ENTITY_TYPE
|
50
|
+
message << COMMA
|
51
|
+
add_key_value message, HOSTNAME_KEY, Hostname.get
|
52
|
+
|
53
|
+
if entity_guid = Agent.config[:entity_guid]
|
54
|
+
message << COMMA
|
55
|
+
add_key_value message, ENTITY_GUID_KEY, entity_guid
|
56
|
+
end
|
57
|
+
|
58
|
+
if trace_id = Tracer.trace_id
|
59
|
+
message << COMMA
|
60
|
+
add_key_value message, TRACE_ID_KEY, trace_id
|
61
|
+
end
|
62
|
+
if span_id = Tracer.span_id
|
63
|
+
message << COMMA
|
64
|
+
add_key_value message, SPAN_ID_KEY, span_id
|
65
|
+
end
|
66
|
+
|
67
|
+
message << COMMA
|
68
|
+
message << QUOTE << MESSAGE_KEY << QUOTE << COLON << escape(msg)
|
69
|
+
message << COMMA
|
70
|
+
add_key_value message, LOG_LEVEL_KEY, severity
|
71
|
+
if progname
|
72
|
+
message << COMMA
|
73
|
+
add_key_value message, LOG_NAME_KEY, progname
|
74
|
+
end
|
75
|
+
|
76
|
+
message << COMMA
|
77
|
+
message << QUOTE << TIMESTAMP_KEY << QUOTE << COLON << time.to_f.to_s
|
78
|
+
message << CLOSING_BRACE << NEWLINE
|
79
|
+
end
|
80
|
+
|
81
|
+
def app_name
|
82
|
+
@app_name ||= Agent.config[:app_name][0]
|
83
|
+
end
|
84
|
+
|
85
|
+
def add_key_value message, key, value
|
86
|
+
message << QUOTE << key << QUOTE << COLON << QUOTE << value << QUOTE
|
87
|
+
end
|
88
|
+
|
89
|
+
def escape message
|
90
|
+
if String === message
|
91
|
+
message.to_json
|
92
|
+
else
|
93
|
+
message.inspect.to_json
|
94
|
+
end
|
95
|
+
end
|
96
|
+
|
97
|
+
def clear_tags!
|
98
|
+
# No-op; just avoiding issues with act-fluent-logger-rails
|
99
|
+
end
|
100
|
+
end
|
101
|
+
|
102
|
+
|
103
|
+
# This logger decorates logs with trace and entity metadata, and emits log
|
104
|
+
# messages formatted as JSON objects. It extends the Logger class from
|
105
|
+
# the Ruby standard library, and accepts the same constructor parameters.
|
106
|
+
#
|
107
|
+
# It aliases the `:info` message to overwrite the `:write` method, so it
|
108
|
+
# can be used in Rack applications that expect the logger to be a file-like
|
109
|
+
# object.
|
110
|
+
#
|
111
|
+
# It can be added to an application like this:
|
112
|
+
#
|
113
|
+
# require 'newrelic_rpm'
|
114
|
+
#
|
115
|
+
# config.logger = NewRelic::Agent::Logging::DecoratingLogger.new "log/application.log"
|
116
|
+
#
|
117
|
+
# @api public
|
118
|
+
class DecoratingLogger < (defined?(::ActiveSupport) && defined?(::ActiveSupport::Logger) ? ::ActiveSupport::Logger : ::Logger)
|
119
|
+
|
120
|
+
alias :write :info
|
121
|
+
|
122
|
+
# Positional and Keyword arguments are separated beginning with Ruby 2.7
|
123
|
+
# Signature of ::Logger constructor changes in Ruby 2.4 to have both positional and keyword args
|
124
|
+
# We pivot on Ruby 2.7 for widest supportability with least amount of hassle.
|
125
|
+
if RUBY_VERSION < "2.7.0"
|
126
|
+
def initialize(*args)
|
127
|
+
super(*args)
|
128
|
+
self.formatter = DecoratingFormatter.new
|
129
|
+
end
|
130
|
+
else
|
131
|
+
def initialize(*args, **kwargs)
|
132
|
+
super(*args, **kwargs)
|
133
|
+
self.formatter = DecoratingFormatter.new
|
134
|
+
end
|
135
|
+
end
|
136
|
+
end
|
137
|
+
end
|
138
|
+
end
|
139
|
+
end
|
@@ -1,6 +1,8 @@
|
|
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
|
5
|
+
|
4
6
|
require 'new_relic/agent/transaction'
|
5
7
|
|
6
8
|
module NewRelic
|
@@ -13,12 +15,12 @@ module NewRelic
|
|
13
15
|
module Messaging
|
14
16
|
extend self
|
15
17
|
|
18
|
+
RABBITMQ_TRANSPORT_TYPE = "RabbitMQ"
|
19
|
+
|
16
20
|
ATTR_DESTINATION = AttributeFilter::DST_TRANSACTION_EVENTS |
|
17
21
|
AttributeFilter::DST_TRANSACTION_TRACER |
|
18
22
|
AttributeFilter::DST_ERROR_COLLECTOR
|
19
23
|
|
20
|
-
EMPTY_STRING = ''.freeze
|
21
|
-
|
22
24
|
# Start a MessageBroker segment configured to trace a messaging action.
|
23
25
|
# Finishing this segment will handle timing and recording of the proper
|
24
26
|
# metrics for New Relic's messaging features..
|
@@ -133,7 +135,7 @@ module NewRelic
|
|
133
135
|
txn = Tracer.start_transaction name: txn_name, category: :message
|
134
136
|
|
135
137
|
if headers
|
136
|
-
consume_message_headers headers,
|
138
|
+
txn.distributed_tracer.consume_message_headers headers, state, RABBITMQ_TRANSPORT_TYPE
|
137
139
|
CrossAppTracing.reject_messaging_cat_headers(headers).each do |k, v|
|
138
140
|
txn.add_agent_attribute :"message.headers.#{k}", v, AttributeFilter::DST_NONE unless v.nil?
|
139
141
|
end
|
@@ -365,76 +367,6 @@ module NewRelic
|
|
365
367
|
transaction_name
|
366
368
|
end
|
367
369
|
|
368
|
-
RABBITMQ_TRANSPORT_TYPE = "RabbitMQ".freeze
|
369
|
-
|
370
|
-
def consume_message_headers headers, transaction, state
|
371
|
-
consume_distributed_tracing_headers headers, transaction
|
372
|
-
consume_cross_app_tracing_headers headers, state
|
373
|
-
|
374
|
-
assign_synthetics_header headers[CrossAppTracing::NR_MESSAGE_BROKER_SYNTHETICS_HEADER], transaction
|
375
|
-
rescue => e
|
376
|
-
NewRelic::Agent.logger.error "Error in consume_message_headers", e
|
377
|
-
end
|
378
|
-
|
379
|
-
def decode_txn_info headers, transaction_state
|
380
|
-
encoded_id = headers[CrossAppTracing::NR_MESSAGE_BROKER_ID_HEADER]
|
381
|
-
|
382
|
-
decoded_id = if encoded_id.nil?
|
383
|
-
EMPTY_STRING
|
384
|
-
else
|
385
|
-
CrossAppTracing.obfuscator.deobfuscate(encoded_id)
|
386
|
-
end
|
387
|
-
|
388
|
-
if CrossAppTracing.trusted_valid_cross_app_id?(decoded_id) && transaction_state.current_transaction
|
389
|
-
txn_header = headers[CrossAppTracing::NR_MESSAGE_BROKER_TXN_HEADER]
|
390
|
-
txn = transaction_state.current_transaction
|
391
|
-
txn_info = ::JSON.load(CrossAppTracing.obfuscator.deobfuscate(txn_header))
|
392
|
-
payload = CrossAppPayload.new(decoded_id, txn, txn_info)
|
393
|
-
|
394
|
-
txn.cross_app_payload = payload
|
395
|
-
end
|
396
|
-
rescue => e
|
397
|
-
NewRelic::Agent.logger.debug("Failure deserializing encoded header in #{self.class}, #{e.class}, #{e.message}")
|
398
|
-
nil
|
399
|
-
end
|
400
|
-
|
401
|
-
CANDIDATE_HEADERS = ['newrelic'.freeze, 'NEWRELIC'.freeze, 'Newrelic'.freeze]
|
402
|
-
|
403
|
-
def consume_distributed_tracing_headers headers, transaction
|
404
|
-
if Agent.config[:'distributed_tracing.enabled']
|
405
|
-
return unless newrelic_trace_key = CANDIDATE_HEADERS.detect do |key|
|
406
|
-
headers.has_key?(key)
|
407
|
-
end
|
408
|
-
|
409
|
-
return unless payload = headers[newrelic_trace_key]
|
410
|
-
|
411
|
-
if transaction.accept_distributed_trace_payload payload
|
412
|
-
transaction.distributed_trace_payload.caller_transport_type = RABBITMQ_TRANSPORT_TYPE
|
413
|
-
end
|
414
|
-
end
|
415
|
-
end
|
416
|
-
|
417
|
-
def consume_cross_app_tracing_headers headers, state
|
418
|
-
if CrossAppTracing.cross_app_enabled? && CrossAppTracing.message_has_crossapp_request_header?(headers)
|
419
|
-
decode_txn_info headers, state
|
420
|
-
CrossAppTracing.assign_intrinsic_transaction_attributes state
|
421
|
-
end
|
422
|
-
end
|
423
|
-
|
424
|
-
def assign_synthetics_header synthetics_header, transaction
|
425
|
-
if synthetics_header and
|
426
|
-
incoming_payload = ::JSON.load(CrossAppTracing.obfuscator.deobfuscate(synthetics_header)) and
|
427
|
-
SyntheticsMonitor.is_valid_payload?(incoming_payload) and
|
428
|
-
SyntheticsMonitor.is_supported_version?(incoming_payload) and
|
429
|
-
SyntheticsMonitor.is_trusted?(incoming_payload)
|
430
|
-
|
431
|
-
transaction.raw_synthetics_header = synthetics_header
|
432
|
-
transaction.synthetics_payload = incoming_payload
|
433
|
-
end
|
434
|
-
rescue => e
|
435
|
-
NewRelic::Agent.logger.error "Error in assign_synthetics_header", e
|
436
|
-
end
|
437
|
-
|
438
370
|
end
|
439
371
|
end
|
440
372
|
end
|
@@ -47,6 +47,7 @@ module NewRelic
|
|
47
47
|
#
|
48
48
|
|
49
49
|
module MethodTracer
|
50
|
+
|
50
51
|
def self.included clazz
|
51
52
|
clazz.extend ClassMethods
|
52
53
|
end
|
@@ -67,7 +68,7 @@ module NewRelic
|
|
67
68
|
#
|
68
69
|
# @api public
|
69
70
|
#
|
70
|
-
def trace_execution_scoped(metric_names, options=
|
71
|
+
def trace_execution_scoped(metric_names, options=NewRelic::EMPTY_HASH) #THREAD_LOCAL_ACCESS
|
71
72
|
NewRelic::Agent.record_api_supportability_metric :trace_execution_scoped
|
72
73
|
NewRelic::Agent::MethodTracerHelpers.trace_execution_scoped(metric_names, options) do
|
73
74
|
# Using an implicit block avoids object allocation for a &block param
|
@@ -83,7 +84,7 @@ module NewRelic
|
|
83
84
|
#
|
84
85
|
# @api public
|
85
86
|
#
|
86
|
-
def trace_execution_unscoped(metric_names, options=
|
87
|
+
def trace_execution_unscoped(metric_names, options=NewRelic::EMPTY_HASH) #THREAD_LOCAL_ACCESS
|
87
88
|
NewRelic::Agent.record_api_supportability_metric :trace_execution_unscoped
|
88
89
|
return yield unless NewRelic::Agent.tl_is_execution_traced?
|
89
90
|
t0 = Time.now
|
@@ -9,7 +9,7 @@ module NewRelic
|
|
9
9
|
|
10
10
|
extend self
|
11
11
|
|
12
|
-
def trace_execution_scoped(metric_names, options=
|
12
|
+
def trace_execution_scoped(metric_names, options=NewRelic::EMPTY_HASH) #THREAD_LOCAL_ACCESS
|
13
13
|
state = NewRelic::Agent::Tracer.state
|
14
14
|
return yield unless state.is_execution_traced?
|
15
15
|
|