newrelic_rpm 6.2.0.354 → 6.3.0.355

Sign up to get free protection for your applications and to get access to all the features.
Files changed (28) hide show
  1. checksums.yaml +4 -4
  2. data/.travis.yml +17 -0
  3. data/CHANGELOG.md +35 -6
  4. data/lib/new_relic/agent/agent.rb +38 -130
  5. data/lib/new_relic/agent/configuration/default_source.rb +49 -10
  6. data/lib/new_relic/agent/configuration/event_data.rb +39 -0
  7. data/lib/new_relic/agent/configuration/server_source.rb +11 -1
  8. data/lib/new_relic/agent/connect/request_builder.rb +63 -0
  9. data/lib/new_relic/agent/connect/response_handler.rb +61 -0
  10. data/lib/new_relic/agent/hostname.rb +1 -1
  11. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +3 -7
  12. data/lib/new_relic/agent/instrumentation/active_record_notifications.rb +161 -0
  13. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +7 -0
  14. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +34 -3
  15. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_cable.rb +3 -3
  16. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_controller.rb +3 -3
  17. data/lib/new_relic/agent/instrumentation/{rails5 → rails_notifications}/action_view.rb +3 -3
  18. data/lib/new_relic/agent/parameter_filtering.rb +18 -5
  19. data/lib/new_relic/control/class_methods.rb +7 -1
  20. data/lib/new_relic/control/frameworks/{rails5.rb → rails_notifications.rb} +1 -1
  21. data/lib/new_relic/version.rb +1 -1
  22. data/test/agent_helper.rb +11 -5
  23. metadata +10 -11
  24. data/lib/new_relic/agent/instrumentation/active_record_4.rb +0 -42
  25. data/lib/new_relic/agent/instrumentation/active_record_5.rb +0 -41
  26. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +0 -32
  27. data/lib/new_relic/agent/instrumentation/rails4/action_view.rb +0 -27
  28. data/lib/new_relic/control/frameworks/rails6.rb +0 -14
@@ -5,11 +5,11 @@ require 'new_relic/agent/instrumentation/action_cable_subscriber'
5
5
  require 'new_relic/agent/prepend_supportability'
6
6
 
7
7
  DependencyDetection.defer do
8
- @name = :rails5_action_cable
8
+ @name = :action_cable_notifications
9
9
 
10
10
  depends_on do
11
11
  defined?(::Rails::VERSION::MAJOR) &&
12
- ::Rails::VERSION::MAJOR.to_i == 5 &&
12
+ ::Rails::VERSION::MAJOR.to_i >= 5 &&
13
13
  defined?(::ActionCable)
14
14
  end
15
15
 
@@ -19,7 +19,7 @@ DependencyDetection.defer do
19
19
  end
20
20
 
21
21
  executes do
22
- ::NewRelic::Agent.logger.info 'Installing Rails 5 Action Cable instrumentation'
22
+ ::NewRelic::Agent.logger.info 'Installing notifications based Action Cable instrumentation'
23
23
  end
24
24
 
25
25
  executes do
@@ -6,10 +6,10 @@ require 'new_relic/agent/prepend_supportability'
6
6
 
7
7
 
8
8
  DependencyDetection.defer do
9
- @name = :rails5_controller
9
+ @name = :action_controller_notifications
10
10
 
11
11
  depends_on do
12
- defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i == 5
12
+ defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i >= 4
13
13
  end
14
14
 
15
15
  depends_on do
@@ -17,7 +17,7 @@ DependencyDetection.defer do
17
17
  end
18
18
 
19
19
  executes do
20
- ::NewRelic::Agent.logger.info 'Installing Rails 5 Controller instrumentation'
20
+ ::NewRelic::Agent.logger.info 'Installing notifications based Action Controller instrumentation'
21
21
  end
22
22
 
23
23
  executes do
@@ -5,10 +5,10 @@ require 'new_relic/agent/instrumentation/action_view_subscriber'
5
5
  require 'new_relic/agent/prepend_supportability'
6
6
 
7
7
  DependencyDetection.defer do
8
- @name = :rails5_view
8
+ @name = :action_view_notifications
9
9
 
10
10
  depends_on do
11
- defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i == 5
11
+ defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i >= 4
12
12
  end
13
13
 
14
14
  depends_on do
@@ -17,7 +17,7 @@ DependencyDetection.defer do
17
17
  end
18
18
 
19
19
  executes do
20
- NewRelic::Agent.logger.info 'Installing Rails 5 view instrumentation'
20
+ NewRelic::Agent.logger.info 'Installing notification based Action View instrumentation'
21
21
  end
22
22
 
23
23
  executes do
@@ -7,16 +7,29 @@ module NewRelic
7
7
  module ParameterFiltering
8
8
  extend self
9
9
 
10
+ ACTION_DISPATCH_PARAMETER_FILTER = "action_dispatch.parameter_filter".freeze
11
+
12
+ RAILS_FILTER_CLASS = if defined?(ActiveSupport::ParameterFilter)
13
+ ActiveSupport::ParameterFilter
14
+ elsif defined?(ActionDispatch::Http::ParameterFilter)
15
+ ActionDispatch::Http::ParameterFilter
16
+ else
17
+ nil
18
+ end
19
+
10
20
  def apply_filters(env, params)
11
- params = filter_using_rails(env, params)
21
+ if filters = env[ACTION_DISPATCH_PARAMETER_FILTER]
22
+ params = filter_using_rails(params, filters)
23
+ end
12
24
  params = filter_rack_file_data(env, params)
13
25
  params
14
26
  end
15
27
 
16
- def filter_using_rails(env, params)
17
- return params unless defined?(ActionDispatch::Http::ParameterFilter) && env.key?("action_dispatch.parameter_filter")
18
- filters = env["action_dispatch.parameter_filter"]
19
- ActionDispatch::Http::ParameterFilter.new(filters).filter(params)
28
+ def filter_using_rails(params, filters)
29
+ return params if RAILS_FILTER_CLASS.nil?
30
+
31
+ pre_filtered_params = filter_rails_request_parameters(params)
32
+ RAILS_FILTER_CLASS.new(filters).filter(pre_filtered_params)
20
33
  end
21
34
 
22
35
  def filter_rack_file_data(env, params)
@@ -49,13 +49,19 @@ module NewRelic
49
49
  # maybe it is already loaded by some external system
50
50
  # i.e. rpm_contrib or user extensions?
51
51
  end
52
- NewRelic::Control::Frameworks.const_get(framework.to_s.capitalize)
52
+ NewRelic::Control::Frameworks.const_get(camelize(framework.to_s))
53
53
  end
54
54
 
55
55
  # The root directory for the plugin or gem
56
56
  def newrelic_root
57
57
  File.expand_path(File.join("..", "..", "..", ".."), __FILE__)
58
58
  end
59
+
60
+ def camelize(snake_case_name)
61
+ snake_case_name.gsub(/(\_|^)[a-z]/) do |substring|
62
+ substring[-1].capitalize!
63
+ end
64
+ end
59
65
  end
60
66
  extend ClassMethods
61
67
  end
@@ -7,7 +7,7 @@ require 'new_relic/control/frameworks/rails4'
7
7
  module NewRelic
8
8
  class Control
9
9
  module Frameworks
10
- class Rails5 < NewRelic::Control::Frameworks::Rails4
10
+ class RailsNotifications < NewRelic::Control::Frameworks::Rails4
11
11
  end
12
12
  end
13
13
  end
@@ -11,7 +11,7 @@ module NewRelic
11
11
  end
12
12
 
13
13
  MAJOR = 6
14
- MINOR = 2
14
+ MINOR = 3
15
15
  TINY = 0
16
16
 
17
17
  begin
@@ -521,7 +521,7 @@ def constant_path(name, opts={})
521
521
  path = [Object]
522
522
  parts = name.gsub(/^::/, '').split('::')
523
523
  parts.each do |part|
524
- if !path.last.const_defined?(part)
524
+ if !path.last.constants.include?(part.to_sym)
525
525
  return allow_partial ? path : nil
526
526
  end
527
527
  path << path.last.const_get(part)
@@ -529,11 +529,17 @@ def constant_path(name, opts={})
529
529
  path
530
530
  end
531
531
 
532
+ def get_parent(constant_name)
533
+ parent_name = constant_name.gsub(/::[^:]*$/, '')
534
+ const_path = constant_path(parent_name)
535
+ const_path ? const_path[-1] : nil
536
+ end
537
+
532
538
  def undefine_constant(constant_symbol)
533
- const_path = constant_path(constant_symbol.to_s)
534
- return yield unless const_path
535
- parent = const_path[-2]
536
- const_name = constant_symbol.to_s.gsub(/.*::/, '')
539
+ const_str = constant_symbol.to_s
540
+ parent = get_parent(const_str)
541
+ const_name = const_str.gsub(/.*::/, '')
542
+ return yield unless parent && parent.constants.include?(const_name.to_sym)
537
543
  removed_constant = parent.send(:remove_const, const_name)
538
544
  yield
539
545
  ensure
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 6.2.0.354
4
+ version: 6.3.0.355
5
5
  platform: ruby
6
6
  authors:
7
7
  - Matthew Wear
@@ -11,7 +11,7 @@ authors:
11
11
  autorequire:
12
12
  bindir: bin
13
13
  cert_chain: []
14
- date: 2019-03-12 00:00:00.000000000 Z
14
+ date: 2019-04-25 00:00:00.000000000 Z
15
15
  dependencies:
16
16
  - !ruby/object:Gem::Dependency
17
17
  name: rake
@@ -184,6 +184,7 @@ files:
184
184
  - lib/new_relic/agent/configuration/default_source.rb
185
185
  - lib/new_relic/agent/configuration/dotted_hash.rb
186
186
  - lib/new_relic/agent/configuration/environment_source.rb
187
+ - lib/new_relic/agent/configuration/event_data.rb
187
188
  - lib/new_relic/agent/configuration/high_security_source.rb
188
189
  - lib/new_relic/agent/configuration/manager.rb
189
190
  - lib/new_relic/agent/configuration/manual_source.rb
@@ -191,6 +192,8 @@ files:
191
192
  - lib/new_relic/agent/configuration/security_policy_source.rb
192
193
  - lib/new_relic/agent/configuration/server_source.rb
193
194
  - lib/new_relic/agent/configuration/yaml_source.rb
195
+ - lib/new_relic/agent/connect/request_builder.rb
196
+ - lib/new_relic/agent/connect/response_handler.rb
194
197
  - lib/new_relic/agent/cross_app_monitor.rb
195
198
  - lib/new_relic/agent/cross_app_payload.rb
196
199
  - lib/new_relic/agent/cross_app_tracing.rb
@@ -240,9 +243,8 @@ files:
240
243
  - lib/new_relic/agent/instrumentation/active_job.rb
241
244
  - lib/new_relic/agent/instrumentation/active_merchant.rb
242
245
  - lib/new_relic/agent/instrumentation/active_record.rb
243
- - lib/new_relic/agent/instrumentation/active_record_4.rb
244
- - lib/new_relic/agent/instrumentation/active_record_5.rb
245
246
  - lib/new_relic/agent/instrumentation/active_record_helper.rb
247
+ - lib/new_relic/agent/instrumentation/active_record_notifications.rb
246
248
  - lib/new_relic/agent/instrumentation/active_record_prepend.rb
247
249
  - lib/new_relic/agent/instrumentation/active_record_subscriber.rb
248
250
  - lib/new_relic/agent/instrumentation/active_storage.rb
@@ -278,12 +280,10 @@ files:
278
280
  - lib/new_relic/agent/instrumentation/rails/action_controller.rb
279
281
  - lib/new_relic/agent/instrumentation/rails/action_web_service.rb
280
282
  - lib/new_relic/agent/instrumentation/rails3/action_controller.rb
281
- - lib/new_relic/agent/instrumentation/rails4/action_controller.rb
282
- - lib/new_relic/agent/instrumentation/rails4/action_view.rb
283
- - lib/new_relic/agent/instrumentation/rails5/action_cable.rb
284
- - lib/new_relic/agent/instrumentation/rails5/action_controller.rb
285
- - lib/new_relic/agent/instrumentation/rails5/action_view.rb
286
283
  - lib/new_relic/agent/instrumentation/rails_middleware.rb
284
+ - lib/new_relic/agent/instrumentation/rails_notifications/action_cable.rb
285
+ - lib/new_relic/agent/instrumentation/rails_notifications/action_controller.rb
286
+ - lib/new_relic/agent/instrumentation/rails_notifications/action_view.rb
287
287
  - lib/new_relic/agent/instrumentation/rainbows_instrumentation.rb
288
288
  - lib/new_relic/agent/instrumentation/rake.rb
289
289
  - lib/new_relic/agent/instrumentation/redis.rb
@@ -394,8 +394,7 @@ files:
394
394
  - lib/new_relic/control/frameworks/rails.rb
395
395
  - lib/new_relic/control/frameworks/rails3.rb
396
396
  - lib/new_relic/control/frameworks/rails4.rb
397
- - lib/new_relic/control/frameworks/rails5.rb
398
- - lib/new_relic/control/frameworks/rails6.rb
397
+ - lib/new_relic/control/frameworks/rails_notifications.rb
399
398
  - lib/new_relic/control/frameworks/ruby.rb
400
399
  - lib/new_relic/control/frameworks/sinatra.rb
401
400
  - lib/new_relic/control/instance_methods.rb
@@ -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,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 = :rails4_view
9
-
10
- depends_on do
11
- defined?(::Rails::VERSION::MAJOR) && ::Rails::VERSION::MAJOR.to_i == 4
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 4 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,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