newrelic_rpm 6.1.0.352 → 6.6.0.358

Sign up to get free protection for your applications and to get access to all the features.
Files changed (62) hide show
  1. checksums.yaml +4 -4
  2. data/.gitignore +1 -0
  3. data/.travis.yml +34 -96
  4. data/CHANGELOG.md +139 -0
  5. data/lib/new_relic/agent/agent.rb +51 -134
  6. data/lib/new_relic/agent/commands/agent_command_router.rb +2 -21
  7. data/lib/new_relic/agent/configuration/default_source.rb +53 -41
  8. data/lib/new_relic/agent/configuration/environment_source.rb +4 -2
  9. data/lib/new_relic/agent/configuration/event_harvest_config.rb +39 -0
  10. data/lib/new_relic/agent/configuration/high_security_source.rb +1 -0
  11. data/lib/new_relic/agent/configuration/manager.rb +13 -1
  12. data/lib/new_relic/agent/configuration/server_source.rb +34 -1
  13. data/lib/new_relic/agent/connect/request_builder.rb +69 -0
  14. data/lib/new_relic/agent/connect/response_handler.rb +61 -0
  15. data/lib/new_relic/agent/error_collector.rb +2 -2
  16. data/lib/new_relic/agent/error_event_aggregator.rb +2 -1
  17. data/lib/new_relic/agent/error_trace_aggregator.rb +1 -0
  18. data/lib/new_relic/agent/event_aggregator.rb +26 -32
  19. data/lib/new_relic/agent/hostname.rb +1 -1
  20. data/lib/new_relic/agent/inbound_request_monitor.rb +2 -2
  21. data/lib/new_relic/agent/instrumentation/action_cable_subscriber.rb +24 -42
  22. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +46 -74
  23. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +70 -53
  24. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +168 -0
  25. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +41 -48
  26. data/lib/new_relic/agent/instrumentation/active_storage_subscriber.rb +4 -4
  27. data/lib/new_relic/agent/instrumentation/grape.rb +2 -3
  28. data/lib/new_relic/agent/instrumentation/notifications_subscriber.rb +76 -0
  29. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_cable.rb +5 -6
  30. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_controller.rb +3 -3
  31. data/lib/new_relic/agent/instrumentation/{rails4 → rails_notifications}/action_view.rb +3 -3
  32. data/lib/new_relic/agent/javascript_instrumentor.rb +1 -1
  33. data/lib/new_relic/agent/new_relic_service.rb +0 -4
  34. data/lib/new_relic/agent/new_relic_service/json_marshaller.rb +0 -1
  35. data/lib/new_relic/agent/parameter_filtering.rb +18 -5
  36. data/lib/new_relic/agent/priority_sampled_buffer.rb +2 -0
  37. data/lib/new_relic/agent/span_event_aggregator.rb +2 -5
  38. data/lib/new_relic/agent/threading/backtrace_service.rb +3 -3
  39. data/lib/new_relic/agent/threading/thread_profile.rb +9 -23
  40. data/lib/new_relic/agent/transaction.rb +0 -2
  41. data/lib/new_relic/agent/transaction/trace.rb +3 -8
  42. data/lib/new_relic/agent/transaction/trace_builder.rb +0 -1
  43. data/lib/new_relic/agent/transaction_event_recorder.rb +3 -3
  44. data/lib/new_relic/agent/transaction_sampler.rb +1 -5
  45. data/lib/new_relic/agent/transaction_time_aggregator.rb +19 -4
  46. data/lib/new_relic/control/class_methods.rb +7 -1
  47. data/lib/new_relic/control/frameworks/{rails5.rb → rails_notifications.rb} +1 -1
  48. data/lib/new_relic/rack/browser_monitoring.rb +10 -8
  49. data/lib/new_relic/version.rb +1 -1
  50. data/lib/tasks/config.rake +1 -2
  51. data/newrelic_rpm.gemspec +2 -9
  52. data/test/agent_helper.rb +18 -5
  53. metadata +18 -51
  54. data/lib/new_relic/agent/commands/xray_session.rb +0 -55
  55. data/lib/new_relic/agent/commands/xray_session_collection.rb +0 -161
  56. data/lib/new_relic/agent/instrumentation/active_record_4.rb +0 -42
  57. data/lib/new_relic/agent/instrumentation/active_record_5.rb +0 -41
  58. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +0 -104
  59. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -32
  60. data/lib/new_relic/agent/instrumentation/rails5/action_view.rb +0 -27
  61. data/lib/new_relic/agent/transaction/xray_sample_buffer.rb +0 -64
  62. data/lib/new_relic/control/frameworks/rails6.rb +0 -14
@@ -1,42 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- require 'new_relic/agent/instrumentation/active_record_prepend'
6
- require 'new_relic/agent/instrumentation/active_record_subscriber'
7
- require 'new_relic/agent/prepend_supportability'
8
-
9
- DependencyDetection.defer do
10
- named :active_record_4
11
-
12
- depends_on do
13
- defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
14
- defined?(::ActiveRecord::VERSION) &&
15
- ::ActiveRecord::VERSION::MAJOR.to_i == 4
16
- end
17
-
18
- depends_on do
19
- !NewRelic::Agent.config[:disable_activerecord_instrumentation] &&
20
- !NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.subscribed?
21
- end
22
-
23
- executes do
24
- ::NewRelic::Agent.logger.info 'Installing ActiveRecord 4 instrumentation'
25
- end
26
-
27
- executes do
28
- ActiveSupport::Notifications.subscribe('sql.active_record',
29
- NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.new)
30
-
31
- ActiveSupport.on_load(:active_record) do
32
- ::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActiveRecord::Base, ::ActiveRecord::Relation)
33
-
34
- if NewRelic::Agent.config[:prepend_active_record_instrumentation]
35
- ::ActiveRecord::Base.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions
36
- ::ActiveRecord::Relation.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions
37
- else
38
- ::NewRelic::Agent::Instrumentation::ActiveRecordHelper.instrument_additional_methods
39
- end
40
- end
41
- end
42
- end
@@ -1,41 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- require 'new_relic/agent/instrumentation/active_record_subscriber'
6
- require 'new_relic/agent/instrumentation/active_record_prepend'
7
-
8
- DependencyDetection.defer do
9
- named :active_record_5
10
-
11
- depends_on do
12
- defined?(::ActiveRecord) && defined?(::ActiveRecord::Base) &&
13
- defined?(::ActiveRecord::VERSION) &&
14
- ::ActiveRecord::VERSION::MAJOR.to_i == 5
15
- end
16
-
17
- depends_on do
18
- !NewRelic::Agent.config[:disable_activerecord_instrumentation] &&
19
- !NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.subscribed?
20
- end
21
-
22
- executes do
23
- ::NewRelic::Agent.logger.info 'Installing ActiveRecord 5 instrumentation'
24
- end
25
-
26
- executes do
27
- ActiveSupport::Notifications.subscribe('sql.active_record',
28
- NewRelic::Agent::Instrumentation::ActiveRecordSubscriber.new)
29
-
30
- ActiveSupport.on_load(:active_record) do
31
- ::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActiveRecord::Base, ::ActiveRecord::Relation)
32
- ::ActiveRecord::Base.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions
33
- ::ActiveRecord::Relation.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::RelationExtensions
34
-
35
- if ::ActiveRecord::VERSION::MINOR.to_i == 1 &&
36
- ::ActiveRecord::VERSION::TINY.to_i >= 6
37
- ::ActiveRecord::Base.prepend ::NewRelic::Agent::Instrumentation::ActiveRecordPrepend::BaseExtensions516
38
- end
39
- end
40
- end
41
- end
@@ -1,104 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- module NewRelic
6
- module Agent
7
- module Instrumentation
8
- class EventedSubscriber
9
- def initialize
10
- @queue_key = ['NewRelic', self.class.name, object_id].join('-')
11
- end
12
-
13
- def self.subscribed?
14
- # TODO: need to talk to Rails core about an API for this,
15
- # rather than digging through Listener ivars
16
- ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers) \
17
- .find{|s| s.instance_variable_get(:@delegate).class == self }
18
- end
19
-
20
- def self.subscribe(pattern)
21
- if !subscribed?
22
- ActiveSupport::Notifications.subscribe(pattern, new)
23
- end
24
- end
25
-
26
- def start(name, id, payload)
27
- event = ActiveSupport::Notifications::Event.new(name, Time.now, nil, id, payload)
28
- push_event(event)
29
- return event
30
- end
31
-
32
- def finish(name, id, payload)
33
- pop_event(id)
34
- end
35
-
36
- def log_notification_error(error, name, event_type)
37
- # These are important enough failures that we want the backtraces
38
- # logged at error level, hence the explicit log_exception call.
39
- NewRelic::Agent.logger.error("Error during #{event_type} callback for event '#{name}':")
40
- NewRelic::Agent.logger.log_exception(:error, error)
41
- end
42
-
43
- def push_event(event)
44
- parent = event_stack[event.transaction_id].last
45
- if parent && event.respond_to?(:parent=)
46
- event.parent = parent
47
- parent << event
48
- end
49
- event_stack[event.transaction_id].push event
50
- end
51
-
52
- def pop_event(transaction_id)
53
- event = event_stack[transaction_id].pop
54
- event.end = Time.now
55
- return event
56
- end
57
-
58
- def event_stack
59
- Thread.current[@queue_key] ||= Hash.new {|h,id| h[id] = [] }
60
- end
61
-
62
- def state
63
- NewRelic::Agent::Tracer.state
64
- end
65
- end
66
-
67
- # Taken from ActiveSupport::Notifications::Event, pasted here
68
- # with a couple minor additions so we don't have a hard
69
- # dependency on ActiveSupport::Notifications.
70
- #
71
- # Represents an instrumentation event, provides timing and metric
72
- # name information useful when recording metrics.
73
- class Event
74
- attr_reader :name, :time, :transaction_id, :payload, :children
75
- attr_accessor :end, :parent, :frame
76
-
77
- def initialize(name, start, ending, transaction_id, payload)
78
- @name = name
79
- @payload = payload.dup
80
- @time = start
81
- @transaction_id = transaction_id
82
- @end = ending
83
- @children = []
84
- end
85
-
86
- def metric_name
87
- raise NotImplementedError
88
- end
89
-
90
- def duration
91
- self.end - time
92
- end
93
-
94
- def <<(event)
95
- @children << event
96
- end
97
-
98
- def parent_of?(event)
99
- @children.include? event
100
- end
101
- end
102
- end
103
- end
104
- end
@@ -1,32 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
- require 'new_relic/agent/instrumentation/action_controller_subscriber'
5
- require 'new_relic/agent/prepend_supportability'
6
-
7
-
8
- DependencyDetection.defer do
9
- @name = :rails4_controller
10
-
11
- depends_on do
12
- defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i == 4
13
- end
14
-
15
- depends_on do
16
- defined?(ActionController) && defined?(ActionController::Base)
17
- end
18
-
19
- executes do
20
- ::NewRelic::Agent.logger.info 'Installing Rails 4 Controller instrumentation'
21
- end
22
-
23
- executes do
24
- class ActionController::Base
25
- include NewRelic::Agent::Instrumentation::ControllerInstrumentation
26
- end
27
- NewRelic::Agent::Instrumentation::ActionControllerSubscriber \
28
- .subscribe(/^process_action.action_controller$/)
29
-
30
- ::NewRelic::Agent::PrependSupportability.record_metrics_for(::ActionController::Base)
31
- end
32
- end
@@ -1,27 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
- require 'new_relic/agent/instrumentation/action_view_subscriber'
5
- require 'new_relic/agent/prepend_supportability'
6
-
7
- DependencyDetection.defer do
8
- @name = :rails5_view
9
-
10
- depends_on do
11
- defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i == 5
12
- end
13
-
14
- depends_on do
15
- !NewRelic::Agent.config[:disable_view_instrumentation] &&
16
- !NewRelic::Agent::Instrumentation::ActionViewSubscriber.subscribed?
17
- end
18
-
19
- executes do
20
- NewRelic::Agent.logger.info 'Installing Rails 5 view instrumentation'
21
- end
22
-
23
- executes do
24
- NewRelic::Agent::Instrumentation::ActionViewSubscriber.subscribe(/render_.+\.action_view$/)
25
- NewRelic::Agent::PrependSupportability.record_metrics_for(::ActionView::Base, ::ActionView::Template, ::ActionView::Renderer)
26
- end
27
- end
@@ -1,64 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- require 'new_relic/agent/transaction/transaction_sample_buffer'
6
-
7
- module NewRelic
8
- module Agent
9
- class Transaction
10
- class XraySampleBuffer < TransactionSampleBuffer
11
-
12
- attr_writer :xray_session_collection
13
-
14
- def initialize
15
- super
16
-
17
- # Memoize the config setting since this happens per request
18
- @enabled = NewRelic::Agent.config[:'xray_session.allow_traces']
19
- NewRelic::Agent.config.register_callback(:'xray_session.allow_traces') do |new_value|
20
- @enabled = new_value
21
- end
22
-
23
- @capacity = NewRelic::Agent.config[:'xray_session.max_samples']
24
- NewRelic::Agent.config.register_callback(:'xray_session.max_samples') do |new_value|
25
- @capacity = new_value
26
- end
27
- end
28
-
29
- def xray_session_collection
30
- @xray_session_collection ||= NewRelic::Agent.instance.agent_command_router.xray_session_collection
31
- end
32
-
33
- def capacity
34
- @capacity
35
- end
36
-
37
- def truncate_samples
38
- # First in wins, so stop on allow_sample? instead of truncating
39
- end
40
-
41
- def allow_sample?(sample)
42
- !full? && !lookup_session_id(sample).nil?
43
- end
44
-
45
- def enabled?
46
- @enabled
47
- end
48
-
49
-
50
- private
51
-
52
- def add_sample(sample)
53
- super(sample)
54
- sample.xray_session_id = lookup_session_id(sample)
55
- end
56
-
57
- def lookup_session_id(sample)
58
- xray_session_collection.session_id_for_transaction_name(sample.transaction_name)
59
- end
60
-
61
- end
62
- end
63
- end
64
- end
@@ -1,14 +0,0 @@
1
- # encoding: utf-8
2
- # This file is distributed under New Relic's license terms.
3
- # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- require 'new_relic/control/frameworks/rails4'
6
-
7
- module NewRelic
8
- class Control
9
- module Frameworks
10
- class Rails6 < NewRelic::Control::Frameworks::Rails4
11
- end
12
- end
13
- end
14
- end