newrelic_rpm 7.2.0 → 8.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.gitignore +2 -0
- data/CHANGELOG.md +105 -9
- data/README.md +2 -0
- data/lib/new_relic/agent/adaptive_sampler.rb +2 -2
- data/lib/new_relic/agent/agent.rb +6 -6
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -3
- data/lib/new_relic/agent/configuration/default_source.rb +15 -7
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +28 -12
- data/lib/new_relic/agent/configuration/manager.rb +0 -1
- data/lib/new_relic/agent/configuration/server_source.rb +3 -2
- data/lib/new_relic/agent/configuration/yaml_source.rb +22 -1
- data/lib/new_relic/agent/custom_event_aggregator.rb +2 -1
- data/lib/new_relic/agent/database.rb +5 -2
- data/lib/new_relic/agent/datastores/mongo.rb +5 -10
- data/lib/new_relic/agent/datastores.rb +7 -7
- data/lib/new_relic/agent/distributed_tracing/cross_app_payload.rb +5 -5
- data/lib/new_relic/agent/distributed_tracing/cross_app_tracing.rb +10 -6
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_attributes.rb +0 -1
- data/lib/new_relic/agent/distributed_tracing/distributed_trace_payload.rb +1 -1
- data/lib/new_relic/agent/distributed_tracing/trace_context_payload.rb +1 -1
- data/lib/new_relic/agent/event_loop.rb +6 -6
- data/lib/new_relic/agent/external.rb +0 -32
- data/lib/new_relic/agent/http_clients/abstract.rb +2 -2
- data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +1 -1
- data/lib/new_relic/agent/instrumentation/active_merchant.rb +3 -3
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/excon.rb +4 -23
- data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
- data/lib/new_relic/agent/instrumentation/queue_time.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +5 -5
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +1 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -41
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -1
- data/lib/new_relic/agent/javascript_instrumentor.rb +3 -3
- data/lib/new_relic/agent/messaging.rb +10 -24
- data/lib/new_relic/agent/method_tracer.rb +132 -138
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +6 -1
- data/lib/new_relic/agent/new_relic_service.rb +9 -9
- data/lib/new_relic/agent/pipe_channel_manager.rb +10 -6
- data/lib/new_relic/agent/pipe_service.rb +1 -1
- data/lib/new_relic/agent/samplers/cpu_sampler.rb +1 -1
- data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +1 -1
- data/lib/new_relic/agent/stats_engine/stats_hash.rb +1 -1
- data/lib/new_relic/agent/stats_engine.rb +1 -1
- data/lib/new_relic/agent/supported_versions.rb +1 -1
- data/lib/new_relic/agent/threading/backtrace_service.rb +4 -5
- data/lib/new_relic/agent/threading/thread_profile.rb +1 -1
- data/lib/new_relic/agent/tracer.rb +15 -37
- data/lib/new_relic/agent/transaction/abstract_segment.rb +3 -3
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -11
- data/lib/new_relic/agent/transaction.rb +7 -28
- data/lib/new_relic/agent/transaction_time_aggregator.rb +5 -5
- data/lib/new_relic/agent/vm/snapshot.rb +1 -1
- data/lib/new_relic/agent/worker_loop.rb +5 -5
- data/lib/new_relic/agent.rb +5 -5
- data/lib/new_relic/cli/commands/deployments.rb +2 -2
- data/lib/new_relic/constants.rb +0 -4
- data/lib/new_relic/noticed_error.rb +2 -2
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +10 -34
- data/lib/tasks/all.rb +1 -1
- data/newrelic.yml +593 -3
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +27 -2
- metadata +3 -8
- data/lib/new_relic/agent/datastores/mongo/statement_formatter.rb +0 -53
- data/lib/new_relic/agent/instrumentation/excon/connection.rb +0 -49
- data/lib/new_relic/agent/instrumentation/merb/controller.rb +0 -44
- data/lib/new_relic/agent/instrumentation/merb/errors.rb +0 -33
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -50,7 +50,7 @@ module NewRelic
|
|
50
50
|
|
51
51
|
payload.id = current_segment_id(transaction)
|
52
52
|
payload.transaction_id = transaction.guid
|
53
|
-
payload.timestamp = (
|
53
|
+
payload.timestamp = Process.clock_gettime(Process::CLOCK_REALTIME, :millisecond)
|
54
54
|
payload.trace_id = transaction.trace_id
|
55
55
|
payload.sampled = transaction.sampled?
|
56
56
|
payload.priority = transaction.priority
|
@@ -14,7 +14,7 @@ module NewRelic
|
|
14
14
|
@interval = interval
|
15
15
|
@event = event
|
16
16
|
@repeat = repeat
|
17
|
-
@started_at =
|
17
|
+
@started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
18
18
|
@last_fired_at = nil
|
19
19
|
reschedule
|
20
20
|
end
|
@@ -32,7 +32,7 @@ module NewRelic
|
|
32
32
|
end
|
33
33
|
|
34
34
|
def calculate_next_fire_time
|
35
|
-
now =
|
35
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
36
36
|
return now if @interval == 0
|
37
37
|
fire_time = @last_fired_at || now
|
38
38
|
while fire_time <= now
|
@@ -42,10 +42,10 @@ module NewRelic
|
|
42
42
|
end
|
43
43
|
|
44
44
|
def set_fired_time
|
45
|
-
@last_fired_at =
|
45
|
+
@last_fired_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
46
46
|
end
|
47
47
|
|
48
|
-
def due?(now=
|
48
|
+
def due?(now=Process.clock_gettime(Process::CLOCK_REALTIME))
|
49
49
|
now >= @next_fire_time
|
50
50
|
end
|
51
51
|
|
@@ -69,7 +69,7 @@ module NewRelic
|
|
69
69
|
existing_timer = @timers[timer.event]
|
70
70
|
|
71
71
|
if existing_timer
|
72
|
-
elapsed_interval =
|
72
|
+
elapsed_interval = Process.clock_gettime(Process::CLOCK_REALTIME) - existing_timer.last_interval_start
|
73
73
|
timer.advance(elapsed_interval)
|
74
74
|
end
|
75
75
|
|
@@ -80,7 +80,7 @@ module NewRelic
|
|
80
80
|
|
81
81
|
def next_timeout
|
82
82
|
return nil if @timers.empty?
|
83
|
-
timeout = @timers.values.map(&:next_fire_time).min -
|
83
|
+
timeout = @timers.values.map(&:next_fire_time).min - Process.clock_gettime(Process::CLOCK_REALTIME)
|
84
84
|
timeout < 0 ? 0 : timeout
|
85
85
|
end
|
86
86
|
|
@@ -18,38 +18,6 @@ module NewRelic
|
|
18
18
|
module External
|
19
19
|
extend self
|
20
20
|
|
21
|
-
# This method creates and starts an external request segment using the
|
22
|
-
# given library, URI, and procedure. This is used to time external calls
|
23
|
-
# made over HTTP.
|
24
|
-
#
|
25
|
-
# @param [String] library a string of the class name of the library used to
|
26
|
-
# make the external call, for example, 'Net::HTTP'.
|
27
|
-
#
|
28
|
-
# @param [String, URI] uri indicates the URI to which the
|
29
|
-
# external request is being made. The URI should begin with the protocol,
|
30
|
-
# for example, 'https://github.com'.
|
31
|
-
#
|
32
|
-
# @param [String] procedure the HTTP method being used for the external
|
33
|
-
# request as a string, for example, 'GET'.
|
34
|
-
#
|
35
|
-
# @api public
|
36
|
-
def start_segment(library: nil, uri: nil, procedure: nil)
|
37
|
-
Deprecator.deprecate 'External.start_segment',
|
38
|
-
'Tracer#start_external_request_segment'
|
39
|
-
|
40
|
-
raise ArgumentError, 'Argument `library` is required' if library.nil?
|
41
|
-
raise ArgumentError, 'Argument `uri` is required' if uri.nil?
|
42
|
-
raise ArgumentError, 'Argument `procedure` is required' if procedure.nil?
|
43
|
-
|
44
|
-
::NewRelic::Agent.record_api_supportability_metric(:start_segment)
|
45
|
-
|
46
|
-
::NewRelic::Agent::Tracer.start_external_request_segment(
|
47
|
-
library: library,
|
48
|
-
uri: uri,
|
49
|
-
procedure: procedure
|
50
|
-
)
|
51
|
-
end
|
52
|
-
|
53
21
|
NON_HTTP_CAT_ID_HEADER = 'NewRelicID'.freeze
|
54
22
|
NON_HTTP_CAT_TXN_HEADER = 'NewRelicTransaction'.freeze
|
55
23
|
NON_HTTP_CAT_SYNTHETICS_HEADER = 'NewRelicSynthetics'.freeze
|
@@ -46,7 +46,7 @@ module NewRelic
|
|
46
46
|
# NOTE: response_object should be non-nil!
|
47
47
|
class AbstractResponse # :nodoc:
|
48
48
|
|
49
|
-
def initialize
|
49
|
+
def initialize(wrapped_response)
|
50
50
|
if wrapped_response.nil?
|
51
51
|
raise ArgumentError, WHINY_NIL_ERROR % self.class
|
52
52
|
end
|
@@ -65,7 +65,7 @@ module NewRelic
|
|
65
65
|
|
66
66
|
private
|
67
67
|
|
68
|
-
def get_status_code_using
|
68
|
+
def get_status_code_using(method_name)
|
69
69
|
return unless @wrapped_response.respond_to?(method_name)
|
70
70
|
code = @wrapped_response.send(method_name).to_i
|
71
71
|
code == 0 ? nil : code
|
@@ -91,7 +91,7 @@ module NewRelic
|
|
91
91
|
|
92
92
|
def queue_start(request)
|
93
93
|
if request && request.respond_to?(:env)
|
94
|
-
QueueTime.parse_frontend_timestamp(request.env,
|
94
|
+
QueueTime.parse_frontend_timestamp(request.env, Process.clock_gettime(Process::CLOCK_REALTIME))
|
95
95
|
end
|
96
96
|
end
|
97
97
|
end
|
@@ -26,9 +26,9 @@ DependencyDetection.defer do
|
|
26
26
|
gateway_name = self.name.split('::').last
|
27
27
|
[:authorize, :purchase, :credit, :void, :capture, :recurring, :store, :unstore, :update].each do |operation|
|
28
28
|
if implemented_methods.include?(operation)
|
29
|
-
add_method_tracer operation, "ActiveMerchant/gateway/#{gateway_name}/#{operation}"
|
30
|
-
|
31
|
-
|
29
|
+
add_method_tracer operation, [-> (*) { "ActiveMerchant/gateway/#{gateway_name}/#{operation}" },
|
30
|
+
-> (*) { "ActiveMerchant/gateway/#{gateway_name}" },
|
31
|
+
-> (*) { "ActiveMerchant/operation/#{operation}" }]
|
32
32
|
end
|
33
33
|
end
|
34
34
|
end
|
@@ -65,7 +65,7 @@ module NewRelic
|
|
65
65
|
def pop_with_tracing
|
66
66
|
bunny_error, delivery_info, message_properties, _payload = nil, nil, nil, nil
|
67
67
|
begin
|
68
|
-
t0 =
|
68
|
+
t0 = Process.clock_gettime(Process::CLOCK_REALTIME)
|
69
69
|
msg = yield
|
70
70
|
delivery_info, message_properties, _payload = msg
|
71
71
|
rescue StandardError => error
|
@@ -277,7 +277,7 @@ module NewRelic
|
|
277
277
|
end
|
278
278
|
|
279
279
|
# Yield to the given block with NewRelic tracing. Used by
|
280
|
-
# default instrumentation on controller actions in Rails
|
280
|
+
# default instrumentation on controller actions in Rails.
|
281
281
|
# But it can also be used in custom instrumentation of controller
|
282
282
|
# methods and background tasks.
|
283
283
|
#
|
@@ -5,17 +5,9 @@
|
|
5
5
|
DependencyDetection.defer do
|
6
6
|
named :excon
|
7
7
|
|
8
|
-
# We
|
9
|
-
# - For newer versions, use the middleware mechanism Excon exposes
|
10
|
-
# - For older versions, monkey-patch Excon::Connection#request
|
8
|
+
# We instrument Excon 0.19.0 and above using the middleware mechanism
|
11
9
|
#
|
12
10
|
# EXCON_MIN_VERSION is the minimum version we attempt to instrument at all.
|
13
|
-
# EXCON_MIDDLEWARE_MIN_VERSION is the min version we use the newer
|
14
|
-
# instrumentation for.
|
15
|
-
#
|
16
|
-
# Note that middlewares were added to Excon prior to 0.19, but we don't
|
17
|
-
# use middleware-based instrumentation prior to that version because it didn't
|
18
|
-
# expose a way for middlewares to know about request failures.
|
19
11
|
#
|
20
12
|
# Why don't we use Excon.defaults[:instrumentor]?
|
21
13
|
# While this might seem a perfect fit, it unfortunately isn't suitable in
|
@@ -25,8 +17,7 @@ DependencyDetection.defer do
|
|
25
17
|
# so we could safely subscribe and not be clobbered by future subscribers,
|
26
18
|
# but alas, it does not yet.
|
27
19
|
|
28
|
-
EXCON_MIN_VERSION = Gem::Version.new("0.
|
29
|
-
EXCON_MIDDLEWARE_MIN_VERSION = Gem::Version.new("0.19.0")
|
20
|
+
EXCON_MIN_VERSION = Gem::Version.new("0.19.0")
|
30
21
|
|
31
22
|
depends_on do
|
32
23
|
defined?(::Excon) && defined?(::Excon::VERSION)
|
@@ -45,11 +36,7 @@ DependencyDetection.defer do
|
|
45
36
|
require 'new_relic/agent/distributed_tracing/cross_app_tracing'
|
46
37
|
require 'new_relic/agent/http_clients/excon_wrappers'
|
47
38
|
|
48
|
-
|
49
|
-
install_middleware_excon_instrumentation
|
50
|
-
else
|
51
|
-
install_legacy_excon_instrumentation
|
52
|
-
end
|
39
|
+
install_middleware_excon_instrumentation
|
53
40
|
end
|
54
41
|
|
55
42
|
def install_middleware_excon_instrumentation
|
@@ -63,11 +50,5 @@ DependencyDetection.defer do
|
|
63
50
|
::NewRelic::Agent.logger.warn("Did not find :middlewares key in Excon.defaults, skipping Excon instrumentation")
|
64
51
|
end
|
65
52
|
end
|
66
|
-
|
67
|
-
def install_legacy_excon_instrumentation
|
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'
|
70
|
-
require 'new_relic/agent/instrumentation/excon/connection'
|
71
|
-
::Excon::Connection.install_newrelic_instrumentation
|
72
|
-
end
|
73
53
|
end
|
54
|
+
|
@@ -11,19 +11,15 @@ DependencyDetection.defer do
|
|
11
11
|
|
12
12
|
depends_on do
|
13
13
|
require 'new_relic/agent/datastores/mongo'
|
14
|
-
|
15
|
-
NewRelic::Agent.logger.log_once(:
|
14
|
+
unless NewRelic::Agent::Datastores::Mongo.is_supported_version?
|
15
|
+
NewRelic::Agent.logger.log_once(:warn, :mongo2, 'Detected unsupported Mongo 2, upgrade your Mongo Driver to 2.1 or newer for instrumentation')
|
16
16
|
end
|
17
17
|
NewRelic::Agent::Datastores::Mongo.is_supported_version?
|
18
18
|
end
|
19
19
|
|
20
20
|
executes do
|
21
21
|
NewRelic::Agent.logger.info 'Installing Mongo instrumentation'
|
22
|
-
|
23
|
-
install_mongo_command_subscriber
|
24
|
-
else
|
25
|
-
install_mongo_instrumentation
|
26
|
-
end
|
22
|
+
install_mongo_command_subscriber
|
27
23
|
end
|
28
24
|
|
29
25
|
def install_mongo_command_subscriber
|
@@ -33,138 +29,4 @@ DependencyDetection.defer do
|
|
33
29
|
NewRelic::Agent::Instrumentation::MongodbCommandSubscriber.new
|
34
30
|
)
|
35
31
|
end
|
36
|
-
|
37
|
-
# TODO: Remove in 8.0.0 release
|
38
|
-
def install_mongo_instrumentation
|
39
|
-
::NewRelic::Agent::Deprecator.deprecate "install_mongo_instrumentation", "install_mongo_command_subscriber", "8.0.0"
|
40
|
-
::NewRelic::Agent.logger.warn("Installing deprecated Mongo instrumentation. " \
|
41
|
-
"This instrumentation will be removed in a future release. " \
|
42
|
-
"Update Mongo version to >= 2.1.0 for updated instrumentation"
|
43
|
-
)
|
44
|
-
|
45
|
-
require 'new_relic/agent/datastores/mongo/metric_translator'
|
46
|
-
require 'new_relic/agent/datastores/mongo/statement_formatter'
|
47
|
-
|
48
|
-
hook_instrument_methods
|
49
|
-
instrument_save
|
50
|
-
instrument_ensure_index
|
51
|
-
end
|
52
|
-
|
53
|
-
def hook_instrument_methods
|
54
|
-
hook_instrument_method(::Mongo::Collection)
|
55
|
-
hook_instrument_method(::Mongo::Connection)
|
56
|
-
hook_instrument_method(::Mongo::Cursor)
|
57
|
-
hook_instrument_method(::Mongo::CollectionWriter) if defined?(::Mongo::CollectionWriter)
|
58
|
-
end
|
59
|
-
|
60
|
-
def hook_instrument_method(target_class)
|
61
|
-
target_class.class_eval do
|
62
|
-
include NewRelic::Agent::MethodTracer
|
63
|
-
|
64
|
-
# It's key that this method eats all exceptions, as it rests between the
|
65
|
-
# Mongo operation the user called and us returning them the data. Be safe!
|
66
|
-
def new_relic_notice_statement(segment, payload, name)
|
67
|
-
statement = NewRelic::Agent::Datastores::Mongo::StatementFormatter.format(payload, name)
|
68
|
-
if statement
|
69
|
-
segment.notice_nosql_statement statement
|
70
|
-
end
|
71
|
-
rescue => e
|
72
|
-
NewRelic::Agent.logger.debug("Exception during Mongo statement gathering", e)
|
73
|
-
end
|
74
|
-
|
75
|
-
def new_relic_default_payload
|
76
|
-
{ :collection => self.name, :database => self.db.name }
|
77
|
-
end
|
78
|
-
|
79
|
-
def new_relic_start_segment name, payload
|
80
|
-
product = NewRelic::Agent::Datastores::Mongo::MetricTranslator::MONGO_PRODUCT_NAME
|
81
|
-
op_and_col = NewRelic::Agent::Datastores::Mongo::MetricTranslator.operation_and_collection_for name, payload
|
82
|
-
if op_and_col
|
83
|
-
operation, collection = op_and_col
|
84
|
-
NewRelic::Agent::Tracer.start_datastore_segment(
|
85
|
-
product: product,
|
86
|
-
operation: operation,
|
87
|
-
collection: collection
|
88
|
-
)
|
89
|
-
end
|
90
|
-
end
|
91
|
-
|
92
|
-
def instrument_with_new_relic_trace(name, payload = {}, &block)
|
93
|
-
segment = new_relic_start_segment name, payload
|
94
|
-
|
95
|
-
begin
|
96
|
-
result = NewRelic::Agent.disable_all_tracing do
|
97
|
-
NewRelic::Agent::Tracer.capture_segment_error segment do
|
98
|
-
instrument_without_new_relic_trace(name, payload, &block)
|
99
|
-
end
|
100
|
-
end
|
101
|
-
|
102
|
-
new_relic_notice_statement(segment, payload, name) if segment
|
103
|
-
result
|
104
|
-
ensure
|
105
|
-
segment.finish if segment
|
106
|
-
end
|
107
|
-
end
|
108
|
-
|
109
|
-
alias_method :instrument_without_new_relic_trace, :instrument
|
110
|
-
alias_method :instrument, :instrument_with_new_relic_trace
|
111
|
-
end
|
112
|
-
end
|
113
|
-
|
114
|
-
def instrument_save
|
115
|
-
::Mongo::Collection.class_eval do
|
116
|
-
def save_with_new_relic_trace(doc, opts = {}, &block)
|
117
|
-
segment = new_relic_start_segment :save, new_relic_default_payload
|
118
|
-
|
119
|
-
begin
|
120
|
-
result = NewRelic::Agent.disable_all_tracing do
|
121
|
-
NewRelic::Agent::Tracer.capture_segment_error segment do
|
122
|
-
save_without_new_relic_trace(doc, opts, &block)
|
123
|
-
end
|
124
|
-
end
|
125
|
-
|
126
|
-
new_relic_notice_statement(segment, doc, :save) if segment
|
127
|
-
result
|
128
|
-
ensure
|
129
|
-
segment.finish if segment
|
130
|
-
end
|
131
|
-
end
|
132
|
-
|
133
|
-
alias_method :save_without_new_relic_trace, :save
|
134
|
-
alias_method :save, :save_with_new_relic_trace
|
135
|
-
end
|
136
|
-
end
|
137
|
-
|
138
|
-
def instrument_ensure_index
|
139
|
-
::Mongo::Collection.class_eval do
|
140
|
-
def ensure_index_with_new_relic_trace(spec, opts = {}, &block)
|
141
|
-
segment = new_relic_start_segment :ensureIndex, new_relic_default_payload
|
142
|
-
|
143
|
-
begin
|
144
|
-
result = NewRelic::Agent.disable_all_tracing do
|
145
|
-
NewRelic::Agent::Tracer.capture_segment_error segment do
|
146
|
-
ensure_index_without_new_relic_trace(spec, opts, &block)
|
147
|
-
end
|
148
|
-
end
|
149
|
-
|
150
|
-
spec = case spec
|
151
|
-
when Array
|
152
|
-
Hash[spec]
|
153
|
-
when String, Symbol
|
154
|
-
{ spec => 1 }
|
155
|
-
else
|
156
|
-
spec.dup
|
157
|
-
end
|
158
|
-
|
159
|
-
new_relic_notice_statement(segment, spec, :ensureIndex) if segment
|
160
|
-
result
|
161
|
-
ensure
|
162
|
-
segment.finish if segment
|
163
|
-
end
|
164
|
-
end
|
165
|
-
|
166
|
-
alias_method :ensure_index_without_new_relic_trace, :ensure_index
|
167
|
-
alias_method :ensure_index, :ensure_index_with_new_relic_trace
|
168
|
-
end
|
169
|
-
end
|
170
32
|
end
|
@@ -15,7 +15,7 @@ module NewRelic
|
|
15
15
|
ALL_QUEUE_METRIC = 'WebFrontend/QueueTime'.freeze
|
16
16
|
# any timestamps before this are thrown out and the parser
|
17
17
|
# will try again with a larger unit (2000/1/1 UTC)
|
18
|
-
EARLIEST_ACCEPTABLE_TIME = Time.at(946684800)
|
18
|
+
EARLIEST_ACCEPTABLE_TIME = Time.at(946684800).to_f
|
19
19
|
|
20
20
|
CANDIDATE_HEADERS = [
|
21
21
|
REQUEST_START_HEADER,
|
@@ -27,7 +27,7 @@ module NewRelic
|
|
27
27
|
|
28
28
|
module_function
|
29
29
|
|
30
|
-
def parse_frontend_timestamp(headers, now=
|
30
|
+
def parse_frontend_timestamp(headers, now=Process.clock_gettime(Process::CLOCK_REALTIME))
|
31
31
|
earliest = nil
|
32
32
|
|
33
33
|
CANDIDATE_HEADERS.each do |header|
|
@@ -40,7 +40,7 @@ module NewRelic
|
|
40
40
|
end
|
41
41
|
|
42
42
|
if earliest && earliest > now
|
43
|
-
NewRelic::Agent.logger.debug("Negative queue time detected, treating as zero: start=#{earliest.to_f} > now=#{now
|
43
|
+
NewRelic::Agent.logger.debug("Negative queue time detected, treating as zero: start=#{earliest.to_f} > now=#{now}")
|
44
44
|
earliest = now
|
45
45
|
end
|
46
46
|
|
@@ -59,7 +59,7 @@ module NewRelic
|
|
59
59
|
def parse_timestamp(string)
|
60
60
|
DIVISORS.each do |divisor|
|
61
61
|
begin
|
62
|
-
t =
|
62
|
+
t = (string.to_f / divisor)
|
63
63
|
return t if t > EARLIEST_ACCEPTABLE_TIME
|
64
64
|
rescue RangeError
|
65
65
|
# On Ruby versions built with a 32-bit time_t, attempting to
|
@@ -20,13 +20,13 @@ DependencyDetection.defer do
|
|
20
20
|
executes do
|
21
21
|
ActionView::PartialTemplate.class_eval do
|
22
22
|
include NewRelic::Agent::MethodTracer
|
23
|
-
add_method_tracer :render,
|
23
|
+
add_method_tracer :render, -> (*) { "View/#{path_without_extension[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Partial" }
|
24
24
|
end
|
25
25
|
|
26
26
|
# this is for template rendering, as opposed to partial rendering.
|
27
27
|
ActionView::Template.class_eval do
|
28
28
|
include NewRelic::Agent::MethodTracer
|
29
|
-
add_method_tracer :render,
|
29
|
+
add_method_tracer :render, -> (*) { "View/#{(path_without_extension || @view.controller.newrelic_metric_path)[%r{^(/.*/)?(.*)$},2]}.#{@view.template_format}.#{extension}/Rendering" }
|
30
30
|
end
|
31
31
|
end
|
32
32
|
end
|
@@ -47,7 +47,7 @@ DependencyDetection.defer do
|
|
47
47
|
executes do
|
48
48
|
ActionController::Base.class_eval do
|
49
49
|
include NewRelic::Agent::MethodTracer
|
50
|
-
add_method_tracer :render,
|
50
|
+
add_method_tracer :render, -> (*) { "View/#{newrelic_metric_path}/Rendering" }
|
51
51
|
end
|
52
52
|
end
|
53
53
|
end
|
@@ -68,12 +68,12 @@ DependencyDetection.defer do
|
|
68
68
|
executes do
|
69
69
|
ActionView::RenderablePartial.module_eval do
|
70
70
|
include NewRelic::Agent::MethodTracer
|
71
|
-
add_method_tracer :render_partial,
|
71
|
+
add_method_tracer :render_partial, -> (*) { "View/#{path[%r{^(/.*/)?(.*)$},2]}/Partial" }
|
72
72
|
end
|
73
73
|
|
74
74
|
ActionView::Template.class_eval do
|
75
75
|
include NewRelic::Agent::MethodTracer
|
76
|
-
add_method_tracer :render,
|
76
|
+
add_method_tracer :render, -> (*) { "View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering" }
|
77
77
|
end
|
78
78
|
end
|
79
79
|
end
|
@@ -38,7 +38,7 @@ DependencyDetection.defer do
|
|
38
38
|
if defined?(ActionController) && defined?(ActionController::Base)
|
39
39
|
ActionController::Base.class_eval do
|
40
40
|
if method_defined? :perform_invocation
|
41
|
-
add_method_tracer :perform_invocation,
|
41
|
+
add_method_tracer :perform_invocation, -> (*args) { "WebService/#{controller_name}/#{args.first}" }
|
42
42
|
end
|
43
43
|
end
|
44
44
|
end
|
@@ -84,52 +84,16 @@ DependencyDetection.defer do
|
|
84
84
|
end
|
85
85
|
end
|
86
86
|
end
|
87
|
-
DependencyDetection.defer do
|
88
|
-
@name = :rails30_view
|
89
|
-
|
90
|
-
depends_on do
|
91
|
-
defined?(::Rails::VERSION::MAJOR) && defined?(::Rails::VERSION::MINOR) &&
|
92
|
-
::Rails::VERSION::MAJOR.to_i == 3 && ::Rails::VERSION::MINOR.to_i == 0
|
93
|
-
end
|
94
|
-
|
95
|
-
depends_on do
|
96
|
-
!NewRelic::Agent.config[:disable_view_instrumentation]
|
97
|
-
end
|
98
|
-
|
99
|
-
executes do
|
100
|
-
::NewRelic::Agent.logger.info 'Installing Rails 3.0 view instrumentation'
|
101
|
-
end
|
102
|
-
|
103
|
-
executes do
|
104
|
-
ActionView::Template.class_eval do
|
105
|
-
include NewRelic::Agent::MethodTracer
|
106
|
-
def render_with_newrelic(*args, &block)
|
107
|
-
options = if @virtual_path && @virtual_path.starts_with?('/') # file render
|
108
|
-
{:file => true }
|
109
|
-
else
|
110
|
-
{}
|
111
|
-
end
|
112
|
-
str = "View/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.template_metric(@identifier, options)}/#{NewRelic::Agent::Instrumentation::Rails3::ActionView::NewRelic.render_type(@identifier)}"
|
113
|
-
trace_execution_scoped str do
|
114
|
-
render_without_newrelic(*args, &block)
|
115
|
-
end
|
116
|
-
end
|
117
|
-
|
118
|
-
alias_method :render_without_newrelic, :render
|
119
|
-
alias_method :render, :render_with_newrelic
|
120
|
-
|
121
|
-
end
|
122
|
-
end
|
123
|
-
end
|
124
87
|
|
88
|
+
# Though this uses the name :rails31_view, it is used only for rails 3.2 now
|
89
|
+
# Rails 3.1 is no longer supported by the agent.
|
125
90
|
DependencyDetection.defer do
|
126
91
|
@name = :rails31_view
|
127
92
|
|
128
|
-
#
|
129
|
-
# Currently enabled for Rails 3.1 and 3.2
|
93
|
+
# Enabled for Rails 3.2
|
130
94
|
depends_on do
|
131
95
|
defined?(::Rails::VERSION::MAJOR) && defined?(::Rails::VERSION::MINOR) &&
|
132
|
-
::Rails::VERSION::MAJOR.to_i == 3 &&
|
96
|
+
::Rails::VERSION::MAJOR.to_i == 3 && ::Rails::VERSION::MINOR.to_i == 2
|
133
97
|
end
|
134
98
|
|
135
99
|
depends_on do
|
@@ -137,7 +101,7 @@ DependencyDetection.defer do
|
|
137
101
|
end
|
138
102
|
|
139
103
|
executes do
|
140
|
-
::NewRelic::Agent.logger.info 'Installing Rails 3.
|
104
|
+
::NewRelic::Agent.logger.info 'Installing Rails 3.2 view instrumentation'
|
141
105
|
end
|
142
106
|
|
143
107
|
executes do
|
@@ -60,7 +60,12 @@ DependencyDetection.defer do
|
|
60
60
|
|
61
61
|
class Sidekiq::Extensions::DelayedClass
|
62
62
|
def newrelic_trace_args(msg, queue)
|
63
|
-
(target, method_name, _args) = YAML.
|
63
|
+
(target, method_name, _args) = if YAML.respond_to?(:unsafe_load)
|
64
|
+
YAML.unsafe_load(msg['args'][0])
|
65
|
+
else
|
66
|
+
YAML.load(msg['args'][0])
|
67
|
+
end
|
68
|
+
|
64
69
|
{
|
65
70
|
:name => method_name,
|
66
71
|
:class_name => target.name,
|
@@ -136,9 +136,9 @@ module NewRelic
|
|
136
136
|
|
137
137
|
# NOTE: Internal prototyping may override this, so leave name stable!
|
138
138
|
def data_for_js_agent(transaction)
|
139
|
-
queue_time_in_seconds = [transaction.queue_time
|
140
|
-
start_time_in_seconds = [transaction.start_time
|
141
|
-
app_time_in_seconds =
|
139
|
+
queue_time_in_seconds = [transaction.queue_time, 0.0].max
|
140
|
+
start_time_in_seconds = [transaction.start_time, 0.0].max
|
141
|
+
app_time_in_seconds = Process.clock_gettime(Process::CLOCK_REALTIME) - start_time_in_seconds
|
142
142
|
|
143
143
|
queue_time_in_millis = (1000.0 * queue_time_in_seconds).round
|
144
144
|
app_time_in_millis = (1000.0 * app_time_in_seconds).round
|
@@ -110,20 +110,15 @@ module NewRelic
|
|
110
110
|
#
|
111
111
|
# @api public
|
112
112
|
#
|
113
|
-
def wrap_message_broker_consume_transaction
|
114
|
-
destination_type
|
115
|
-
destination_name
|
113
|
+
def wrap_message_broker_consume_transaction(library:,
|
114
|
+
destination_type:,
|
115
|
+
destination_name:,
|
116
116
|
headers: nil,
|
117
117
|
routing_key: nil,
|
118
118
|
queue_name: nil,
|
119
119
|
exchange_type: nil,
|
120
120
|
reply_to: nil,
|
121
|
-
correlation_id: nil
|
122
|
-
|
123
|
-
# ruby 2.0.0 does not support required kwargs
|
124
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
125
|
-
raise ArgumentError, 'missing required argument: destination_type' if destination_type.nil?
|
126
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
121
|
+
correlation_id: nil)
|
127
122
|
|
128
123
|
state = Tracer.state
|
129
124
|
return yield if state.current_transaction
|
@@ -185,17 +180,14 @@ module NewRelic
|
|
185
180
|
#
|
186
181
|
# @api public
|
187
182
|
#
|
188
|
-
def start_amqp_publish_segment(library
|
189
|
-
destination_name
|
183
|
+
def start_amqp_publish_segment(library:,
|
184
|
+
destination_name:,
|
190
185
|
headers: nil,
|
191
186
|
routing_key: nil,
|
192
187
|
reply_to: nil,
|
193
188
|
correlation_id: nil,
|
194
189
|
exchange_type: nil)
|
195
190
|
|
196
|
-
# ruby 2.0.0 does not support required kwargs
|
197
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
198
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
199
191
|
raise ArgumentError, 'missing required argument: headers' if headers.nil? && CrossAppTracing.cross_app_enabled?
|
200
192
|
|
201
193
|
original_headers = headers.nil? ? nil : headers.dup
|
@@ -247,20 +239,14 @@ module NewRelic
|
|
247
239
|
#
|
248
240
|
# @api public
|
249
241
|
#
|
250
|
-
def start_amqp_consume_segment(library
|
251
|
-
destination_name
|
252
|
-
delivery_info
|
253
|
-
message_properties
|
242
|
+
def start_amqp_consume_segment(library:,
|
243
|
+
destination_name:,
|
244
|
+
delivery_info:,
|
245
|
+
message_properties:,
|
254
246
|
exchange_type: nil,
|
255
247
|
queue_name: nil,
|
256
248
|
start_time: nil)
|
257
249
|
|
258
|
-
# ruby 2.0.0 does not support required kwargs
|
259
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
260
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
261
|
-
raise ArgumentError, 'missing required argument: delivery_info' if delivery_info.nil?
|
262
|
-
raise ArgumentError, 'missing required argument: message_properties' if message_properties.nil?
|
263
|
-
|
264
250
|
segment = Tracer.start_message_broker_segment(
|
265
251
|
action: :consume,
|
266
252
|
library: library,
|