newrelic_rpm 3.6.0.83 → 3.6.1.85.beta

Sign up to get free protection for your applications and to get access to all the features.
Files changed (118) hide show
  1. data/CHANGELOG +27 -0
  2. data/Gemfile +2 -7
  3. data/README.md +1 -1
  4. data/lib/new_relic/agent/agent.rb +3 -2
  5. data/lib/new_relic/agent/autostart.rb +56 -0
  6. data/lib/new_relic/agent/browser_monitoring.rb +19 -14
  7. data/lib/new_relic/agent/configuration/defaults.rb +12 -2
  8. data/lib/new_relic/agent/configuration/environment_source.rb +4 -1
  9. data/lib/new_relic/agent/cross_app_monitor.rb +2 -1
  10. data/lib/new_relic/agent/cross_app_tracing.rb +19 -10
  11. data/lib/new_relic/agent/error_collector.rb +5 -4
  12. data/lib/new_relic/agent/instrumentation/action_controller_subscriber.rb +204 -0
  13. data/lib/new_relic/agent/instrumentation/action_view_subscriber.rb +88 -0
  14. data/lib/new_relic/agent/instrumentation/active_record.rb +1 -1
  15. data/lib/new_relic/agent/instrumentation/active_record_helper.rb +1 -1
  16. data/lib/new_relic/agent/instrumentation/active_record_subscriber.rb +84 -0
  17. data/lib/new_relic/agent/instrumentation/browser_monitoring_timings.rb +3 -2
  18. data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +104 -87
  19. data/lib/new_relic/agent/instrumentation/evented_subscriber.rb +91 -0
  20. data/lib/new_relic/agent/instrumentation/memcache.rb +4 -4
  21. data/lib/new_relic/agent/instrumentation/merb/errors.rb +4 -4
  22. data/lib/new_relic/agent/instrumentation/rack.rb +1 -1
  23. data/lib/new_relic/agent/instrumentation/rails/action_controller.rb +20 -20
  24. data/lib/new_relic/agent/instrumentation/rails/errors.rb +5 -5
  25. data/lib/new_relic/agent/instrumentation/rails3/errors.rb +3 -3
  26. data/lib/new_relic/agent/instrumentation/rails4/action_controller.rb +3 -25
  27. data/lib/new_relic/agent/instrumentation/rails4/action_view.rb +2 -115
  28. data/lib/new_relic/agent/instrumentation/rails4/active_record.rb +2 -82
  29. data/lib/new_relic/agent/instrumentation/rails4/errors.rb +3 -4
  30. data/lib/new_relic/agent/method_tracer.rb +93 -56
  31. data/lib/new_relic/agent/null_logger.rb +6 -0
  32. data/lib/new_relic/agent/samplers/cpu_sampler.rb +9 -4
  33. data/lib/new_relic/agent/sql_sampler.rb +10 -6
  34. data/lib/new_relic/agent/stats_engine/metric_stats.rb +19 -3
  35. data/lib/new_relic/agent/stats_engine/transactions.rb +53 -34
  36. data/lib/new_relic/agent/system_info.rb +54 -0
  37. data/lib/new_relic/agent/thread.rb +2 -2
  38. data/lib/new_relic/agent/transaction/pop.rb +52 -0
  39. data/lib/new_relic/agent/transaction.rb +388 -0
  40. data/lib/new_relic/agent/transaction_info.rb +5 -13
  41. data/lib/new_relic/agent/transaction_sample_builder.rb +13 -20
  42. data/lib/new_relic/agent/transaction_sampler.rb +13 -15
  43. data/lib/new_relic/agent/uri_util.rb +35 -0
  44. data/lib/new_relic/agent.rb +54 -11
  45. data/lib/new_relic/build.rb +2 -2
  46. data/lib/new_relic/control/frameworks/rails.rb +0 -1
  47. data/lib/new_relic/control/frameworks/rails3.rb +2 -0
  48. data/lib/new_relic/control/frameworks/rails4.rb +0 -4
  49. data/lib/new_relic/control/instance_methods.rb +5 -19
  50. data/lib/new_relic/control/server_methods.rb +2 -0
  51. data/lib/new_relic/environment_report.rb +4 -34
  52. data/lib/new_relic/latest_changes.rb +1 -1
  53. data/lib/new_relic/local_environment.rb +0 -6
  54. data/lib/new_relic/metric_spec.rb +2 -2
  55. data/lib/new_relic/rack/error_collector.rb +6 -4
  56. data/lib/new_relic/transaction_sample.rb +7 -1
  57. data/lib/new_relic/version.rb +1 -1
  58. data/lib/newrelic_rpm.rb +2 -2
  59. data/newrelic.yml +20 -20
  60. data/test/config/test_control.rb +2 -2
  61. data/test/multiverse/suites/agent_only/audit_log_test.rb +1 -1
  62. data/test/multiverse/suites/agent_only/cross_application_tracing_test.rb +0 -2
  63. data/test/multiverse/suites/agent_only/logging_test.rb +1 -1
  64. data/test/multiverse/suites/agent_only/marshaling_test.rb +5 -3
  65. data/test/multiverse/suites/agent_only/rename_rule_test.rb +2 -0
  66. data/test/multiverse/suites/agent_only/set_transaction_name_test.rb +96 -0
  67. data/test/multiverse/suites/agent_only/testing_app.rb +1 -0
  68. data/test/multiverse/suites/rails/error_tracing_test.rb +17 -29
  69. data/test/multiverse/suites/rails/queue_time_test.rb +8 -2
  70. data/test/multiverse/suites/rails/view_instrumentation_test.rb +6 -3
  71. data/test/multiverse/suites/resque/instrumentation_test.rb +1 -1
  72. data/test/multiverse/suites/sinatra/sinatra_error_tracing_test.rb +8 -0
  73. data/test/new_relic/agent/agent/connect_test.rb +2 -1
  74. data/test/new_relic/agent/agent/start_test.rb +0 -10
  75. data/test/new_relic/agent/agent_logger_test.rb +15 -0
  76. data/test/new_relic/agent/agent_test_controller.rb +6 -2
  77. data/test/new_relic/agent/agent_test_controller_test.rb +20 -69
  78. data/test/new_relic/agent/autostart_test.rb +67 -0
  79. data/test/new_relic/agent/browser_monitoring_test.rb +60 -38
  80. data/test/new_relic/agent/configuration/environment_source_test.rb +19 -17
  81. data/test/new_relic/agent/cross_app_monitor_test.rb +8 -0
  82. data/test/new_relic/agent/error_collector/notice_error_test.rb +0 -5
  83. data/test/new_relic/agent/error_collector_test.rb +8 -9
  84. data/test/new_relic/agent/instrumentation/action_controller_subscriber_test.rb +228 -0
  85. data/test/new_relic/agent/instrumentation/action_view_subscriber_test.rb +18 -34
  86. data/test/new_relic/agent/instrumentation/active_record_instrumentation_test.rb +5 -5
  87. data/test/new_relic/agent/instrumentation/active_record_subscriber_test.rb +8 -9
  88. data/test/new_relic/agent/instrumentation/browser_monitoring_timings_test.rb +1 -1
  89. data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +24 -38
  90. data/test/new_relic/agent/instrumentation/net_instrumentation_test.rb +126 -178
  91. data/test/new_relic/agent/instrumentation/rack_test.rb +1 -1
  92. data/test/new_relic/agent/instrumentation/task_instrumentation_test.rb +135 -151
  93. data/test/new_relic/agent/method_tracer/instance_methods/trace_execution_scoped_test.rb +153 -81
  94. data/test/new_relic/agent/method_tracer_test.rb +42 -33
  95. data/test/new_relic/agent/mock_scope_listener.rb +4 -4
  96. data/test/new_relic/agent/pipe_channel_manager_test.rb +4 -2
  97. data/test/new_relic/agent/rpm_agent_test.rb +86 -89
  98. data/test/new_relic/agent/sql_sampler_test.rb +18 -19
  99. data/test/new_relic/agent/stats_engine/gc_profiler_test.rb +5 -8
  100. data/test/new_relic/agent/stats_engine/metric_stats_test.rb +20 -8
  101. data/test/new_relic/agent/stats_engine/samplers_test.rb +31 -14
  102. data/test/new_relic/agent/stats_engine_test.rb +53 -60
  103. data/test/new_relic/agent/thread_test.rb +7 -7
  104. data/test/new_relic/agent/transaction/pop_test.rb +96 -0
  105. data/test/new_relic/agent/transaction_info_test.rb +6 -17
  106. data/test/new_relic/agent/transaction_sample_builder_test.rb +10 -18
  107. data/test/new_relic/agent/transaction_sampler_test.rb +80 -75
  108. data/test/new_relic/agent/{instrumentation/metric_frame_test.rb → transaction_test.rb} +76 -42
  109. data/test/new_relic/agent/uri_util_test.rb +75 -0
  110. data/test/new_relic/agent_test.rb +115 -9
  111. data/test/test_helper.rb +138 -9
  112. data.tar.gz.sig +0 -0
  113. metadata +37 -74
  114. metadata.gz.sig +0 -0
  115. data/lib/new_relic/agent/instrumentation/metric_frame/pop.rb +0 -84
  116. data/lib/new_relic/agent/instrumentation/metric_frame.rb +0 -353
  117. data/test/new_relic/agent/instrumentation/metric_frame/pop_test.rb +0 -175
  118. data/test/test_contexts.rb +0 -34
@@ -4,13 +4,13 @@
4
4
 
5
5
  DependencyDetection.defer do
6
6
  @name = :rails21_view
7
-
7
+
8
8
  depends_on do
9
9
  !NewRelic::Agent.config[:disable_view_instrumentation] &&
10
10
  defined?(ActionController) && defined?(ActionController::Base) && defined?(ActionView::PartialTemplate) && defined?(ActionView::Template) &&
11
11
  defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.1\./ # Rails 2.1 &&
12
12
  end
13
-
13
+
14
14
  executes do
15
15
  ::NewRelic::Agent.logger.info 'Installing Rails 2.1 View instrumentation'
16
16
  end
@@ -28,81 +28,81 @@ end
28
28
 
29
29
  DependencyDetection.defer do
30
30
  @name = :old_rails_view
31
-
31
+
32
32
  depends_on do
33
33
  !NewRelic::Agent.config[:disable_view_instrumentation] &&
34
34
  defined?(ActionController) && defined?(ActionController::Base) &&
35
- defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^(1\.|2\.0)/ # Rails 1.* - 2.0
35
+ defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^(1\.|2\.0)/ # Rails 1.* - 2.0
36
36
  end
37
-
37
+
38
38
  executes do
39
39
  ::NewRelic::Agent.logger.info 'Installing Rails 1.* - 2.0 View instrumentation'
40
40
  end
41
-
41
+
42
42
  executes do
43
43
  ActionController::Base.class_eval do
44
44
  add_method_tracer :render, 'View/#{newrelic_metric_path}/Rendering'
45
45
  end
46
-
46
+
47
47
  end
48
48
  end
49
49
 
50
50
  DependencyDetection.defer do
51
51
  @name = :rails23_view
52
-
52
+
53
53
  depends_on do
54
54
  !NewRelic::Agent.config[:disable_view_instrumentation] &&
55
55
  defined?(ActionView) && defined?(ActionView::Template) && defined?(ActionView::RenderablePartial) &&
56
- defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.[23]/
56
+ defined?(Rails::VERSION::STRING) && Rails::VERSION::STRING =~ /^2\.[23]/
57
57
  end
58
58
 
59
59
  executes do
60
60
  ::NewRelic::Agent.logger.info 'Installing Rails 2.2 - 2.3 View instrumentation'
61
61
  end
62
-
63
- executes do
62
+
63
+ executes do
64
64
  ActionView::RenderablePartial.module_eval do
65
65
  add_method_tracer :render_partial, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Partial'
66
66
  end
67
67
  ActionView::Template.class_eval do
68
68
  add_method_tracer :render, 'View/#{path[%r{^(/.*/)?(.*)$},2]}/Rendering'
69
69
  end
70
- end
70
+ end
71
71
  end
72
72
 
73
73
  DependencyDetection.defer do
74
74
  @name = :rails2_controller
75
-
75
+
76
76
  depends_on do
77
77
  defined?(ActionController) && defined?(ActionController::Base)
78
78
  end
79
-
79
+
80
80
  depends_on do
81
81
  defined?(Rails) && Rails::VERSION::MAJOR.to_i == 2
82
82
  end
83
-
83
+
84
84
  executes do
85
85
  ::NewRelic::Agent.logger.info 'Installing Rails 2 Controller instrumentation'
86
86
  end
87
-
87
+
88
88
  executes do
89
89
  ActionController::Base.class_eval do
90
90
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
91
-
91
+
92
92
  # Compare with #alias_method_chain, which is not available in
93
93
  # Rails 1.1:
94
94
  alias_method :perform_action_without_newrelic_trace, :perform_action
95
95
  alias_method :perform_action, :perform_action_with_newrelic_trace
96
96
  private :perform_action
97
-
97
+
98
98
  def self.newrelic_write_attr(attr_name, value) # :nodoc:
99
99
  write_inheritable_attribute(attr_name, value)
100
100
  end
101
-
101
+
102
102
  def self.newrelic_read_attr(attr_name) # :nodoc:
103
103
  read_inheritable_attribute(attr_name)
104
104
  end
105
-
105
+
106
106
  # determine the path that is used in the metric name for
107
107
  # the called controller action
108
108
  def newrelic_metric_path(action_name_override = nil)
@@ -4,7 +4,7 @@
4
4
 
5
5
  DependencyDetection.defer do
6
6
  @name = :rails2_error
7
-
7
+
8
8
  depends_on do
9
9
  defined?(ActionController) && defined?(ActionController::Base)
10
10
  end
@@ -15,8 +15,8 @@ DependencyDetection.defer do
15
15
 
16
16
  executes do
17
17
  ::NewRelic::Agent.logger.info 'Installing Rails 2 Error instrumentation'
18
- end
19
-
18
+ end
19
+
20
20
  executes do
21
21
 
22
22
  ActionController::Base.class_eval do
@@ -26,12 +26,12 @@ DependencyDetection.defer do
26
26
  # but we replaced that global method with NewRelic::Agent#notice_error.
27
27
  # Use that one outside of controller actions.
28
28
  def newrelic_notice_error(exception, custom_params = {})
29
- NewRelic::Agent::Instrumentation::MetricFrame.notice_error exception, :custom_params => custom_params, :request => request
29
+ NewRelic::Agent::Transaction.notice_error exception, :custom_params => custom_params, :request => request
30
30
  end
31
31
 
32
32
  def rescue_action_with_newrelic_trace(exception)
33
33
  rescue_action_without_newrelic_trace exception
34
- NewRelic::Agent::Instrumentation::MetricFrame.notice_error exception, :request => request
34
+ NewRelic::Agent::Transaction.notice_error exception, :request => request
35
35
  end
36
36
 
37
37
  # Compare with #alias_method_chain, which is not available in
@@ -10,7 +10,7 @@ module NewRelic
10
10
  def newrelic_notice_error(exception, custom_params = {})
11
11
  filtered_params = (respond_to? :filter_parameters) ? filter_parameters(params) : params
12
12
  filtered_params.merge!(custom_params)
13
- NewRelic::Agent::Instrumentation::MetricFrame.notice_error( \
13
+ NewRelic::Agent::Transaction.notice_error( \
14
14
  exception, \
15
15
  :request => request, \
16
16
  :metric => newrelic_metric_path, \
@@ -24,9 +24,9 @@ end
24
24
 
25
25
  DependencyDetection.defer do
26
26
  @name = :rails3_error
27
-
27
+
28
28
  depends_on do
29
- defined?(::Rails) && ::Rails.respond_to?(:version) && ::Rails.version.to_i == 3
29
+ defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
30
30
  end
31
31
 
32
32
  depends_on do
@@ -1,6 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
+ require 'new_relic/agent/instrumentation/action_controller_subscriber'
4
5
 
5
6
  module NewRelic
6
7
  module Agent
@@ -14,31 +15,6 @@ module NewRelic
14
15
  def self.newrelic_read_attr(attr_name) # :nodoc:
15
16
  read_inheritable_attribute(attr_name)
16
17
  end
17
-
18
- # determine the path that is used in the metric name for
19
- # the called controller action
20
- def newrelic_metric_path(action_name_override = nil)
21
- action_part = action_name_override || action_name
22
- if action_name_override || self.class.action_methods.include?(action_part)
23
- "#{self.class.controller_path}/#{action_part}"
24
- else
25
- "#{self.class.controller_path}/(other)"
26
- end
27
- end
28
-
29
- def process_action(*args)
30
- # skip instrumentation if we are in an ignored action
31
- if _is_filtered?('do_not_trace')
32
- NewRelic::Agent.disable_all_tracing do
33
- return super
34
- end
35
- end
36
-
37
- perform_action_with_newrelic_trace(:category => :controller, :name => self.action_name, :path => newrelic_metric_path, :params => request.filtered_parameters, :class_name => self.class.name) do
38
- super
39
- end
40
- end
41
-
42
18
  end
43
19
  end
44
20
  end
@@ -65,5 +41,7 @@ DependencyDetection.defer do
65
41
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
66
42
  include NewRelic::Agent::Instrumentation::Rails4::ActionController
67
43
  end
44
+ NewRelic::Agent::Instrumentation::ActionControllerSubscriber \
45
+ .subscribe(/^process_action.action_controller$/)
68
46
  end
69
47
  end
@@ -1,120 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
-
5
- # Listen for ActiveSupport::Notifications events for ActionView render
6
- # events. Write metric data and transaction trace segments for each event.
7
- module NewRelic
8
- module Agent
9
- module Instrumentation
10
- class ActionViewSubscriber
11
- def initialize
12
- @queue_key = ['NewRelic', self.class.name, object_id].join('-')
13
- end
14
-
15
- def self.subscribe
16
- if !subscribed?
17
- ActiveSupport::Notifications.subscribe(/render_.+\.action_view$/,
18
- new)
19
- end
20
- end
21
-
22
- def self.subscribed?
23
- # TODO: need to talk to Rails core about an API for this,
24
- # rather than digging through Listener ivars
25
- ActiveSupport::Notifications.notifier.instance_variable_get(:@subscribers) \
26
- .find{|s| s.instance_variable_get(:@delegate).class == self }
27
- end
28
-
29
- def start(name, id, payload)
30
- event = RenderEvent.new(name, Time.now, nil, id, payload)
31
- parent = event_stack[id].last
32
- event.parent = parent
33
- parent << event if parent
34
- event_stack[id].push event
35
-
36
- if NewRelic::Agent.is_execution_traced? && event.recordable?
37
- event.scope = NewRelic::Agent.instance.stats_engine \
38
- .push_scope(event.metric_name, event.time)
39
- end
40
- end
41
-
42
- def finish(name, id, payload)
43
- event = event_stack[id].pop
44
- event.end = Time.now
45
-
46
- if NewRelic::Agent.is_execution_traced? && event.recordable?
47
- record_metrics(event)
48
- NewRelic::Agent.instance.stats_engine \
49
- .pop_scope(event.scope, event.duration, event.end)
50
- end
51
- end
52
-
53
- def record_metrics(event)
54
- NewRelic::Agent.instance.stats_engine \
55
- .record_metrics(event.metric_name,
56
- Helper.milliseconds_to_seconds(event.duration),
57
- :scoped => true)
58
- end
59
-
60
- def event_stack
61
- Thread.current[@queue_key] ||= Hash.new {|h,id| h[id] = [] }
62
- end
63
-
64
- if defined?(ActiveSupport::Notifications::Event)
65
- class RenderEvent < ActiveSupport::Notifications::Event
66
- attr_accessor :parent, :scope
67
-
68
- # Nearly every "render_blah.action_view" event has a child
69
- # in the form of "!render_blah.action_view". The children
70
- # are the ones we want to record. There are a couple
71
- # special cases of events without children.
72
- def recordable?
73
- name[0] == '!' ||
74
- metric_name == 'View/text template/Rendering' ||
75
- metric_name == 'View/(unknown)/Partial'
76
- end
77
-
78
- def metric_name
79
- if parent && (payload[:virtual_path] ||
80
- (parent.payload[:identifier] =~ /template$/))
81
- return parent.metric_name
82
- elsif payload[:virtual_path]
83
- identifier = payload[:virtual_path]
84
- else
85
- identifier = payload[:identifier]
86
- end
87
-
88
- # memoize
89
- @metric_name ||= "View/#{metric_path(identifier)}/#{metric_action(name)}"
90
- @metric_name
91
- end
92
-
93
- def metric_path(identifier)
94
- if identifier == nil
95
- 'file'
96
- elsif identifier =~ /template$/
97
- identifier
98
- elsif (parts = identifier.split('/')).size > 1
99
- parts[-2..-1].join('/')
100
- else
101
- '(unknown)'
102
- end
103
- end
104
-
105
- def metric_action(name)
106
- case name
107
- when /render_template.action_view$/ then 'Rendering'
108
- when 'render_partial.action_view' then 'Partial'
109
- when 'render_collection.action_view' then 'Partial'
110
- end
111
- end
112
- end
113
- end
114
- end
115
- end
116
- end
117
- end
4
+ require 'new_relic/agent/instrumentation/action_view_subscriber'
118
5
 
119
6
  DependencyDetection.defer do
120
7
  @name = :rails4_view
@@ -133,6 +20,6 @@ DependencyDetection.defer do
133
20
  end
134
21
 
135
22
  executes do
136
- NewRelic::Agent::Instrumentation::ActionViewSubscriber.subscribe
23
+ NewRelic::Agent::Instrumentation::ActionViewSubscriber.subscribe(/render_.+\.action_view$/)
137
24
  end
138
25
  end
@@ -1,87 +1,7 @@
1
1
  # encoding: utf-8
2
2
  # This file is distributed under New Relic's license terms.
3
3
  # See https://github.com/newrelic/rpm/blob/master/LICENSE for complete details.
4
- require 'new_relic/agent/instrumentation/active_record_helper'
5
-
6
- # Listen for ActiveSupport::Notifications events for ActiveRecord query
7
- # events. Write metric data, transaction trace segments and slow sql
8
- # nodes for each event.
9
- module NewRelic
10
- module Agent
11
- module Instrumentation
12
- class ActiveRecordSubscriber
13
- include NewRelic::Agent::Instrumentation
14
-
15
- def self.subscribed?
16
- # TODO: need to talk to Rails core about an API for this,
17
- # rather than digging through Listener ivars
18
- ActiveSupport::Notifications.notifier.listeners_for('sql.active_record') \
19
- .find{|l| l.instance_variable_get(:@delegate).class == self }
20
- end
21
-
22
- def call(*args)
23
- return unless NewRelic::Agent.is_execution_traced?
24
-
25
- event = ActiveSupport::Notifications::Event.new(*args)
26
- record_metrics(event)
27
- notice_sql(event)
28
- end
29
-
30
- def notice_sql(event)
31
- config = active_record_config_for_event(event)
32
- metric = base_metric(event)
33
-
34
- # enter transaction trace segment
35
- scope = NewRelic::Agent.instance.stats_engine.push_scope(metric, event.time)
36
-
37
- NewRelic::Agent.instance.transaction_sampler \
38
- .notice_sql(event.payload[:sql], config,
39
- Helper.milliseconds_to_seconds(event.duration))
40
-
41
- NewRelic::Agent.instance.sql_sampler \
42
- .notice_sql(event.payload[:sql], metric, config,
43
- Helper.milliseconds_to_seconds(event.duration))
44
-
45
- # exit transaction trace segment
46
- NewRelic::Agent.instance.stats_engine.pop_scope(scope, event.duration, event.end)
47
- end
48
-
49
- def record_metrics(event)
50
- base = base_metric(event)
51
- NewRelic::Agent.instance.stats_engine.record_metrics(base,
52
- Helper.milliseconds_to_seconds(event.duration),
53
- :scoped => true)
54
-
55
- other_metrics = ActiveRecordHelper.rollup_metrics_for(base)
56
- if config = active_record_config_for_event(event)
57
- other_metrics << ActiveRecordHelper.remote_service_metric(config[:adapter], config[:host])
58
- end
59
-
60
- other_metrics.compact.each do |metric_name|
61
- NewRelic::Agent.instance.stats_engine.record_metrics(metric_name,
62
- Helper.milliseconds_to_seconds(event.duration),
63
- :scoped => false)
64
- end
65
- end
66
-
67
- def base_metric(event)
68
- ActiveRecordHelper.metric_for_name(event.payload[:name]) ||
69
- ActiveRecordHelper.metric_for_sql(NewRelic::Helper.correctly_encoded(event.payload[:sql]))
70
- end
71
-
72
- def active_record_config_for_event(event)
73
- return unless event.payload[:connection_id]
74
-
75
- # TODO: This will not work for JRuby and in any case we want
76
- # this to be part of the event meta data so it doesn't have
77
- # to be dug out of an ivar.
78
- connection = ObjectSpace._id2ref(event.payload[:connection_id])
79
- connection.instance_variable_get(:@config) if connection
80
- end
81
- end
82
- end
83
- end
84
- end
4
+ require 'new_relic/agent/instrumentation/active_record_subscriber'
85
5
 
86
6
  DependencyDetection.defer do
87
7
  @name = :active_record
@@ -98,7 +18,7 @@ DependencyDetection.defer do
98
18
  end
99
19
 
100
20
  executes do
101
- ::NewRelic::Agent.logger.info 'Installing ActiveRecord instrumentation'
21
+ ::NewRelic::Agent.logger.info 'Installing ActiveRecord 4 instrumentation'
102
22
  end
103
23
 
104
24
  executes do
@@ -10,10 +10,9 @@ module NewRelic
10
10
  def newrelic_notice_error(exception, custom_params = {})
11
11
  filtered_params = (respond_to? :filter_parameters) ? filter_parameters(params) : params
12
12
  filtered_params.merge!(custom_params)
13
- NewRelic::Agent::Instrumentation::MetricFrame.notice_error( \
13
+ NewRelic::Agent::Transaction.notice_error( \
14
14
  exception, \
15
15
  :request => request, \
16
- :metric => newrelic_metric_path, \
17
16
  :custom_params => filtered_params)
18
17
  end
19
18
  end
@@ -24,9 +23,9 @@ end
24
23
 
25
24
  DependencyDetection.defer do
26
25
  @name = :rails4_error
27
-
26
+
28
27
  depends_on do
29
- defined?(::Rails) && ::Rails.respond_to?(:version) && ::Rails.version.to_i == 4
28
+ defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 4
30
29
  end
31
30
 
32
31
  depends_on do