newrelic_rpm 6.15.0 → 7.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- checksums.yaml +4 -4
- data/CHANGELOG.md +96 -22
- data/README.md +2 -2
- data/lib/new_relic/agent.rb +0 -6
- data/lib/new_relic/agent/autostart.rb +1 -2
- data/lib/new_relic/agent/configuration/default_source.rb +270 -104
- data/lib/new_relic/agent/configuration/manager.rb +2 -2
- data/lib/new_relic/agent/datastores/redis.rb +0 -4
- data/lib/new_relic/agent/distributed_tracing.rb +0 -66
- data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +0 -16
- data/lib/new_relic/agent/instrumentation/bunny.rb +10 -152
- data/lib/new_relic/agent/instrumentation/bunny/chain.rb +45 -0
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +152 -0
- data/lib/new_relic/agent/instrumentation/bunny/prepend.rb +35 -0
- data/lib/new_relic/agent/instrumentation/curb.rb +9 -241
- data/lib/new_relic/agent/instrumentation/curb/chain.rb +93 -0
- data/lib/new_relic/agent/instrumentation/curb/instrumentation.rb +222 -0
- data/lib/new_relic/agent/instrumentation/curb/prepend.rb +63 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/chain.rb +38 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +53 -0
- data/lib/new_relic/agent/instrumentation/delayed_job/prepend.rb +34 -0
- data/lib/new_relic/agent/instrumentation/delayed_job_instrumentation.rb +8 -50
- data/lib/new_relic/agent/instrumentation/excon.rb +2 -1
- data/lib/new_relic/agent/instrumentation/grape.rb +13 -113
- data/lib/new_relic/agent/instrumentation/grape/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/grape/instrumentation.rb +100 -0
- data/lib/new_relic/agent/instrumentation/grape/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httpclient.rb +8 -30
- data/lib/new_relic/agent/instrumentation/httpclient/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/httpclient/instrumentation.rb +38 -0
- data/lib/new_relic/agent/instrumentation/httpclient/prepend.rb +17 -0
- data/lib/new_relic/agent/instrumentation/httprb.rb +29 -0
- data/lib/new_relic/agent/instrumentation/httprb/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/httprb/instrumentation.rb +30 -0
- data/lib/new_relic/agent/instrumentation/httprb/prepend.rb +15 -0
- data/lib/new_relic/agent/instrumentation/memcache.rb +54 -69
- data/lib/new_relic/agent/instrumentation/memcache/chain.rb +16 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +38 -121
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +56 -0
- data/lib/new_relic/agent/instrumentation/memcache/instrumentation.rb +88 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +88 -0
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -0
- data/lib/new_relic/agent/instrumentation/mongo.rb +7 -0
- data/lib/new_relic/agent/instrumentation/net_http.rb +39 -0
- data/lib/new_relic/agent/instrumentation/net_http/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/{net_prepend.rb → net_http/instrumentation.rb} +3 -3
- data/lib/new_relic/agent/instrumentation/net_http/prepend.rb +21 -0
- data/lib/new_relic/agent/instrumentation/padrino.rb +18 -53
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/padrino/instrumentation.rb +27 -0
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +20 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +29 -139
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +57 -0
- data/lib/new_relic/agent/instrumentation/rack/helpers.rb +32 -0
- data/lib/new_relic/agent/instrumentation/rack/instrumentation.rb +73 -0
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +36 -0
- data/lib/new_relic/agent/instrumentation/rake.rb +13 -154
- data/lib/new_relic/agent/instrumentation/rake/chain.rb +25 -0
- data/lib/new_relic/agent/instrumentation/rake/instrumentation.rb +144 -0
- data/lib/new_relic/agent/instrumentation/rake/prepend.rb +14 -0
- data/lib/new_relic/agent/instrumentation/redis.rb +10 -109
- data/lib/new_relic/agent/instrumentation/redis/chain.rb +34 -0
- data/lib/new_relic/agent/instrumentation/redis/instrumentation.rb +65 -0
- data/lib/new_relic/agent/instrumentation/redis/prepend.rb +24 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +8 -28
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +33 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -158
- data/lib/new_relic/agent/instrumentation/sinatra/chain.rb +55 -0
- data/lib/new_relic/agent/instrumentation/sinatra/ignorer.rb +29 -34
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +118 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/typhoeus.rb +10 -89
- data/lib/new_relic/agent/instrumentation/typhoeus/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/instrumentation.rb +82 -0
- data/lib/new_relic/agent/instrumentation/typhoeus/prepend.rb +14 -0
- data/lib/new_relic/agent/new_relic_service.rb +3 -12
- data/lib/new_relic/agent/sql_sampler.rb +1 -1
- data/lib/new_relic/agent/transaction.rb +1 -4
- data/lib/new_relic/control/frameworks/rails.rb +11 -9
- data/lib/new_relic/control/instance_methods.rb +1 -0
- data/lib/new_relic/dependency_detection.rb +116 -10
- data/lib/new_relic/noticed_error.rb +1 -5
- data/lib/new_relic/supportability_helper.rb +1 -2
- data/lib/new_relic/version.rb +2 -2
- data/newrelic_rpm.gemspec +1 -1
- metadata +53 -8
- data/cert/cacert.pem +0 -1177
- data/lib/new_relic/agent/instrumentation/http.rb +0 -49
- data/lib/new_relic/agent/instrumentation/net.rb +0 -70
@@ -0,0 +1,63 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require_relative 'instrumentation'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module Instrumentation
|
11
|
+
module Curb
|
12
|
+
module Easy
|
13
|
+
module Prepend
|
14
|
+
include NewRelic::Agent::Instrumentation::Curb::Easy
|
15
|
+
|
16
|
+
def http_head(*args, &blk)
|
17
|
+
http_head_with_tracing { super }
|
18
|
+
end
|
19
|
+
|
20
|
+
def http_post(*args, &blk)
|
21
|
+
http_post_with_tracing { super }
|
22
|
+
end
|
23
|
+
|
24
|
+
def http_put(*args, &blk)
|
25
|
+
http_put_with_tracing { super }
|
26
|
+
end
|
27
|
+
|
28
|
+
def http verb
|
29
|
+
http_with_tracing(verb) { super }
|
30
|
+
end
|
31
|
+
|
32
|
+
def perform
|
33
|
+
perform_with_tracing { super }
|
34
|
+
end
|
35
|
+
|
36
|
+
def method verb
|
37
|
+
method_with_tracing { super }
|
38
|
+
end
|
39
|
+
|
40
|
+
def header_str
|
41
|
+
header_str_with_tracing { super }
|
42
|
+
end
|
43
|
+
end
|
44
|
+
end
|
45
|
+
|
46
|
+
module Multi
|
47
|
+
module Prepend
|
48
|
+
include NewRelic::Agent::Instrumentation::Curb::Multi
|
49
|
+
|
50
|
+
def add(curl)
|
51
|
+
add_with_tracing(curl) { super }
|
52
|
+
end
|
53
|
+
|
54
|
+
def perform(&blk)
|
55
|
+
perform_with_tracing { super }
|
56
|
+
end
|
57
|
+
|
58
|
+
end
|
59
|
+
end
|
60
|
+
end
|
61
|
+
end
|
62
|
+
end
|
63
|
+
end
|
@@ -0,0 +1,38 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
|
+
require_relative 'instrumentation'
|
6
|
+
|
7
|
+
module NewRelic::Agent::Instrumentation
|
8
|
+
module DelayedJob
|
9
|
+
module Chain
|
10
|
+
def self.instrument!
|
11
|
+
Delayed::Worker.class_eval do
|
12
|
+
include NewRelic::Agent::Instrumentation::DelayedJob
|
13
|
+
|
14
|
+
def initialize_with_new_relic(*args)
|
15
|
+
initialize_with_tracing { initialize_without_new_relic(*args) }
|
16
|
+
end
|
17
|
+
|
18
|
+
alias initialize_without_new_relic initialize
|
19
|
+
alias initialize initialize_with_new_relic
|
20
|
+
|
21
|
+
|
22
|
+
def install_newrelic_job_tracer
|
23
|
+
Delayed::Job.class_eval do
|
24
|
+
include NewRelic::Agent::Instrumentation::DelayedJobTracer
|
25
|
+
|
26
|
+
alias_method :invoke_job_without_new_relic, :invoke_job
|
27
|
+
|
28
|
+
def invoke_job(*args, &block)
|
29
|
+
invoke_job_with_tracing { invoke_job_without_new_relic(*args, &block) }
|
30
|
+
end
|
31
|
+
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
35
|
+
end
|
36
|
+
end
|
37
|
+
end
|
38
|
+
end
|
@@ -0,0 +1,53 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
|
7
|
+
module NewRelic
|
8
|
+
module Agent
|
9
|
+
module Instrumentation
|
10
|
+
module DelayedJob
|
11
|
+
|
12
|
+
def initialize_with_tracing
|
13
|
+
yield
|
14
|
+
worker_name = case
|
15
|
+
when self.respond_to?(:name) then self.name
|
16
|
+
when self.class.respond_to?(:default_name) then self.class.default_name
|
17
|
+
end
|
18
|
+
NewRelic::DelayedJobInjection.worker_name = worker_name
|
19
|
+
|
20
|
+
if defined?(::Delayed::Job) && ::Delayed::Job.method_defined?(:invoke_job) &&
|
21
|
+
!(::Delayed::Job.method_defined?(:invoke_job_without_new_relic) )
|
22
|
+
|
23
|
+
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation [part 2/2]'
|
24
|
+
install_newrelic_job_tracer
|
25
|
+
NewRelic::Control.instance.init_plugin :dispatcher => :delayed_job
|
26
|
+
else
|
27
|
+
NewRelic::Agent.logger.warn("Did not find a Delayed::Job class responding to invoke_job, aborting DJ instrumentation")
|
28
|
+
end
|
29
|
+
end
|
30
|
+
|
31
|
+
end
|
32
|
+
|
33
|
+
module DelayedJobTracer
|
34
|
+
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
35
|
+
|
36
|
+
NR_TRANSACTION_CATEGORY = 'OtherTransaction/DelayedJob'.freeze
|
37
|
+
|
38
|
+
def invoke_job_with_tracing
|
39
|
+
options = {
|
40
|
+
:category => NR_TRANSACTION_CATEGORY,
|
41
|
+
:path => ::NewRelic::Agent::Instrumentation::DelayedJob::Naming.name_from_payload(payload_object)
|
42
|
+
}
|
43
|
+
|
44
|
+
perform_action_with_newrelic_trace(options) do
|
45
|
+
yield
|
46
|
+
end
|
47
|
+
end
|
48
|
+
|
49
|
+
end
|
50
|
+
end
|
51
|
+
end
|
52
|
+
end
|
53
|
+
|
@@ -0,0 +1,34 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
# frozen_string_literal: true
|
5
|
+
|
6
|
+
require_relative 'instrumentation'
|
7
|
+
|
8
|
+
module NewRelic
|
9
|
+
module Agent
|
10
|
+
module Instrumentation
|
11
|
+
module DelayedJob
|
12
|
+
module Prepend
|
13
|
+
include NewRelic::Agent::Instrumentation::DelayedJob
|
14
|
+
|
15
|
+
def initialize(*args)
|
16
|
+
initialize_with_tracing { super }
|
17
|
+
end
|
18
|
+
|
19
|
+
def install_newrelic_job_tracer
|
20
|
+
Delayed::Job.send :prepend, ::NewRelic::Agent::Instrumentation::DelayedJobTracerPrepend
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
|
25
|
+
module DelayedJobTracerPrepend
|
26
|
+
include NewRelic::Agent::Instrumentation::DelayedJobTracer
|
27
|
+
|
28
|
+
def invoke_job(*args, &block)
|
29
|
+
invoke_job_with_tracing { super }
|
30
|
+
end
|
31
|
+
end
|
32
|
+
end
|
33
|
+
end
|
34
|
+
end
|
@@ -2,6 +2,9 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
|
5
|
+
require_relative 'delayed_job/chain'
|
6
|
+
require_relative 'delayed_job/prepend'
|
7
|
+
|
5
8
|
require 'new_relic/agent/instrumentation/controller_instrumentation'
|
6
9
|
|
7
10
|
module NewRelic
|
@@ -76,11 +79,7 @@ DependencyDetection.defer do
|
|
76
79
|
@name = :delayed_job
|
77
80
|
|
78
81
|
depends_on do
|
79
|
-
|
80
|
-
end
|
81
|
-
|
82
|
-
depends_on do
|
83
|
-
defined?(::Delayed) && defined?(::Delayed::Worker) && !NewRelic::Agent.config[:disable_dj]
|
82
|
+
defined?(::Delayed) && defined?(::Delayed::Worker)
|
84
83
|
end
|
85
84
|
|
86
85
|
executes do
|
@@ -88,51 +87,10 @@ DependencyDetection.defer do
|
|
88
87
|
end
|
89
88
|
|
90
89
|
executes do
|
91
|
-
|
92
|
-
|
93
|
-
|
94
|
-
|
95
|
-
worker_name = case
|
96
|
-
when self.respond_to?(:name) then self.name
|
97
|
-
when self.class.respond_to?(:default_name) then self.class.default_name
|
98
|
-
end
|
99
|
-
NewRelic::DelayedJobInjection.worker_name = worker_name
|
100
|
-
|
101
|
-
if defined?(::Delayed::Job) && ::Delayed::Job.method_defined?(:invoke_job) &&
|
102
|
-
!(::Delayed::Job.method_defined?(:invoke_job_without_new_relic) )
|
103
|
-
|
104
|
-
::NewRelic::Agent.logger.info 'Installing DelayedJob instrumentation [part 2/2]'
|
105
|
-
install_newrelic_job_tracer
|
106
|
-
NewRelic::Control.instance.init_plugin :dispatcher => :delayed_job
|
107
|
-
else
|
108
|
-
NewRelic::Agent.logger.warn("Did not find a Delayed::Job class responding to invoke_job, aborting DJ instrumentation")
|
109
|
-
end
|
110
|
-
end
|
111
|
-
|
112
|
-
alias initialize_without_new_relic initialize
|
113
|
-
alias initialize initialize_with_new_relic
|
114
|
-
|
115
|
-
NR_TRANSACTION_CATEGORY = 'OtherTransaction/DelayedJob'.freeze
|
116
|
-
|
117
|
-
def install_newrelic_job_tracer
|
118
|
-
Delayed::Job.class_eval do
|
119
|
-
include NewRelic::Agent::Instrumentation::ControllerInstrumentation
|
120
|
-
|
121
|
-
alias_method :invoke_job_without_new_relic, :invoke_job
|
122
|
-
|
123
|
-
def invoke_job(*args, &block)
|
124
|
-
options = {
|
125
|
-
:category => NR_TRANSACTION_CATEGORY,
|
126
|
-
:path => ::NewRelic::Agent::Instrumentation::DelayedJob::Naming.name_from_payload(payload_object)
|
127
|
-
}
|
128
|
-
|
129
|
-
perform_action_with_newrelic_trace(options) do
|
130
|
-
invoke_job_without_new_relic(*args, &block)
|
131
|
-
end
|
132
|
-
end
|
133
|
-
|
134
|
-
end
|
135
|
-
end
|
90
|
+
if use_prepend?
|
91
|
+
prepend_instrument ::Delayed::Worker, ::NewRelic::Agent::Instrumentation::DelayedJob::Prepend
|
92
|
+
else
|
93
|
+
chain_instrument ::NewRelic::Agent::Instrumentation::DelayedJob::Chain
|
136
94
|
end
|
137
95
|
end
|
138
96
|
end
|
@@ -65,7 +65,8 @@ DependencyDetection.defer do
|
|
65
65
|
end
|
66
66
|
|
67
67
|
def install_legacy_excon_instrumentation
|
68
|
-
::NewRelic::Agent.
|
68
|
+
::NewRelic::Agent::Deprecator.deprecate :install_legacy_excon_instrumentation, :install_middleware_excon_instrumentation, "8.0.0"
|
69
|
+
::NewRelic::Agent.logger.warn 'Installing deprecated legacy Excon instrumentation. This instrumentation will be removed in a future release. Update Excon version to > 0.19.0 for updated instrumentation'
|
69
70
|
require 'new_relic/agent/instrumentation/excon/connection'
|
70
71
|
::Excon::Connection.install_newrelic_instrumentation
|
71
72
|
end
|
@@ -2,90 +2,19 @@
|
|
2
2
|
# This file is distributed under New Relic's license terms.
|
3
3
|
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
4
|
|
5
|
-
|
6
|
-
|
7
|
-
|
8
|
-
module Agent
|
9
|
-
module Instrumentation
|
10
|
-
module GrapeInstrumentation
|
11
|
-
extend self
|
12
|
-
|
13
|
-
API_ENDPOINT = 'api.endpoint'.freeze
|
14
|
-
API_VERSION = 'api.version'.freeze
|
15
|
-
FORMAT_REGEX = /\(\/?\.[\:\w]*\)/.freeze # either :format (< 0.12.0) or .ext (>= 0.12.0)
|
16
|
-
VERSION_REGEX = /:version(\/|$)/.freeze
|
17
|
-
MIN_VERSION = Gem::Version.new("0.2.0")
|
18
|
-
PIPE_STRING = '|'.freeze
|
19
|
-
|
20
|
-
def handle_transaction(endpoint, class_name, version)
|
21
|
-
return unless endpoint && route = endpoint.route
|
22
|
-
name_transaction(route, class_name, version)
|
23
|
-
capture_params(endpoint)
|
24
|
-
end
|
25
|
-
|
26
|
-
def name_transaction(route, class_name, version)
|
27
|
-
txn_name = name_for_transaction(route, class_name, version)
|
28
|
-
segment_name = "Middleware/Grape/#{class_name}/call"
|
29
|
-
Transaction.set_default_transaction_name(txn_name, :grape)
|
30
|
-
txn = NewRelic::Agent::Transaction.tl_current
|
31
|
-
txn.segments.last.name = segment_name
|
32
|
-
end
|
33
|
-
|
34
|
-
def name_for_transaction(route, class_name, version)
|
35
|
-
action_name = route.path.sub(FORMAT_REGEX, NewRelic::EMPTY_STR)
|
36
|
-
method_name = route.request_method
|
37
|
-
version ||= route.version
|
38
|
-
|
39
|
-
# defaulting does not set rack.env['api.version'] and route.version may return Array
|
40
|
-
#
|
41
|
-
version = version.join(PIPE_STRING) if Array === version
|
42
|
-
|
43
|
-
if version
|
44
|
-
action_name = action_name.sub(VERSION_REGEX, NewRelic::EMPTY_STR)
|
45
|
-
"#{class_name}-#{version}#{action_name} (#{method_name})"
|
46
|
-
else
|
47
|
-
"#{class_name}#{action_name} (#{method_name})"
|
48
|
-
end
|
49
|
-
end
|
50
|
-
|
51
|
-
def name_for_transaction_deprecated(route, class_name, version)
|
52
|
-
action_name = route.route_path.sub(FORMAT_REGEX, NewRelic::EMPTY_STR)
|
53
|
-
method_name = route.route_method
|
54
|
-
version ||= route.route_version
|
55
|
-
|
56
|
-
if version
|
57
|
-
action_name = action_name.sub(VERSION_REGEX, NewRelic::EMPTY_STR)
|
58
|
-
"#{class_name}-#{version}#{action_name} (#{method_name})"
|
59
|
-
else
|
60
|
-
"#{class_name}#{action_name} (#{method_name})"
|
61
|
-
end
|
62
|
-
end
|
63
|
-
|
64
|
-
def capture_params(endpoint)
|
65
|
-
txn = Transaction.tl_current
|
66
|
-
env = endpoint.request.env
|
67
|
-
params = ParameterFiltering::apply_filters(env, endpoint.params)
|
68
|
-
params.delete("route_info")
|
69
|
-
txn.filtered_params = params
|
70
|
-
txn.merge_request_parameters(params)
|
71
|
-
end
|
72
|
-
end
|
73
|
-
end
|
74
|
-
end
|
75
|
-
end
|
5
|
+
require_relative 'grape/instrumentation'
|
6
|
+
require_relative 'grape/chain'
|
7
|
+
require_relative 'grape/prepend'
|
76
8
|
|
77
9
|
DependencyDetection.defer do
|
78
10
|
# Why not just :grape? newrelic-grape used that name already, and while we're
|
79
11
|
# not shipping yet, overloading the name interferes with the plugin.
|
80
12
|
named :grape_instrumentation
|
81
|
-
|
82
|
-
|
83
|
-
::NewRelic::Agent.config[:disable_grape] == false
|
84
|
-
end
|
85
|
-
|
13
|
+
configure_with :grape
|
14
|
+
|
86
15
|
depends_on do
|
87
16
|
defined?(::Grape::VERSION) &&
|
88
|
-
Gem::Version.new(::Grape::VERSION) >= ::NewRelic::Agent::Instrumentation::
|
17
|
+
Gem::Version.new(::Grape::VERSION) >= ::NewRelic::Agent::Instrumentation::Grape::Instrumentation::MIN_VERSION
|
89
18
|
end
|
90
19
|
|
91
20
|
depends_on do
|
@@ -103,43 +32,14 @@ DependencyDetection.defer do
|
|
103
32
|
end
|
104
33
|
|
105
34
|
executes do
|
106
|
-
NewRelic::Agent.
|
107
|
-
instrument_call
|
108
|
-
end
|
35
|
+
::NewRelic::Agent::Instrumentation::Grape::Instrumentation.prepare!
|
109
36
|
|
110
|
-
|
111
|
-
|
112
|
-
::NewRelic::Agent::Instrumentation::
|
113
|
-
else
|
114
|
-
::NewRelic::Agent::Instrumentation::
|
115
|
-
::NewRelic::Agent::Instrumentation::GrapeInstrumentation.send :alias_method, :name_for_transaction, :name_for_transaction_deprecated
|
116
|
-
end
|
117
|
-
|
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`
|
119
|
-
# https://github.com/ruby-grape/grape/blob/c20a73ac1e3f3ba1082005ed61bf69452373ba87/UPGRADING.md#upgrading-to--120
|
120
|
-
grape_api_class = defined?(Grape::API::Instance) ? ::Grape::API::Instance : ::Grape::API
|
121
|
-
|
122
|
-
grape_api_class.class_eval do
|
123
|
-
def call_with_new_relic(env)
|
124
|
-
begin
|
125
|
-
response = call_without_new_relic(env)
|
126
|
-
ensure
|
127
|
-
begin
|
128
|
-
endpoint = env[::NewRelic::Agent::Instrumentation::GrapeInstrumentation::API_ENDPOINT]
|
129
|
-
version = env[::NewRelic::Agent::Instrumentation::GrapeInstrumentation::API_VERSION]
|
130
|
-
|
131
|
-
api_class = (self.class.respond_to?(:base) && self.class.base) || self.class
|
132
|
-
::NewRelic::Agent::Instrumentation::GrapeInstrumentation.handle_transaction(endpoint, api_class.name, version)
|
133
|
-
rescue => e
|
134
|
-
::NewRelic::Agent.logger.warn("Error in Grape instrumentation", e)
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
response
|
139
|
-
end
|
140
|
-
|
141
|
-
alias_method :call_without_new_relic, :call
|
142
|
-
alias_method :call, :call_with_new_relic
|
37
|
+
if use_prepend?
|
38
|
+
instrumented_class = ::NewRelic::Agent::Instrumentation::Grape::Instrumentation.instrumented_class
|
39
|
+
prepend_instrument instrumented_class, ::NewRelic::Agent::Instrumentation::Grape::Prepend
|
40
|
+
else
|
41
|
+
chain_instrument ::NewRelic::Agent::Instrumentation::Grape::Chain
|
143
42
|
end
|
144
43
|
end
|
44
|
+
|
145
45
|
end
|
@@ -0,0 +1,25 @@
|
|
1
|
+
# encoding: utf-8
|
2
|
+
# This file is distributed under New Relic's license terms.
|
3
|
+
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details.
|
4
|
+
|
5
|
+
module NewRelic::Agent::Instrumentation
|
6
|
+
module Grape
|
7
|
+
module Chain
|
8
|
+
def self.instrument!
|
9
|
+
Grape::Instrumentation.instrumented_class.class_eval do
|
10
|
+
def call_with_new_relic env
|
11
|
+
begin
|
12
|
+
call_without_new_relic env
|
13
|
+
ensure
|
14
|
+
Grape::Instrumentation.capture_transaction env, self
|
15
|
+
end
|
16
|
+
end
|
17
|
+
|
18
|
+
alias_method :call_without_new_relic, :call
|
19
|
+
alias_method :call, :call_with_new_relic
|
20
|
+
end
|
21
|
+
end
|
22
|
+
end
|
23
|
+
end
|
24
|
+
end
|
25
|
+
|