newrelic_rpm 7.0.0 → 8.2.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 +226 -0
- data/CONTRIBUTING.md +13 -2
- data/README.md +5 -1
- data/lib/new_relic/agent/adaptive_sampler.rb +2 -2
- data/lib/new_relic/agent/agent.rb +8 -7
- data/lib/new_relic/agent/commands/thread_profiler_session.rb +7 -3
- data/lib/new_relic/agent/configuration/default_source.rb +229 -158
- data/lib/new_relic/agent/configuration/event_harvest_config.rb +28 -12
- data/lib/new_relic/agent/configuration/manager.rb +1 -2
- 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.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 +6 -6
- data/lib/new_relic/agent/error_collector.rb +52 -37
- data/lib/new_relic/agent/error_filter.rb +175 -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/http_clients/net_http_wrappers.rb +7 -1
- 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_subscriber.rb +1 -3
- data/lib/new_relic/agent/instrumentation/bunny/instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +2 -1
- data/lib/new_relic/agent/instrumentation/delayed_job/instrumentation.rb +4 -4
- data/lib/new_relic/agent/instrumentation/excon.rb +4 -23
- data/lib/new_relic/agent/instrumentation/logger/chain.rb +21 -0
- data/lib/new_relic/agent/instrumentation/logger/instrumentation.rb +59 -0
- data/lib/new_relic/agent/instrumentation/logger/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/logger.rb +25 -0
- data/lib/new_relic/agent/instrumentation/memcache/dalli.rb +5 -1
- data/lib/new_relic/agent/instrumentation/memcache/helper.rb +5 -0
- data/lib/new_relic/agent/instrumentation/memcache/prepend.rb +8 -2
- data/lib/new_relic/agent/instrumentation/mongo.rb +3 -141
- data/lib/new_relic/agent/instrumentation/net_http.rb +6 -1
- data/lib/new_relic/agent/instrumentation/padrino/chain.rb +23 -19
- data/lib/new_relic/agent/instrumentation/padrino/prepend.rb +1 -1
- data/lib/new_relic/agent/instrumentation/padrino.rb +4 -2
- data/lib/new_relic/agent/instrumentation/queue_time.rb +4 -4
- data/lib/new_relic/agent/instrumentation/rack/chain.rb +3 -2
- data/lib/new_relic/agent/instrumentation/rack/prepend.rb +2 -1
- data/lib/new_relic/agent/instrumentation/rails3/action_controller.rb +5 -41
- data/lib/new_relic/agent/instrumentation/redis.rb +4 -0
- data/lib/new_relic/agent/instrumentation/resque/helper.rb +19 -0
- data/lib/new_relic/agent/instrumentation/resque/instrumentation.rb +5 -3
- data/lib/new_relic/agent/instrumentation/resque.rb +13 -4
- data/lib/new_relic/agent/instrumentation/sidekiq.rb +6 -1
- data/lib/new_relic/agent/instrumentation/sinatra/instrumentation.rb +8 -2
- data/lib/new_relic/agent/instrumentation/tilt/chain.rb +24 -0
- data/lib/new_relic/agent/instrumentation/tilt/instrumentation.rb +41 -0
- data/lib/new_relic/agent/instrumentation/tilt/prepend.rb +13 -0
- data/lib/new_relic/agent/instrumentation/tilt.rb +25 -0
- data/lib/new_relic/agent/javascript_instrumentor.rb +15 -10
- data/lib/new_relic/agent/logging.rb +5 -6
- data/lib/new_relic/agent/messaging.rb +10 -24
- data/lib/new_relic/agent/method_tracer.rb +137 -138
- data/lib/new_relic/agent/monitors/cross_app_monitor.rb +8 -1
- data/lib/new_relic/agent/new_relic_service.rb +16 -12
- 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/samplers/delayed_job_sampler.rb +9 -6
- data/lib/new_relic/agent/span_event_aggregator.rb +2 -2
- data/lib/new_relic/agent/sql_sampler.rb +3 -3
- 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/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/datastore_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/distributed_tracer.rb +1 -0
- data/lib/new_relic/agent/transaction/external_request_segment.rb +3 -0
- data/lib/new_relic/agent/transaction/message_broker_segment.rb +5 -11
- data/lib/new_relic/agent/transaction/segment.rb +3 -0
- 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 +10 -7
- 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 +4 -4
- 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 +580 -3
- data/newrelic_rpm.gemspec +1 -1
- data/test/agent_helper.rb +27 -2
- metadata +13 -11
- 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/agent/instrumentation/rails/action_controller.rb +0 -125
- data/lib/new_relic/agent/instrumentation/rails/action_web_service.rb +0 -46
- data/lib/new_relic/agent/supported_versions.rb +0 -275
- data/lib/new_relic/control/frameworks/merb.rb +0 -29
@@ -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?
|
@@ -138,6 +138,9 @@ module NewRelic
|
|
138
138
|
end
|
139
139
|
|
140
140
|
def record_span_event
|
141
|
+
# don't record a span event if the transaction is ignored
|
142
|
+
return if transaction.ignore?
|
143
|
+
|
141
144
|
aggregator = ::NewRelic::Agent.agent.span_event_aggregator
|
142
145
|
priority = transaction.priority
|
143
146
|
|
@@ -250,6 +250,9 @@ module NewRelic
|
|
250
250
|
end
|
251
251
|
|
252
252
|
def record_span_event
|
253
|
+
# don't record a span event if the transaction is ignored
|
254
|
+
return if transaction.ignore?
|
255
|
+
|
253
256
|
aggregator = ::NewRelic::Agent.agent.span_event_aggregator
|
254
257
|
priority = transaction.priority
|
255
258
|
aggregator.record(priority: priority) do
|
@@ -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
|
|
@@ -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
|
@@ -623,7 +602,7 @@ module NewRelic
|
|
623
602
|
def calculate_transport_duration distributed_trace_payload
|
624
603
|
return unless distributed_trace_payload
|
625
604
|
|
626
|
-
duration =
|
605
|
+
duration = start_time - (distributed_trace_payload.timestamp / 1000.0)
|
627
606
|
duration < 0 ? 0 : duration
|
628
607
|
end
|
629
608
|
|
@@ -645,7 +624,7 @@ module NewRelic
|
|
645
624
|
@payload = {
|
646
625
|
:name => @frozen_name,
|
647
626
|
:bucket => recording_web_transaction? ? :request : :background,
|
648
|
-
:start_timestamp => start_time
|
627
|
+
:start_timestamp => start_time,
|
649
628
|
:duration => duration,
|
650
629
|
:metrics => @metrics,
|
651
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 = []
|
@@ -758,13 +759,15 @@ module NewRelic
|
|
758
759
|
# In previous agents there was a corresponding footer required, but all the
|
759
760
|
# work is now done by this single method.
|
760
761
|
#
|
762
|
+
# @param [String] nonce The nonce to use in the javascript tag for browser instrumentation
|
763
|
+
#
|
761
764
|
# @api public
|
762
765
|
#
|
763
|
-
def browser_timing_header
|
766
|
+
def browser_timing_header(nonce=nil)
|
764
767
|
record_api_supportability_metric(:browser_timing_header)
|
765
768
|
|
766
769
|
return "" unless agent
|
767
|
-
agent.javascript_instrumentor.browser_timing_header
|
770
|
+
agent.javascript_instrumentor.browser_timing_header(nonce)
|
768
771
|
end
|
769
772
|
|
770
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}"
|
@@ -33,7 +33,7 @@ class NewRelic::NoticedError
|
|
33
33
|
ERROR_CLASS_KEY = "#{ERROR_PREFIX_KEY}.class"
|
34
34
|
ERROR_EXPECTED_KEY = "#{ERROR_PREFIX_KEY}.expected"
|
35
35
|
|
36
|
-
def initialize(path, exception, timestamp =
|
36
|
+
def initialize(path, exception, timestamp = Process.clock_gettime(Process::CLOCK_REALTIME), expected = false)
|
37
37
|
@exception_id = exception.object_id
|
38
38
|
@path = path
|
39
39
|
|
@@ -58,7 +58,7 @@ class NewRelic::NoticedError
|
|
58
58
|
@attributes_from_notice_error = nil
|
59
59
|
@attributes = nil
|
60
60
|
@timestamp = timestamp
|
61
|
-
@expected =
|
61
|
+
@expected = expected
|
62
62
|
end
|
63
63
|
|
64
64
|
def ==(other)
|
@@ -104,7 +104,7 @@ class NewRelic::NoticedError
|
|
104
104
|
params[:file_name] = file_name if file_name
|
105
105
|
params[:line_number] = line_number if line_number
|
106
106
|
params[:stack_trace] = stack_trace if stack_trace
|
107
|
-
params[
|
107
|
+
params[ERROR_EXPECTED_KEY.to_sym] = expected
|
108
108
|
params
|
109
109
|
end
|
110
110
|
|
@@ -139,7 +139,7 @@ class NewRelic::NoticedError
|
|
139
139
|
ERROR_MESSAGE_KEY => string(message),
|
140
140
|
ERROR_CLASS_KEY => string(exception_class_name)
|
141
141
|
})
|
142
|
-
|
142
|
+
|
143
143
|
@attributes_from_notice_error[ERROR_EXPECTED_KEY] = true if expected
|
144
144
|
end
|
145
145
|
|
data/lib/new_relic/version.rb
CHANGED
data/lib/newrelic_rpm.rb
CHANGED
@@ -6,48 +6,24 @@
|
|
6
6
|
#
|
7
7
|
# When installed as a gem, you can activate the New Relic agent one of the following ways:
|
8
8
|
#
|
9
|
-
# For
|
10
|
-
#
|
11
|
-
# to your initialization sequence.
|
9
|
+
# For applications using Bundler, add this to the Gemfile:
|
10
|
+
# gem 'newrelic_rpm'
|
12
11
|
#
|
13
|
-
#
|
14
|
-
# dependency 'newrelic_rpm'
|
15
|
-
# in the Merb config/init.rb
|
12
|
+
# You will also need to install the newrelic.yml configuration file
|
16
13
|
#
|
17
|
-
# For
|
18
|
-
#
|
19
|
-
# after requiring 'sinatra'.
|
20
|
-
#
|
21
|
-
# For other frameworks, or to manage the agent manually, invoke NewRelic::Agent#manual_start
|
22
|
-
# directly.
|
14
|
+
# For applications not using Bundler, and for other installation information, visit:
|
15
|
+
# https://docs.newrelic.com/docs/agents/ruby-agent/installation/install-new-relic-ruby-agent/
|
23
16
|
#
|
24
17
|
|
25
18
|
require 'new_relic/control'
|
26
|
-
if defined?(Merb) && defined?(Merb::BootLoader)
|
27
|
-
module NewRelic
|
28
|
-
class MerbBootLoader < Merb::BootLoader
|
29
|
-
after Merb::BootLoader::ChooseAdapter
|
30
|
-
def self.run
|
31
|
-
NewRelic::Control.instance.init_plugin
|
32
|
-
end
|
33
|
-
end
|
34
|
-
end
|
35
|
-
elsif defined?(Rails::VERSION)
|
36
|
-
if Rails::VERSION::MAJOR.to_i >= 3
|
37
|
-
module NewRelic
|
38
|
-
class Railtie < Rails::Railtie
|
39
19
|
|
40
|
-
|
41
|
-
|
42
|
-
|
20
|
+
if defined?(Rails::VERSION)
|
21
|
+
module NewRelic
|
22
|
+
class Railtie < Rails::Railtie
|
23
|
+
initializer "newrelic_rpm.start_plugin", before: :load_config_initializers do |app|
|
24
|
+
NewRelic::Control.instance.init_plugin(config: app.config)
|
43
25
|
end
|
44
26
|
end
|
45
|
-
else
|
46
|
-
# After version 2.0 of Rails we can access the configuration directly.
|
47
|
-
# We need it to add dev mode routes after initialization finished.
|
48
|
-
config = nil
|
49
|
-
config = Rails.configuration if Rails.respond_to?(:configuration)
|
50
|
-
NewRelic::Control.instance.init_plugin :config => config
|
51
27
|
end
|
52
28
|
else
|
53
29
|
NewRelic::Control.instance.init_plugin
|
data/lib/tasks/all.rb
CHANGED
@@ -2,7 +2,7 @@
|
|
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
|
-
# This is required to load in task definitions
|
5
|
+
# This is required to load in task definitions
|
6
6
|
Dir.glob(File.join(File.dirname(__FILE__),'*.rake')) do |file|
|
7
7
|
load file
|
8
8
|
end
|