newrelic_rpm 9.3.0 → 9.6.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.build_ignore +6 -1
- data/CHANGELOG.md +193 -6
- data/README.md +4 -0
- data/Rakefile +1 -1
- data/lib/new_relic/agent/attribute_pre_filtering.rb +109 -0
- data/lib/new_relic/agent/configuration/default_source.rb +177 -34
- data/lib/new_relic/agent/configuration/environment_source.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing.rb +1 -1
- data/lib/new_relic/agent/http_clients/async_http_wrappers.rb +83 -0
- data/lib/new_relic/agent/http_clients/ethon_wrappers.rb +111 -0
- data/lib/new_relic/agent/http_clients/httpx_wrappers.rb +93 -0
- data/lib/new_relic/agent/instrumentation/action_controller_other_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -2
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/chain.rb +69 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/instrumentation.rb +13 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger/prepend.rb +37 -0
- data/lib/new_relic/agent/instrumentation/active_support_broadcast_logger.rb +23 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/active_support_logger.rb +3 -1
- data/lib/new_relic/agent/instrumentation/async_http/chain.rb +23 -0
- data/lib/new_relic/agent/instrumentation/async_http/instrumentation.rb +37 -0
- data/lib/new_relic/agent/instrumentation/async_http/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/async_http.rb +26 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/concurrent_ruby/instrumentation.rb +2 -2
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -2
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/elasticsearch/instrumentation.rb +4 -1
- data/lib/new_relic/agent/instrumentation/ethon/chain.rb +39 -0
- data/lib/new_relic/agent/instrumentation/ethon/instrumentation.rb +105 -0
- data/lib/new_relic/agent/instrumentation/ethon/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/ethon.rb +39 -0
- data/lib/new_relic/agent/instrumentation/excon/middleware.rb +3 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/grpc/client/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/grpc/server/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/grpc_client.rb +1 -1
- data/lib/new_relic/agent/instrumentation/grpc_server.rb +1 -1
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/httpx/chain.rb +20 -0
- data/lib/new_relic/agent/instrumentation/httpx/instrumentation.rb +51 -0
- data/lib/new_relic/agent/instrumentation/httpx/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/httpx.rb +27 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +3 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +9 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +2 -2
- data/lib/new_relic/agent/instrumentation/mongodb_command_subscriber.rb +1 -3
- data/lib/new_relic/agent/instrumentation/net_http/instrumentation.rb +5 -1
- data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +4 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/queue_time.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +6 -0
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +4 -0
- data/lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb +1 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/roda/chain.rb +43 -0
- data/lib/new_relic/agent/instrumentation/roda/ignorer.rb +45 -0
- data/lib/new_relic/agent/instrumentation/roda/instrumentation.rb +68 -0
- data/lib/new_relic/agent/instrumentation/roda/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/roda/roda_transaction_namer.rb +29 -0
- data/lib/new_relic/agent/instrumentation/roda.rb +36 -0
- data/lib/new_relic/agent/instrumentation/sequel.rb +1 -1
- data/lib/new_relic/agent/instrumentation/sidekiq/client.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sidekiq/server.rb +26 -3
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +5 -3
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/sinatra/transaction_namer.rb +1 -3
- data/lib/new_relic/agent/instrumentation/stripe.rb +28 -0
- data/lib/new_relic/agent/instrumentation/stripe_subscriber.rb +77 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +4 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +5 -1
- data/lib/new_relic/agent/log_event_attributes.rb +1 -1
- data/lib/new_relic/agent/messaging.rb +2 -2
- data/lib/new_relic/agent/monitors/synthetics_monitor.rb +12 -1
- data/lib/new_relic/agent/new_relic_service.rb +33 -17
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/rules_engine.rb +1 -1
- data/lib/new_relic/agent/span_event_primitive.rb +16 -4
- data/lib/new_relic/agent/system_info.rb +26 -0
- data/lib/new_relic/agent/tracer.rb +5 -6
- data/lib/new_relic/agent/transaction/abstract_segment.rb +55 -0
- data/lib/new_relic/agent/transaction/external_request_segment.rb +5 -2
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +1 -2
- data/lib/new_relic/agent/transaction/request_attributes.rb +46 -10
- data/lib/new_relic/agent/transaction.rb +30 -6
- data/lib/new_relic/agent/transaction_error_primitive.rb +16 -0
- data/lib/new_relic/agent/transaction_event_primitive.rb +19 -0
- data/lib/new_relic/agent/utilization/gcp.rb +1 -3
- data/lib/new_relic/agent/utilization/vendor.rb +5 -7
- data/lib/new_relic/agent.rb +19 -3
- data/lib/new_relic/cli/command.rb +1 -0
- data/lib/new_relic/constants.rb +3 -0
- data/lib/new_relic/control/class_methods.rb +1 -7
- data/lib/new_relic/control/frameworks/rails.rb +14 -2
- data/lib/new_relic/control/frameworks/roda.rb +20 -0
- data/lib/new_relic/language_support.rb +9 -0
- data/lib/new_relic/noticed_error.rb +5 -2
- data/lib/new_relic/rack/agent_hooks.rb +1 -1
- data/lib/new_relic/rack/agent_middleware.rb +0 -16
- data/lib/new_relic/rack/browser_monitoring.rb +1 -1
- data/lib/new_relic/supportability_helper.rb +1 -0
- data/lib/new_relic/version.rb +1 -1
- data/lib/tasks/bump_version.rake +1 -1
- data/lib/tasks/config.rake +3 -2
- data/lib/tasks/helpers/config.html.erb +93 -0
- data/lib/tasks/helpers/format.rb +11 -7
- data/lib/tasks/helpers/version_bump.rb +2 -2
- data/lib/tasks/instrumentation_generator/instrumentation.thor +3 -3
- data/lib/tasks/newrelicyml.rake +1 -1
- data/lib/tasks/tests.rake +71 -0
- data/newrelic.yml +103 -31
- data/newrelic_rpm.gemspec +12 -6
- data/test/agent_helper.rb +1027 -0
- metadata +63 -8
- data/lib/tasks/helpers/removers.rb +0 -33
- data/lib/tasks/multiverse.rake +0 -6
- data/lib/tasks/multiverse.rb +0 -76
@@ -0,0 +1,111 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'uri'
|
6
|
+
require_relative 'abstract'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module HTTPClients
|
11
|
+
class EthonHTTPResponse < AbstractResponse
|
12
|
+
def initialize(easy)
|
13
|
+
@easy = easy
|
14
|
+
end
|
15
|
+
|
16
|
+
def status_code
|
17
|
+
@easy.response_code
|
18
|
+
end
|
19
|
+
|
20
|
+
def [](key)
|
21
|
+
headers[format_key(key)]
|
22
|
+
end
|
23
|
+
|
24
|
+
def headers
|
25
|
+
# Ethon::Easy#response_headers will return '' if headers are unset
|
26
|
+
@easy.response_headers.scan(/\n([^:]+?): ([^:\n]+?)\r/).each_with_object({}) do |pair, hash|
|
27
|
+
hash[format_key(pair[0])] = pair[1]
|
28
|
+
end
|
29
|
+
end
|
30
|
+
alias to_hash headers
|
31
|
+
|
32
|
+
private
|
33
|
+
|
34
|
+
def format_key(key)
|
35
|
+
key.tr('-', '_').downcase
|
36
|
+
end
|
37
|
+
end
|
38
|
+
|
39
|
+
class EthonHTTPRequest < AbstractRequest
|
40
|
+
attr_reader :uri
|
41
|
+
|
42
|
+
DEFAULT_ACTION = 'GET'
|
43
|
+
DEFAULT_HOST = 'UNKNOWN_HOST'
|
44
|
+
ETHON = 'Ethon'
|
45
|
+
LHOST = 'host'.freeze
|
46
|
+
UHOST = 'Host'.freeze
|
47
|
+
|
48
|
+
def initialize(easy)
|
49
|
+
@easy = easy
|
50
|
+
@uri = uri_from_easy
|
51
|
+
end
|
52
|
+
|
53
|
+
def type
|
54
|
+
ETHON
|
55
|
+
end
|
56
|
+
|
57
|
+
def host_from_header
|
58
|
+
self[LHOST] || self[UHOST]
|
59
|
+
end
|
60
|
+
|
61
|
+
def uri_from_easy
|
62
|
+
# anticipate `Ethon::Easy#url` being `example.com` without a protocol
|
63
|
+
# defined and use an 'http' protocol prefix for `URI.parse` to work
|
64
|
+
# with the URL as desired
|
65
|
+
url_str = @easy.url.match?(':') ? @easy.url : "http://#{@easy.url}"
|
66
|
+
begin
|
67
|
+
URI.parse(url_str)
|
68
|
+
rescue URI::InvalidURIError => e
|
69
|
+
NewRelic::Agent.logger.debug("Failed to parse URI '#{url_str}': #{e.class} - #{e.message}")
|
70
|
+
URI.parse(NewRelic::EMPTY_STR)
|
71
|
+
end
|
72
|
+
end
|
73
|
+
|
74
|
+
def host
|
75
|
+
host_from_header || uri.host&.downcase || DEFAULT_HOST
|
76
|
+
end
|
77
|
+
|
78
|
+
def method
|
79
|
+
return DEFAULT_ACTION unless @easy.instance_variable_defined?(action_instance_var)
|
80
|
+
|
81
|
+
@easy.instance_variable_get(action_instance_var)
|
82
|
+
end
|
83
|
+
|
84
|
+
def action_instance_var
|
85
|
+
NewRelic::Agent::Instrumentation::Ethon::Easy::ACTION_INSTANCE_VAR
|
86
|
+
end
|
87
|
+
|
88
|
+
def []=(key, value)
|
89
|
+
headers[key] = value
|
90
|
+
@easy.headers = headers
|
91
|
+
end
|
92
|
+
|
93
|
+
def headers
|
94
|
+
@headers ||= if @easy.instance_variable_defined?(headers_instance_var)
|
95
|
+
@easy.instance_variable_get(headers_instance_var)
|
96
|
+
else
|
97
|
+
{}
|
98
|
+
end
|
99
|
+
end
|
100
|
+
|
101
|
+
def headers_instance_var
|
102
|
+
NewRelic::Agent::Instrumentation::Ethon::Easy::HEADERS_INSTANCE_VAR
|
103
|
+
end
|
104
|
+
|
105
|
+
def [](key)
|
106
|
+
headers[key]
|
107
|
+
end
|
108
|
+
end
|
109
|
+
end
|
110
|
+
end
|
111
|
+
end
|
@@ -0,0 +1,93 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'abstract'
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
module HTTPClients
|
10
|
+
# HTTPX returns an instance of HTTPX::ErrorResponse on error,
|
11
|
+
# and that instance itself yields the underlying HTTP response
|
12
|
+
# object via #response, but depending on the error that HTTP
|
13
|
+
# response object could be unset.
|
14
|
+
class HTTPXErrorResponse
|
15
|
+
def status; end
|
16
|
+
def headers; {}; end
|
17
|
+
end
|
18
|
+
|
19
|
+
class HTTPXHTTPResponse < AbstractResponse
|
20
|
+
def initialize(response)
|
21
|
+
if response.is_a?(::HTTPX::ErrorResponse)
|
22
|
+
@response = response.response || HTTPXErrorResponse.new
|
23
|
+
else
|
24
|
+
@response = response
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
def status_code
|
29
|
+
@response.status
|
30
|
+
end
|
31
|
+
|
32
|
+
def [](key)
|
33
|
+
headers[format_key(key)]
|
34
|
+
end
|
35
|
+
|
36
|
+
def headers
|
37
|
+
headers ||= @response.headers.to_hash.each_with_object({}) do |(k, v), h|
|
38
|
+
h[format_key(k)] = v
|
39
|
+
end
|
40
|
+
end
|
41
|
+
alias to_hash headers
|
42
|
+
|
43
|
+
private
|
44
|
+
|
45
|
+
def format_key(key)
|
46
|
+
key.tr('-', '_').downcase
|
47
|
+
end
|
48
|
+
end
|
49
|
+
|
50
|
+
class HTTPXHTTPRequest < AbstractRequest
|
51
|
+
attr_reader :uri
|
52
|
+
|
53
|
+
DEFAULT_HOST = 'UNKNOWN_HOST'
|
54
|
+
TYPE = 'HTTPX'
|
55
|
+
LHOST = 'host'.freeze
|
56
|
+
UHOST = 'Host'.freeze
|
57
|
+
|
58
|
+
def initialize(request)
|
59
|
+
@request = request
|
60
|
+
@uri = request.uri
|
61
|
+
end
|
62
|
+
|
63
|
+
def type
|
64
|
+
TYPE
|
65
|
+
end
|
66
|
+
|
67
|
+
def host_from_header
|
68
|
+
self[LHOST] || self[UHOST]
|
69
|
+
end
|
70
|
+
|
71
|
+
def host
|
72
|
+
host_from_header || uri.host&.downcase || DEFAULT_HOST
|
73
|
+
end
|
74
|
+
|
75
|
+
def method
|
76
|
+
@request.verb
|
77
|
+
end
|
78
|
+
|
79
|
+
def []=(key, value)
|
80
|
+
@request.headers[key] = value
|
81
|
+
end
|
82
|
+
|
83
|
+
def headers
|
84
|
+
@request.headers
|
85
|
+
end
|
86
|
+
|
87
|
+
def [](key)
|
88
|
+
@request.headers[key]
|
89
|
+
end
|
90
|
+
end
|
91
|
+
end
|
92
|
+
end
|
93
|
+
end
|
@@ -23,7 +23,7 @@ module NewRelic
|
|
23
23
|
|
24
24
|
def metric_name(name, payload)
|
25
25
|
controller_name = controller_name_for_metric(payload)
|
26
|
-
"Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub(
|
26
|
+
"Ruby/ActionController#{"/#{controller_name}" if controller_name}/#{name.gsub('.action_controller', '')}"
|
27
27
|
end
|
28
28
|
|
29
29
|
def controller_name_for_metric(payload)
|
@@ -232,7 +232,6 @@ module NewRelic
|
|
232
232
|
|
233
233
|
DEFAULT = 'default'.freeze
|
234
234
|
UNKNOWN = 'unknown'.freeze
|
235
|
-
SLASH = '/'.freeze
|
236
235
|
LOCALHOST = 'localhost'.freeze
|
237
236
|
|
238
237
|
def adapter_from_config(config)
|
@@ -288,7 +287,7 @@ module NewRelic
|
|
288
287
|
private
|
289
288
|
|
290
289
|
def postgres_unix_domain_socket_case?(host, adapter)
|
291
|
-
adapter == :postgres && host && host.start_with?(SLASH)
|
290
|
+
adapter == :postgres && host && host.start_with?(NewRelic::SLASH)
|
292
291
|
end
|
293
292
|
|
294
293
|
def mysql_default_case?(config, adapter)
|
@@ -0,0 +1,69 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module ActiveSupportBroadcastLogger::Chain
|
7
|
+
def self.instrument!
|
8
|
+
::ActiveSupportBroadcastLogger.class_eval do
|
9
|
+
include NewRelic::Agent::Instrumentation::ActiveSupportBroadcastLogger
|
10
|
+
|
11
|
+
alias_method(:add_without_new_relic, :add)
|
12
|
+
|
13
|
+
def add(*args, &task)
|
14
|
+
record_one_broadcast_with_new_relic(*args) do
|
15
|
+
add_without_new_relic(*args, &traced_task)
|
16
|
+
end
|
17
|
+
end
|
18
|
+
|
19
|
+
alias_method(:debug_without_new_relic, :debug)
|
20
|
+
|
21
|
+
def debug(*args, &task)
|
22
|
+
record_one_broadcast_with_new_relic(*args) do
|
23
|
+
debug_without_new_relic(*args, &traced_task)
|
24
|
+
end
|
25
|
+
end
|
26
|
+
|
27
|
+
alias_method(:info_without_new_relic, :info)
|
28
|
+
|
29
|
+
def info(*args, &task)
|
30
|
+
record_one_broadcast_with_new_relic(*args) do
|
31
|
+
info_without_new_relic(*args, &traced_task)
|
32
|
+
end
|
33
|
+
end
|
34
|
+
|
35
|
+
alias_method(:warn_without_new_relic, :warn)
|
36
|
+
|
37
|
+
def warn(*args, &task)
|
38
|
+
record_one_broadcast_with_new_relic(*args) do
|
39
|
+
warn_without_new_relic(*args, &traced_task)
|
40
|
+
end
|
41
|
+
end
|
42
|
+
|
43
|
+
alias_method(:error_without_new_relic, :error)
|
44
|
+
|
45
|
+
def error(*args, &task)
|
46
|
+
record_one_broadcast_with_new_relic(*args) do
|
47
|
+
error_without_new_relic(*args, &traced_task)
|
48
|
+
end
|
49
|
+
end
|
50
|
+
|
51
|
+
alias_method(:fatal_without_new_relic, :fatal)
|
52
|
+
|
53
|
+
def fatal(*args, &task)
|
54
|
+
record_one_broadcast_with_new_relic(*args) do
|
55
|
+
fatal_without_new_relic(*args, &traced_task)
|
56
|
+
end
|
57
|
+
end
|
58
|
+
end
|
59
|
+
|
60
|
+
alias_method(:unknown_without_new_relic, :unknown)
|
61
|
+
|
62
|
+
def unknown(*args, &task)
|
63
|
+
record_one_broadcast_with_new_relic(*args) do
|
64
|
+
unknown_without_new_relic(*args, &traced_task)
|
65
|
+
end
|
66
|
+
end
|
67
|
+
end
|
68
|
+
end
|
69
|
+
end
|
@@ -0,0 +1,13 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module ActiveSupportBroadcastLogger
|
7
|
+
def record_one_broadcast_with_new_relic(*args)
|
8
|
+
broadcasts[1..-1].each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, true) }
|
9
|
+
yield
|
10
|
+
broadcasts.each { |broadcasted_logger| broadcasted_logger.instance_variable_set(:@skip_instrumenting, false) }
|
11
|
+
end
|
12
|
+
end
|
13
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module ActiveSupportBroadcastLogger::Prepend
|
7
|
+
include NewRelic::Agent::Instrumentation::ActiveSupportBroadcastLogger
|
8
|
+
|
9
|
+
def add(*args)
|
10
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
11
|
+
end
|
12
|
+
|
13
|
+
def debug(*args)
|
14
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
15
|
+
end
|
16
|
+
|
17
|
+
def info(*args)
|
18
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
19
|
+
end
|
20
|
+
|
21
|
+
def warn(*args)
|
22
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
23
|
+
end
|
24
|
+
|
25
|
+
def error(*args)
|
26
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
27
|
+
end
|
28
|
+
|
29
|
+
def fatal(*args)
|
30
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
31
|
+
end
|
32
|
+
|
33
|
+
def unknown(*args)
|
34
|
+
record_one_broadcast_with_new_relic(*args) { super }
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'active_support_broadcast_logger/instrumentation'
|
6
|
+
require_relative 'active_support_broadcast_logger/chain'
|
7
|
+
require_relative 'active_support_broadcast_logger/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :'active_support_broadcast_logger'
|
11
|
+
|
12
|
+
depends_on { defined?(ActiveSupport::BroadcastLogger) }
|
13
|
+
|
14
|
+
executes do
|
15
|
+
NewRelic::Agent.logger.info('Installing ActiveSupport::BroadcastLogger instrumentation')
|
16
|
+
|
17
|
+
if use_prepend?
|
18
|
+
prepend_instrument ActiveSupport::BroadcastLogger, NewRelic::Agent::Instrumentation::ActiveSupportBroadcastLogger::Prepend
|
19
|
+
else
|
20
|
+
chain_instrument NewRelic::Agent::Instrumentation::ActiveSupportBroadcastLogger::Chain
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -6,8 +6,12 @@ module NewRelic
|
|
6
6
|
module Agent
|
7
7
|
module Instrumentation
|
8
8
|
module ActiveSupportLogger
|
9
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
10
|
+
|
9
11
|
# Mark @skip_instrumenting on any broadcasted loggers to instrument Rails.logger only
|
10
12
|
def broadcast_with_tracing(logger)
|
13
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
14
|
+
|
11
15
|
NewRelic::Agent::Instrumentation::Logger.mark_skip_instrumenting(logger)
|
12
16
|
yield
|
13
17
|
rescue => error
|
@@ -9,7 +9,9 @@ require_relative 'active_support_logger/prepend'
|
|
9
9
|
DependencyDetection.defer do
|
10
10
|
named :active_support_logger
|
11
11
|
|
12
|
-
depends_on
|
12
|
+
depends_on do
|
13
|
+
defined?(ActiveSupport::Logger) && defined?(ActiveSupport::Logger.broadcast)
|
14
|
+
end
|
13
15
|
|
14
16
|
executes do
|
15
17
|
NewRelic::Agent.logger.info('Installing ActiveSupport::Logger instrumentation')
|
@@ -0,0 +1,23 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module AsyncHttp::Chain
|
9
|
+
def self.instrument!
|
10
|
+
::Async::HTTP::Internet.class_eval do
|
11
|
+
include NewRelic::Agent::Instrumentation::AsyncHttp
|
12
|
+
|
13
|
+
alias_method(:call_without_new_relic, :call)
|
14
|
+
|
15
|
+
def call(method, url, headers = nil, body = nil)
|
16
|
+
call_with_new_relic(method, url, headers, body) do |hdr|
|
17
|
+
call_without_new_relic(method, url, hdr, body)
|
18
|
+
end
|
19
|
+
end
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
@@ -0,0 +1,37 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require 'new_relic/agent/http_clients/async_http_wrappers'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module AsyncHttp
|
9
|
+
def call_with_new_relic(method, url, headers = nil, body = nil)
|
10
|
+
headers ||= {} # if it is nil, we need to make it a hash so we can insert headers
|
11
|
+
wrapped_request = NewRelic::Agent::HTTPClients::AsyncHTTPRequest.new(self, method, url, headers)
|
12
|
+
|
13
|
+
segment = NewRelic::Agent::Tracer.start_external_request_segment(
|
14
|
+
library: wrapped_request.type,
|
15
|
+
uri: wrapped_request.uri,
|
16
|
+
procedure: wrapped_request.method
|
17
|
+
)
|
18
|
+
|
19
|
+
begin
|
20
|
+
response = nil
|
21
|
+
segment.add_request_headers(wrapped_request)
|
22
|
+
|
23
|
+
NewRelic::Agent.disable_all_tracing do
|
24
|
+
response = NewRelic::Agent::Tracer.capture_segment_error(segment) do
|
25
|
+
yield(headers)
|
26
|
+
end
|
27
|
+
end
|
28
|
+
|
29
|
+
wrapped_response = NewRelic::Agent::HTTPClients::AsyncHTTPResponse.new(response)
|
30
|
+
segment.process_response_headers(wrapped_response)
|
31
|
+
response
|
32
|
+
ensure
|
33
|
+
segment&.finish
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
@@ -0,0 +1,15 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module AsyncHttp::Prepend
|
9
|
+
include NewRelic::Agent::Instrumentation::AsyncHttp
|
10
|
+
|
11
|
+
def call(method, url, headers = nil, body = nil)
|
12
|
+
call_with_new_relic(method, url, headers, body) { |hdr| super(method, url, hdr, body) }
|
13
|
+
end
|
14
|
+
end
|
15
|
+
end
|
@@ -0,0 +1,26 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
require_relative 'async_http/instrumentation'
|
6
|
+
require_relative 'async_http/chain'
|
7
|
+
require_relative 'async_http/prepend'
|
8
|
+
|
9
|
+
DependencyDetection.defer do
|
10
|
+
named :async_http
|
11
|
+
|
12
|
+
depends_on do
|
13
|
+
defined?(Async::HTTP) && Gem::Version.new(Async::HTTP::VERSION) >= Gem::Version.new('0.59.0')
|
14
|
+
end
|
15
|
+
|
16
|
+
executes do
|
17
|
+
NewRelic::Agent.logger.info('Installing async_http instrumentation')
|
18
|
+
|
19
|
+
require 'async/http/internet'
|
20
|
+
if use_prepend?
|
21
|
+
prepend_instrument Async::HTTP::Internet, NewRelic::Agent::Instrumentation::AsyncHttp::Prepend
|
22
|
+
else
|
23
|
+
chain_instrument NewRelic::Agent::Instrumentation::AsyncHttp::Chain
|
24
|
+
end
|
25
|
+
end
|
26
|
+
end
|
@@ -12,6 +12,7 @@ module NewRelic
|
|
12
12
|
DEFAULT_NAME = 'Default'
|
13
13
|
DEFAULT_TYPE = :direct
|
14
14
|
SLASH = '/'
|
15
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
15
16
|
|
16
17
|
def exchange_name(name)
|
17
18
|
name.empty? ? DEFAULT_NAME : name
|
@@ -28,6 +29,8 @@ module NewRelic
|
|
28
29
|
include Bunny
|
29
30
|
|
30
31
|
def publish_with_tracing(payload, opts = {})
|
32
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
33
|
+
|
31
34
|
begin
|
32
35
|
destination = exchange_name(name)
|
33
36
|
|
@@ -62,6 +65,8 @@ module NewRelic
|
|
62
65
|
include Bunny
|
63
66
|
|
64
67
|
def pop_with_tracing
|
68
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
69
|
+
|
65
70
|
bunny_error, delivery_info, message_properties, _payload = nil, nil, nil, nil
|
66
71
|
begin
|
67
72
|
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
@@ -104,6 +109,8 @@ module NewRelic
|
|
104
109
|
end
|
105
110
|
|
106
111
|
def purge_with_tracing
|
112
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
113
|
+
|
107
114
|
begin
|
108
115
|
type = server_named? ? :temporary_queue : :queue
|
109
116
|
segment = NewRelic::Agent::Tracer.start_message_broker_segment(
|
@@ -129,6 +136,8 @@ module NewRelic
|
|
129
136
|
include Bunny
|
130
137
|
|
131
138
|
def call_with_tracing(*args)
|
139
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
140
|
+
|
132
141
|
delivery_info, message_properties, _ = args
|
133
142
|
queue_name = queue.respond_to?(:name) ? queue.name : queue
|
134
143
|
|
@@ -5,10 +5,10 @@
|
|
5
5
|
module NewRelic::Agent::Instrumentation
|
6
6
|
module ConcurrentRuby
|
7
7
|
SEGMENT_NAME = 'Concurrent/Task'
|
8
|
-
|
8
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
9
9
|
|
10
10
|
def add_task_tracing(&task)
|
11
|
-
NewRelic::Agent.
|
11
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
12
12
|
|
13
13
|
NewRelic::Agent::Tracer.thread_block_with_current_transaction(
|
14
14
|
segment_name: SEGMENT_NAME,
|
@@ -41,8 +41,6 @@ module NewRelic
|
|
41
41
|
clazz.extend(ClassMethodsShim)
|
42
42
|
end
|
43
43
|
|
44
|
-
def new_relic_trace_controller_action(*args); yield; end
|
45
|
-
|
46
44
|
def perform_action_with_newrelic_trace(*args); yield; end
|
47
45
|
end
|
48
46
|
|
@@ -245,6 +243,7 @@ module NewRelic
|
|
245
243
|
when :background then ::NewRelic::Agent::Transaction::TASK_PREFIX
|
246
244
|
when :rack then ::NewRelic::Agent::Transaction::RACK_PREFIX
|
247
245
|
when :uri then ::NewRelic::Agent::Transaction::CONTROLLER_PREFIX
|
246
|
+
when :roda then ::NewRelic::Agent::Transaction::RODA_PREFIX
|
248
247
|
when :sinatra then ::NewRelic::Agent::Transaction::SINATRA_PREFIX
|
249
248
|
when :middleware then ::NewRelic::Agent::Transaction::MIDDLEWARE_PREFIX
|
250
249
|
when :grape then ::NewRelic::Agent::Transaction::GRAPE_PREFIX
|
@@ -68,6 +68,8 @@ module NewRelic
|
|
68
68
|
module Multi
|
69
69
|
include NewRelic::Agent::MethodTracer
|
70
70
|
|
71
|
+
INSTRUMENTATION_NAME = 'Curb'
|
72
|
+
|
71
73
|
# Add CAT with callbacks if the request is serial
|
72
74
|
def add_with_tracing(curl)
|
73
75
|
if curl.respond_to?(:_nr_serial) && curl._nr_serial
|
@@ -81,6 +83,8 @@ module NewRelic
|
|
81
83
|
def perform_with_tracing
|
82
84
|
return yield if first_request_is_serial?
|
83
85
|
|
86
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
87
|
+
|
84
88
|
trace_execution_scoped('External/Multiple/Curb::Multi/perform') do
|
85
89
|
yield
|
86
90
|
end
|
@@ -31,8 +31,11 @@ module NewRelic
|
|
31
31
|
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
32
32
|
|
33
33
|
NR_TRANSACTION_CATEGORY = 'OtherTransaction/DelayedJob'.freeze
|
34
|
+
INSTRUMENTATION_NAME = 'DelayedJob'
|
34
35
|
|
35
36
|
def invoke_job_with_tracing
|
37
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
38
|
+
|
36
39
|
options = {
|
37
40
|
:category => NR_TRANSACTION_CATEGORY,
|
38
41
|
:path => ::NewRelic::Agent::Instrumentation::DelayedJob::Naming.name_from_payload(payload_object)
|
@@ -8,15 +8,18 @@ module NewRelic::Agent::Instrumentation
|
|
8
8
|
module Elasticsearch
|
9
9
|
PRODUCT_NAME = 'Elasticsearch'
|
10
10
|
OPERATION = 'perform_request'
|
11
|
+
INSTRUMENTATION_NAME = NewRelic::Agent.base_name(name)
|
11
12
|
|
12
13
|
def perform_request_with_tracing(method, path, params = {}, body = nil, headers = nil)
|
13
14
|
return yield unless NewRelic::Agent::Tracer.tracing_enabled?
|
14
15
|
|
16
|
+
NewRelic::Agent.record_instrumentation_invocation(INSTRUMENTATION_NAME)
|
17
|
+
|
15
18
|
segment = NewRelic::Agent::Tracer.start_datastore_segment(
|
16
19
|
product: PRODUCT_NAME,
|
17
20
|
operation: nr_operation || OPERATION,
|
18
21
|
host: nr_hosts[:host],
|
19
|
-
port_path_or_id:
|
22
|
+
port_path_or_id: nr_hosts[:port],
|
20
23
|
database_name: nr_cluster_name
|
21
24
|
)
|
22
25
|
begin
|
@@ -0,0 +1,39 @@
|
|
1
|
+
# This file is distributed under New Relic's license terms.
|
2
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
3
|
+
# frozen_string_literal: true
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module Ethon
|
7
|
+
module Chain
|
8
|
+
def self.instrument!
|
9
|
+
::Ethon::Easy.class_eval do
|
10
|
+
include NewRelic::Agent::Instrumentation::Ethon::Easy
|
11
|
+
|
12
|
+
alias_method(:fabricate_without_tracing, :fabricate)
|
13
|
+
def fabricate(url, action_name, options)
|
14
|
+
fabricate_with_tracing(url, action_name, options) { fabricate_without_tracing(url, action_name, options) }
|
15
|
+
end
|
16
|
+
|
17
|
+
alias_method(:headers_equals_without_tracing, :headers=)
|
18
|
+
def headers=(headers)
|
19
|
+
headers_equals_with_tracing(headers) { headers_equals_without_tracing(headers) }
|
20
|
+
end
|
21
|
+
|
22
|
+
alias_method(:perform_without_tracing, :perform)
|
23
|
+
def perform(*args)
|
24
|
+
perform_with_tracing(*args) { perform_without_tracing(*args) }
|
25
|
+
end
|
26
|
+
end
|
27
|
+
|
28
|
+
::Ethon::Multi.class_eval do
|
29
|
+
include NewRelic::Agent::Instrumentation::Ethon::Multi
|
30
|
+
|
31
|
+
alias_method(:perform_without_tracing, :perform)
|
32
|
+
def perform(*args)
|
33
|
+
perform_with_tracing(*args) { perform_without_tracing(*args) }
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|