newrelic_rpm 6.15.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 +260 -22
- data/CONTRIBUTING.md +13 -2
- data/README.md +4 -2
- data/lib/new_relic/agent/adaptive_sampler.rb +2 -2
- data/lib/new_relic/agent/agent.rb +8 -7
- data/lib/new_relic/agent/autostart.rb +1 -2
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -3
- data/lib/new_relic/agent/configuration/default_source.rb +456 -233
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +28 -12
- data/lib/new_relic/agent/configuration/manager.rb +3 -4
- 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/connect/request_builder.rb +4 -2
- 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/redis.rb +0 -4
- 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/distributed_tracing.rb +0 -66
- data/lib/new_relic/agent/error_collector.rb +52 -37
- data/lib/new_relic/agent/error_filter.rb +167 -0
- 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/active_record_notifications.rb +0 -16
- data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +1 -3
- 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/bunny.rb +10 -152
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -1
- 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/curb.rb +9 -241
- 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 +4 -22
- 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/grape.rb +13 -113
- 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/httpclient.rb +8 -30
- 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/httprb.rb +29 -0
- 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/memcache.rb +54 -69
- data/lib/new_relic/agent/instrumentation/middleware_proxy.rb +2 -0
- data/lib/new_relic/agent/instrumentation/mongo.rb +3 -134
- 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/net_http.rb +44 -0
- 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/padrino.rb +18 -53
- data/lib/new_relic/agent/instrumentation/queue_time.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +58 -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 +37 -0
- data/lib/new_relic/agent/instrumentation/rack.rb +29 -139
- 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/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/rake.rb +13 -154
- 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/redis.rb +12 -107
- data/lib/new_relic/agent/instrumentation/resque/chain.rb +22 -0
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +35 -0
- data/lib/new_relic/agent/instrumentation/resque/prepend.rb +16 -0
- data/lib/new_relic/agent/instrumentation/resque.rb +21 -32
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -1
- 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 +124 -0
- data/lib/new_relic/agent/instrumentation/sinatra/prepend.rb +33 -0
- data/lib/new_relic/agent/instrumentation/sinatra.rb +20 -158
- 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/instrumentation/typhoeus.rb +10 -89
- data/lib/new_relic/agent/javascript_instrumentor.rb +15 -10
- 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 +24 -22
- 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 +4 -4
- 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 +8 -32
- 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 +10 -13
- data/lib/new_relic/cli/commands/deployments.rb +2 -2
- data/lib/new_relic/constants.rb +0 -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 +5 -9
- data/lib/new_relic/supportability_helper.rb +1 -2
- data/lib/new_relic/version.rb +2 -2
- data/lib/newrelic_rpm.rb +10 -34
- data/lib/tasks/all.rb +1 -1
- data/lib/tasks/config.html.erb +14 -25
- data/lib/tasks/config.rake +8 -7
- data/newrelic.yml +593 -3
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +27 -2
- metadata +56 -14
- data/cert/cacert.pem +0 -1177
- 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/http.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/agent/instrumentation/net.rb +0 -70
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -46,7 +46,7 @@ module NewRelic
|
|
46
46
|
NewRelic::Agent::Database.should_record_sql?(:slow_sql)
|
47
47
|
end
|
48
48
|
|
49
|
-
def on_start_transaction(state,
|
49
|
+
def on_start_transaction(state, uri=nil)
|
50
50
|
return unless enabled?
|
51
51
|
|
52
52
|
state.sql_sampler_transaction_data = TransactionSqlData.new
|
@@ -65,7 +65,7 @@ module NewRelic
|
|
65
65
|
end
|
66
66
|
|
67
67
|
# This is called when we are done with the transaction.
|
68
|
-
def on_finishing_transaction(state, name
|
68
|
+
def on_finishing_transaction(state, name)
|
69
69
|
return unless enabled?
|
70
70
|
|
71
71
|
data = state.sql_sampler_transaction_data
|
@@ -359,10 +359,10 @@ module NewRelic
|
|
359
359
|
# need to hash the same way in every process, to be able to aggregate slow SQL traces
|
360
360
|
def consistent_hash(string)
|
361
361
|
if NewRelic::Agent.config[:'slow_sql.use_longer_sql_id']
|
362
|
-
Digest::
|
362
|
+
Digest::SHA1.hexdigest(string).hex.modulo(2**63-1)
|
363
363
|
else
|
364
364
|
# from when sql_id needed to fit in an INT(11)
|
365
|
-
Digest::
|
365
|
+
Digest::SHA1.hexdigest(string).hex.modulo(2**31-1)
|
366
366
|
end
|
367
367
|
end
|
368
368
|
end
|
@@ -33,7 +33,7 @@ module NewRelic
|
|
33
33
|
|
34
34
|
attr_accessor :started_at, :harvested_at
|
35
35
|
|
36
|
-
def initialize(started_at=
|
36
|
+
def initialize(started_at=Process.clock_gettime(Process::CLOCK_REALTIME))
|
37
37
|
@started_at = started_at.to_f
|
38
38
|
@scoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
|
39
39
|
@unscoped = Hash.new { |h, k| h[k] = NewRelic::Agent::Stats.new }
|
@@ -105,7 +105,7 @@ module NewRelic
|
|
105
105
|
@lock.synchronize do
|
106
106
|
if @profiles[transaction_name]
|
107
107
|
profile = @profiles.delete(transaction_name)
|
108
|
-
profile.finished_at =
|
108
|
+
profile.finished_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
109
109
|
@profiles[transaction_name] = ThreadProfile.new(profile.command_arguments)
|
110
110
|
profile
|
111
111
|
end
|
@@ -163,7 +163,7 @@ module NewRelic
|
|
163
163
|
end
|
164
164
|
|
165
165
|
def poll
|
166
|
-
poll_start =
|
166
|
+
poll_start = Process.clock_gettime(Process::CLOCK_REALTIME)
|
167
167
|
|
168
168
|
@lock.synchronize do
|
169
169
|
AgentThread.list.each do |thread|
|
@@ -173,7 +173,7 @@ module NewRelic
|
|
173
173
|
@buffer.delete_if { |thread, _| !thread.alive? }
|
174
174
|
end
|
175
175
|
|
176
|
-
end_time =
|
176
|
+
end_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
177
177
|
adjust_polling_time(end_time, poll_start)
|
178
178
|
record_supportability_metrics(end_time, poll_start)
|
179
179
|
end
|
@@ -230,7 +230,7 @@ module NewRelic
|
|
230
230
|
bucket = AgentThread.bucket_thread(thread, @profile_agent_code)
|
231
231
|
|
232
232
|
if need_backtrace?(bucket)
|
233
|
-
timestamp =
|
233
|
+
timestamp = Process.clock_gettime(Process::CLOCK_REALTIME)
|
234
234
|
backtrace = AgentThread.scrub_backtrace(thread, @profile_agent_code)
|
235
235
|
aggregate_global_backtrace(backtrace, bucket, thread)
|
236
236
|
buffer_backtrace_for_thread(thread, timestamp, backtrace, bucket)
|
@@ -277,7 +277,6 @@ module NewRelic
|
|
277
277
|
end
|
278
278
|
@last_poll = poll_start
|
279
279
|
end
|
280
|
-
|
281
280
|
end
|
282
281
|
end
|
283
282
|
end
|
@@ -131,14 +131,10 @@ module NewRelic
|
|
131
131
|
# @api public
|
132
132
|
def start_transaction_or_segment(name: nil,
|
133
133
|
partial_name: nil,
|
134
|
-
category
|
134
|
+
category:,
|
135
135
|
options: {})
|
136
|
-
|
137
|
-
|
138
|
-
end
|
139
|
-
if category.nil?
|
140
|
-
raise ArgumentError, 'missing required argument: category'
|
141
|
-
end
|
136
|
+
|
137
|
+
raise ArgumentError, 'missing required argument: name or partial_name' if name.nil? && partial_name.nil?
|
142
138
|
|
143
139
|
if name
|
144
140
|
options[:transaction_name] = name
|
@@ -163,16 +159,12 @@ module NewRelic
|
|
163
159
|
|
164
160
|
# Takes name or partial_name and a category.
|
165
161
|
# Returns a transaction instance or nil
|
166
|
-
def start_transaction(
|
162
|
+
def start_transaction(category:,
|
163
|
+
name: nil,
|
167
164
|
partial_name: nil,
|
168
|
-
category: nil,
|
169
165
|
**options)
|
170
|
-
|
171
|
-
|
172
|
-
end
|
173
|
-
if category.nil?
|
174
|
-
raise ArgumentError, 'missing required argument: category'
|
175
|
-
end
|
166
|
+
|
167
|
+
raise ArgumentError, 'missing required argument: name or partial_name' if name.nil? && partial_name.nil?
|
176
168
|
|
177
169
|
return current_transaction if current_transaction
|
178
170
|
|
@@ -238,14 +230,11 @@ module NewRelic
|
|
238
230
|
# +finish+ on it at the end of the code you're tracing
|
239
231
|
#
|
240
232
|
# @api public
|
241
|
-
def start_segment(name
|
233
|
+
def start_segment(name:,
|
242
234
|
unscoped_metrics:nil,
|
243
235
|
start_time: nil,
|
244
236
|
parent: nil)
|
245
237
|
|
246
|
-
# ruby 2.0.0 does not support required kwargs
|
247
|
-
raise ArgumentError, 'missing required argument: name' if name.nil?
|
248
|
-
|
249
238
|
segment = Transaction::Segment.new name, unscoped_metrics, start_time
|
250
239
|
start_and_add_segment segment, parent
|
251
240
|
|
@@ -341,17 +330,12 @@ module NewRelic
|
|
341
330
|
# you're tracing
|
342
331
|
#
|
343
332
|
# @api public
|
344
|
-
def start_external_request_segment(library
|
345
|
-
uri
|
346
|
-
procedure
|
333
|
+
def start_external_request_segment(library:,
|
334
|
+
uri:,
|
335
|
+
procedure:,
|
347
336
|
start_time: nil,
|
348
337
|
parent: nil)
|
349
338
|
|
350
|
-
# ruby 2.0.0 does not support required kwargs
|
351
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
352
|
-
raise ArgumentError, 'missing required argument: uri' if uri.nil?
|
353
|
-
raise ArgumentError, 'missing required argument: procedure' if procedure.nil?
|
354
|
-
|
355
339
|
segment = Transaction::ExternalRequestSegment.new library, uri, procedure, start_time
|
356
340
|
start_and_add_segment segment, parent
|
357
341
|
|
@@ -377,21 +361,15 @@ module NewRelic
|
|
377
361
|
end
|
378
362
|
|
379
363
|
# For New Relic internal use only.
|
380
|
-
def start_message_broker_segment(action
|
381
|
-
library
|
382
|
-
destination_type
|
383
|
-
destination_name
|
364
|
+
def start_message_broker_segment(action:,
|
365
|
+
library:,
|
366
|
+
destination_type:,
|
367
|
+
destination_name:,
|
384
368
|
headers: nil,
|
385
369
|
parameters: nil,
|
386
370
|
start_time: nil,
|
387
371
|
parent: nil)
|
388
372
|
|
389
|
-
# ruby 2.0.0 does not support required kwargs
|
390
|
-
raise ArgumentError, 'missing required argument: action' if action.nil?
|
391
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
392
|
-
raise ArgumentError, 'missing required argument: destination_type' if destination_type.nil?
|
393
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
394
|
-
|
395
373
|
segment = Transaction::MessageBrokerSegment.new(
|
396
374
|
action: action,
|
397
375
|
library: library,
|
@@ -48,14 +48,14 @@ module NewRelic
|
|
48
48
|
end
|
49
49
|
|
50
50
|
def start
|
51
|
-
@start_time ||=
|
51
|
+
@start_time ||= Process.clock_gettime(Process::CLOCK_REALTIME)
|
52
52
|
return unless transaction
|
53
53
|
parent.child_start self if parent
|
54
54
|
end
|
55
55
|
|
56
56
|
def finish
|
57
|
-
@end_time =
|
58
|
-
@duration = end_time
|
57
|
+
@end_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
58
|
+
@duration = end_time - start_time
|
59
59
|
return unless transaction
|
60
60
|
run_complete_callbacks
|
61
61
|
finalize if record_on_finish?
|
@@ -52,19 +52,13 @@ module NewRelic
|
|
52
52
|
:library,
|
53
53
|
:headers
|
54
54
|
|
55
|
-
def initialize
|
56
|
-
library
|
57
|
-
destination_type
|
58
|
-
destination_name
|
55
|
+
def initialize(action:,
|
56
|
+
library:,
|
57
|
+
destination_type:,
|
58
|
+
destination_name:,
|
59
59
|
headers: nil,
|
60
60
|
parameters: nil,
|
61
|
-
start_time: nil
|
62
|
-
|
63
|
-
# ruby 2.0.0 does not support required kwargs
|
64
|
-
raise ArgumentError, 'missing required argument: action' if action.nil?
|
65
|
-
raise ArgumentError, 'missing required argument: library' if library.nil?
|
66
|
-
raise ArgumentError, 'missing required argument: destination_type' if destination_type.nil?
|
67
|
-
raise ArgumentError, 'missing required argument: destination_name' if destination_name.nil?
|
61
|
+
start_time: nil)
|
68
62
|
|
69
63
|
@action = action
|
70
64
|
@library = library
|
@@ -119,28 +119,6 @@ module NewRelic
|
|
119
119
|
"#{namer.prefix_for_category(self, category)}#{partial_name}"
|
120
120
|
end
|
121
121
|
|
122
|
-
def self.wrap(state, name, category, options = {})
|
123
|
-
Deprecator.deprecate 'Transaction.wrap',
|
124
|
-
'Tracer#in_transaction'
|
125
|
-
|
126
|
-
finishable = Tracer.start_transaction_or_segment(
|
127
|
-
name: name,
|
128
|
-
category: category,
|
129
|
-
options: options
|
130
|
-
)
|
131
|
-
|
132
|
-
begin
|
133
|
-
# We shouldn't raise from Transaction.start, but only wrap the yield
|
134
|
-
# to be absolutely sure we don't report agent problems as app errors
|
135
|
-
yield
|
136
|
-
rescue => e
|
137
|
-
Transaction.notice_error(e)
|
138
|
-
raise e
|
139
|
-
ensure
|
140
|
-
finishable.finish if finishable
|
141
|
-
end
|
142
|
-
end
|
143
|
-
|
144
122
|
def self.start_new_transaction(state, category, options)
|
145
123
|
txn = Transaction.new(category, options)
|
146
124
|
state.reset(txn)
|
@@ -246,9 +224,10 @@ module NewRelic
|
|
246
224
|
@frozen_name = nil
|
247
225
|
|
248
226
|
@category = category
|
249
|
-
@start_time =
|
227
|
+
@start_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
250
228
|
@end_time = nil
|
251
229
|
@duration = nil
|
230
|
+
|
252
231
|
@apdex_start = options[:apdex_start_time] || @start_time
|
253
232
|
@jruby_cpu_start = jruby_cpu_time
|
254
233
|
@process_cpu_start = process_cpu
|
@@ -416,7 +395,7 @@ module NewRelic
|
|
416
395
|
def start
|
417
396
|
return if !state.is_execution_traced?
|
418
397
|
|
419
|
-
sql_sampler.on_start_transaction(state,
|
398
|
+
sql_sampler.on_start_transaction(state, request_path)
|
420
399
|
NewRelic::Agent.instance.events.notify(:start_transaction)
|
421
400
|
NewRelic::Agent::TransactionTimeAggregator.transaction_start(start_time)
|
422
401
|
|
@@ -464,7 +443,7 @@ module NewRelic
|
|
464
443
|
@ignore_apdex = options[:ignore_apdex] if options.key? :ignore_apdex
|
465
444
|
@ignore_enduser = options[:ignore_enduser] if options.key? :ignore_enduser
|
466
445
|
|
467
|
-
nest_initial_segment if
|
446
|
+
nest_initial_segment if segments.length == 1
|
468
447
|
nested_name = self.class.nested_transaction_name options[:transaction_name]
|
469
448
|
segment = create_segment nested_name
|
470
449
|
set_default_transaction_name(options[:transaction_name], category)
|
@@ -505,8 +484,8 @@ module NewRelic
|
|
505
484
|
|
506
485
|
def finish
|
507
486
|
return unless state.is_execution_traced?
|
508
|
-
@end_time =
|
509
|
-
@duration = @end_time
|
487
|
+
@end_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
488
|
+
@duration = @end_time - @start_time
|
510
489
|
freeze_name_and_execute_if_not_ignored
|
511
490
|
|
512
491
|
if nesting_max_depth == 1
|
@@ -571,9 +550,6 @@ module NewRelic
|
|
571
550
|
AttributeFilter::DST_ERROR_COLLECTOR
|
572
551
|
|
573
552
|
if http_response_code
|
574
|
-
add_agent_attribute(:httpResponseCode, http_response_code.to_s, default_destinations)
|
575
|
-
# Sending status code as an int with http.statusCode key is correct
|
576
|
-
# The above attribute is deprecated and should be removed in agent version 7.0.0
|
577
553
|
add_agent_attribute(:'http.statusCode', http_response_code, default_destinations)
|
578
554
|
end
|
579
555
|
|
@@ -626,7 +602,7 @@ module NewRelic
|
|
626
602
|
def calculate_transport_duration distributed_trace_payload
|
627
603
|
return unless distributed_trace_payload
|
628
604
|
|
629
|
-
duration =
|
605
|
+
duration = start_time - (distributed_trace_payload.timestamp / 1000.0)
|
630
606
|
duration < 0 ? 0 : duration
|
631
607
|
end
|
632
608
|
|
@@ -648,7 +624,7 @@ module NewRelic
|
|
648
624
|
@payload = {
|
649
625
|
:name => @frozen_name,
|
650
626
|
:bucket => recording_web_transaction? ? :request : :background,
|
651
|
-
:start_timestamp => start_time
|
627
|
+
:start_timestamp => start_time,
|
652
628
|
:duration => duration,
|
653
629
|
:metrics => @metrics,
|
654
630
|
:attributes => @attributes,
|
@@ -15,24 +15,24 @@ module NewRelic
|
|
15
15
|
TransactionStats = Struct.new :transaction_started_at, :elapsed_transaction_time
|
16
16
|
|
17
17
|
@lock = Mutex.new
|
18
|
-
@harvest_cycle_started_at =
|
18
|
+
@harvest_cycle_started_at = Process.clock_gettime(Process::CLOCK_REALTIME)
|
19
19
|
|
20
20
|
@stats = Hash.new do |h, k|
|
21
21
|
h[k] = TransactionStats.new nil, 0.0
|
22
22
|
end
|
23
23
|
|
24
|
-
def reset!(timestamp =
|
24
|
+
def reset!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
|
25
25
|
@harvest_cycle_started_at = timestamp
|
26
26
|
@stats.clear
|
27
27
|
end
|
28
28
|
|
29
|
-
def transaction_start(timestamp =
|
29
|
+
def transaction_start(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
|
30
30
|
@lock.synchronize do
|
31
31
|
set_transaction_start_time timestamp
|
32
32
|
end
|
33
33
|
end
|
34
34
|
|
35
|
-
def transaction_stop(timestamp =
|
35
|
+
def transaction_stop(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), starting_thread_id = current_thread)
|
36
36
|
@lock.synchronize do
|
37
37
|
record_elapsed_transaction_time_until timestamp, starting_thread_id
|
38
38
|
set_transaction_start_time nil, starting_thread_id
|
@@ -41,7 +41,7 @@ module NewRelic
|
|
41
41
|
|
42
42
|
INSTANCE_BUSY_METRIC = 'Instance/Busy'.freeze
|
43
43
|
|
44
|
-
def harvest!(timestamp =
|
44
|
+
def harvest!(timestamp = Process.clock_gettime(Process::CLOCK_REALTIME))
|
45
45
|
active_threads = 0
|
46
46
|
result = @lock.synchronize do
|
47
47
|
# Sum up the transaction times spent in each thread
|
@@ -18,7 +18,7 @@ module NewRelic
|
|
18
18
|
# or :limit (integer) for max number of iterations
|
19
19
|
def initialize(opts={})
|
20
20
|
@should_run = true
|
21
|
-
@next_invocation_time =
|
21
|
+
@next_invocation_time = Process.clock_gettime(Process::CLOCK_REALTIME)
|
22
22
|
@period = 60.0
|
23
23
|
@duration = opts[:duration]
|
24
24
|
@limit = opts[:limit]
|
@@ -34,7 +34,7 @@ module NewRelic
|
|
34
34
|
@should_run = true
|
35
35
|
@iterations = 0
|
36
36
|
|
37
|
-
now =
|
37
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
38
38
|
@deadline = now + @duration if @duration
|
39
39
|
@next_invocation_time = (now + @period)
|
40
40
|
end
|
@@ -53,11 +53,11 @@ module NewRelic
|
|
53
53
|
end
|
54
54
|
|
55
55
|
def schedule_next_invocation
|
56
|
-
now =
|
56
|
+
now = Process.clock_gettime(Process::CLOCK_REALTIME)
|
57
57
|
while @next_invocation_time <= now && @period > 0
|
58
58
|
@next_invocation_time += @period
|
59
59
|
end
|
60
|
-
@next_invocation_time -
|
60
|
+
@next_invocation_time - Process.clock_gettime(Process::CLOCK_REALTIME)
|
61
61
|
end
|
62
62
|
|
63
63
|
# a simple accessor for @should_run
|
@@ -66,7 +66,7 @@ module NewRelic
|
|
66
66
|
end
|
67
67
|
|
68
68
|
def under_duration?
|
69
|
-
!@deadline ||
|
69
|
+
!@deadline || Process.clock_gettime(Process::CLOCK_REALTIME) < @deadline
|
70
70
|
end
|
71
71
|
|
72
72
|
def under_limit?
|
data/lib/new_relic/agent.rb
CHANGED
@@ -44,6 +44,7 @@ module NewRelic
|
|
44
44
|
require 'new_relic/agent/sql_sampler'
|
45
45
|
require 'new_relic/agent/commands/thread_profiler_session'
|
46
46
|
require 'new_relic/agent/error_collector'
|
47
|
+
require 'new_relic/agent/error_filter'
|
47
48
|
require 'new_relic/agent/sampler'
|
48
49
|
require 'new_relic/agent/database'
|
49
50
|
require 'new_relic/agent/database_adapter'
|
@@ -138,20 +139,20 @@ module NewRelic
|
|
138
139
|
# is initialized; these methods enable us to defer these calls
|
139
140
|
# until we have started up and can process them.
|
140
141
|
#
|
141
|
-
def add_or_defer_method_tracer(receiver, method_name,
|
142
|
+
def add_or_defer_method_tracer(receiver, method_name, metric_name, options)
|
142
143
|
@tracer_lock.synchronize do
|
143
144
|
if @agent
|
144
|
-
receiver.send(:
|
145
|
+
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
145
146
|
else
|
146
|
-
@tracer_queue << [receiver, method_name,
|
147
|
+
@tracer_queue << [receiver, method_name, metric_name, options]
|
147
148
|
end
|
148
149
|
end
|
149
150
|
end
|
150
151
|
|
151
152
|
def add_deferred_method_tracers_now
|
152
153
|
@tracer_lock.synchronize do
|
153
|
-
@tracer_queue.each do |receiver, method_name,
|
154
|
-
receiver.send(:
|
154
|
+
@tracer_queue.each do |receiver, method_name, metric_name, options|
|
155
|
+
receiver.send(:_nr_add_method_tracer_now, method_name, metric_name, options)
|
155
156
|
end
|
156
157
|
|
157
158
|
@tracer_queue = []
|
@@ -283,12 +284,6 @@ module NewRelic
|
|
283
284
|
def notice_error(exception, options={})
|
284
285
|
record_api_supportability_metric(:notice_error)
|
285
286
|
|
286
|
-
if options.has_key?(:trace_only)
|
287
|
-
NewRelic::Agent.logger.log_once(:warn, :trace_only_deprecated,
|
288
|
-
'Passing the :trace_only option to NewRelic::Agent.notice_error is deprecated. Please use :expected instead.')
|
289
|
-
options[:expected] = options.delete(:trace_only)
|
290
|
-
end
|
291
|
-
|
292
287
|
Transaction.notice_error(exception, options)
|
293
288
|
nil # don't return a noticed error datastructure. it can only hurt.
|
294
289
|
end
|
@@ -764,13 +759,15 @@ module NewRelic
|
|
764
759
|
# In previous agents there was a corresponding footer required, but all the
|
765
760
|
# work is now done by this single method.
|
766
761
|
#
|
762
|
+
# @param [String] nonce The nonce to use in the javascript tag for browser instrumentation
|
763
|
+
#
|
767
764
|
# @api public
|
768
765
|
#
|
769
|
-
def browser_timing_header
|
766
|
+
def browser_timing_header(nonce=nil)
|
770
767
|
record_api_supportability_metric(:browser_timing_header)
|
771
768
|
|
772
769
|
return "" unless agent
|
773
|
-
agent.javascript_instrumentor.browser_timing_header
|
770
|
+
agent.javascript_instrumentor.browser_timing_header(nonce)
|
774
771
|
end
|
775
772
|
|
776
773
|
# @!endgroup
|
@@ -10,7 +10,7 @@ require 'net/http'
|
|
10
10
|
require 'new_relic/agent/hostname'
|
11
11
|
|
12
12
|
# We need to use the Control object but we don't want to load
|
13
|
-
# the rails
|
13
|
+
# the rails environment. The defined? clause is so that
|
14
14
|
# it won't load it twice, something it does when run inside a test
|
15
15
|
require 'new_relic/control' unless defined? NewRelic::Control
|
16
16
|
|
@@ -117,7 +117,7 @@ class NewRelic::Cli::Deployments < NewRelic::Cli::Command
|
|
117
117
|
"Set the application name.",
|
118
118
|
"Default is app_name setting in newrelic.yml") { | e | @appname = e }
|
119
119
|
o.on("-e", "--environment=name", String,
|
120
|
-
"Override the (RAILS|
|
120
|
+
"Override the (RAILS|RUBY|RACK)_ENV setting",
|
121
121
|
"currently: #{control.env}") { | e | @environment = e }
|
122
122
|
o.on("-u", "--user=USER", String,
|
123
123
|
"Specify the user deploying, for information only",
|
data/lib/new_relic/constants.rb
CHANGED
@@ -28,10 +28,6 @@ module NewRelic
|
|
28
28
|
TRACEPARENT_KEY = "traceparent"
|
29
29
|
TRACESTATE_KEY = "tracestate"
|
30
30
|
|
31
|
-
# Right now, old and new Rubies are the same. Intention is to use "(...)" for
|
32
|
-
# Ruby 2.7+ for argument delegation, but doing so is a breaking API change.
|
33
|
-
ARGS_FOR_RUBY_VERSION = RUBY_VERSION < "2.7.0" ? "*args, &block" : "*args, &block"
|
34
|
-
|
35
31
|
HTTP_TRACEPARENT_KEY = "HTTP_#{TRACEPARENT_KEY.upcase}"
|
36
32
|
HTTP_TRACESTATE_KEY = "HTTP_#{TRACESTATE_KEY.upcase}"
|
37
33
|
HTTP_NEWRELIC_KEY = "HTTP_#{NEWRELIC_KEY.upcase}"
|
@@ -82,15 +82,17 @@ module NewRelic
|
|
82
82
|
end
|
83
83
|
|
84
84
|
def install_browser_monitoring(config)
|
85
|
-
|
86
|
-
|
87
|
-
|
88
|
-
|
89
|
-
|
90
|
-
|
91
|
-
|
92
|
-
|
93
|
-
|
85
|
+
@install_lock.synchronize do
|
86
|
+
return if defined?(@browser_monitoring_installed) && @browser_monitoring_installed
|
87
|
+
@browser_monitoring_installed = true
|
88
|
+
return if config.nil? || !config.respond_to?(:middleware) || !Agent.config[:'browser_monitoring.auto_instrument']
|
89
|
+
begin
|
90
|
+
require 'new_relic/rack/browser_monitoring'
|
91
|
+
config.middleware.use NewRelic::Rack::BrowserMonitoring
|
92
|
+
::NewRelic::Agent.logger.debug("Installed New Relic Browser Monitoring middleware")
|
93
|
+
rescue => e
|
94
|
+
::NewRelic::Agent.logger.warn("Error installing New Relic Browser Monitoring middleware", e)
|
95
|
+
end
|
94
96
|
end
|
95
97
|
end
|
96
98
|
|