newrelic_rpm 3.3.0 → 3.3.1.beta1

Sign up to get free protection for your applications and to get access to all the features.

Potentially problematic release.


This version of newrelic_rpm might be problematic. Click here for more details.

data/CHANGELOG CHANGED
@@ -1,3 +1,7 @@
1
+ v3.3.1
2
+ * improved Ruby 1.8.6 support
3
+ * fix for issues with RAILS_ROOT deprecation warnings
4
+
1
5
  v3.3.0
2
6
  * fix for GC instrumentation when using Ruby 1.9
3
7
  * new feature to correlate browser and server transaction traces
@@ -1048,7 +1048,7 @@ module NewRelic
1048
1048
  # FIXME add the code to try to resend if our connection is down
1049
1049
  sql_traces = @sql_sampler.harvest
1050
1050
  unless sql_traces.empty?
1051
- log.debug "Sending (#{sql_traces.count}) sql traces"
1051
+ log.debug "Sending (#{sql_traces.size}) sql traces"
1052
1052
  begin
1053
1053
  response = invoke_remote :sql_trace_data, sql_traces
1054
1054
  # log.debug "Sql trace response: #{response}"
@@ -35,14 +35,6 @@ module NewRelic
35
35
  ConnectionManager.instance.close_connections
36
36
  end
37
37
 
38
- def config
39
- ConnectionManager.instance.config
40
- end
41
-
42
- def config=(other)
43
- ConnectionManager.instance.config = other
44
- end
45
-
46
38
  # Perform this in the runtime environment of a managed
47
39
  # application, to explain the sql statement executed within a
48
40
  # segment of a transaction sample. Returns an array of
@@ -119,12 +111,10 @@ module NewRelic
119
111
  first_word, rest_of_statement = statement.split($;, 2)
120
112
  (first_word.upcase == 'SELECT')
121
113
  end
122
-
114
+
123
115
  class ConnectionManager
124
116
  include Singleton
125
117
 
126
- attr_accessor :config
127
-
128
118
  # Returns a cached connection for a given ActiveRecord
129
119
  # configuration - these are stored or reopened as needed, and if
130
120
  # we cannot get one, we ignore it and move on without explaining
@@ -0,0 +1,137 @@
1
+ module NewRelic
2
+ module Agent
3
+ module Instrumentation
4
+ module ActiveRecord
5
+ def self.included(instrumented_class)
6
+ instrumented_class.class_eval do
7
+ unless instrumented_class.method_defined?(:log_without_newrelic_instrumentation)
8
+ alias_method :log_without_newrelic_instrumentation, :log
9
+ alias_method :log, :log_with_newrelic_instrumentation
10
+ protected :log
11
+ end
12
+ end
13
+ end
14
+
15
+ def log_with_newrelic_instrumentation(*args, &block)
16
+ if !NewRelic::Agent.is_execution_traced?
17
+ return log_without_newrelic_instrumentation(*args, &block)
18
+ end
19
+
20
+ sql, name, binds = args
21
+ metric = metric_for_name(name) || metric_for_sql(sql)
22
+
23
+ if !metric
24
+ log_without_newrelic_instrumentation(*args, &block)
25
+ else
26
+ metrics = [metric, remote_service_metric].compact
27
+ metrics += rollup_metrics_for(metric)
28
+ self.class.trace_execution_scoped(metrics) do
29
+ t0 = Time.now
30
+ begin
31
+ log_without_newrelic_instrumentation(*args, &block)
32
+ ensure
33
+ elapsed_time = (Time.now - t0).to_f
34
+ NewRelic::Agent.instance.transaction_sampler.notice_sql(sql,
35
+ @config, elapsed_time)
36
+ NewRelic::Agent.instance.sql_sampler.notice_sql(sql, metric,
37
+ @config, elapsed_time)
38
+ end
39
+ end
40
+ end
41
+ end
42
+
43
+ def remote_service_metric
44
+ if @config && @config[:adapter]
45
+ type = @config[:adapter].sub(/\d*/, '')
46
+ host = @config[:host] || 'localhost'
47
+ "RemoteService/sql/#{type}/#{host}"
48
+ end
49
+ end
50
+
51
+ def metric_for_name(name)
52
+ if name && (parts = name.split " ") && parts.size == 2
53
+ model = parts.first
54
+ operation = parts.last.downcase
55
+ op_name = case operation
56
+ when 'load', 'count', 'exists' then 'find'
57
+ when 'indexes', 'columns' then nil # fall back to DirectSQL
58
+ when 'destroy', 'find', 'save', 'create' then operation
59
+ when 'update' then 'save'
60
+ else
61
+ if model == 'Join'
62
+ operation
63
+ end
64
+ end
65
+ "ActiveRecord/#{model}/#{op_name}" if op_name
66
+ end
67
+ end
68
+
69
+ def metric_for_sql(sql)
70
+ metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
71
+ if metric.nil?
72
+ if sql =~ /^(select|update|insert|delete|show)/i
73
+ # Could not determine the model/operation so let's find a better
74
+ # metric. If it doesn't match the regex, it's probably a show
75
+ # command or some DDL which we'll ignore.
76
+ metric = "Database/SQL/#{$1.downcase}"
77
+ else
78
+ metric = "Database/SQL/other"
79
+ end
80
+ end
81
+ metric
82
+ end
83
+
84
+ def rollup_metrics_for(metric)
85
+ metrics = ["ActiveRecord/all"]
86
+ metrics << "ActiveRecord/#{$1}" if metric =~ /ActiveRecord\/\w+\/(\w+)/
87
+ metrics
88
+ end
89
+ end
90
+ end
91
+ end
92
+ end
93
+
94
+ DependencyDetection.defer do
95
+ @name = :active_record
96
+
97
+ depends_on do
98
+ defined?(ActiveRecord) && defined?(ActiveRecord::Base)
99
+ end
100
+
101
+ depends_on do
102
+ !NewRelic::Control.instance['skip_ar_instrumentation']
103
+ end
104
+
105
+ depends_on do
106
+ !NewRelic::Control.instance['disable_activerecord_instrumentation']
107
+ end
108
+
109
+ executes do
110
+ NewRelic::Agent.logger.debug 'Installing ActiveRecord instrumentation'
111
+ end
112
+
113
+ executes do
114
+ if defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
115
+ Rails.configuration.after_initialize do
116
+ insert_instrumentation
117
+ end
118
+ else
119
+ insert_instrumentation
120
+ end
121
+ end
122
+
123
+ def insert_instrumentation
124
+ ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
125
+ include ::NewRelic::Agent::Instrumentation::ActiveRecord
126
+ end
127
+
128
+ ActiveRecord::Base.class_eval do
129
+ class << self
130
+ add_method_tracer(:find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql',
131
+ :metric => false)
132
+ add_method_tracer(:transaction, 'ActiveRecord/#{self.name}/transaction',
133
+ :metric => false)
134
+ end
135
+ end
136
+ end
137
+ end
@@ -231,6 +231,7 @@ module NewRelic
231
231
  # If a single argument is passed in, it is treated as a metric
232
232
  # path. This form is deprecated.
233
233
  def perform_action_with_newrelic_trace(*args, &block)
234
+ NewRelic::Agent::TransactionInfo.clear
234
235
 
235
236
  # Skip instrumentation based on the value of 'do_not_trace' and if
236
237
  # we aren't calling directly with a block.
@@ -95,9 +95,9 @@ module NewRelic
95
95
  data = transaction_data
96
96
  clear_transaction_data
97
97
 
98
- if data.sql_data.count > 0
98
+ if data.sql_data.size > 0
99
99
  @samples_lock.synchronize do
100
- NewRelic::Agent.instance.log.debug "Harvesting #{data.sql_data.count} slow transaction sql statement(s)"
100
+ NewRelic::Agent.instance.log.debug "Harvesting #{data.sql_data.size} slow transaction sql statement(s)"
101
101
  #FIXME get tx name and uri
102
102
  harvest_slow_sql data
103
103
  end
@@ -14,7 +14,8 @@ module NewRelic
14
14
  # (handled elsewhere)
15
15
  def should_send_data?
16
16
  NewRelic::Control.instance.disable_serialization? || store_too_large? ||
17
- store_too_old? || pid_too_old?
17
+ store_too_old? || pid_too_old? ||
18
+ NewRelic::LanguageSupport.using_version?('1.8.6')
18
19
  rescue Exception => e
19
20
  NewRelic::Control.instance.disable_serialization = true
20
21
  NewRelic::Control.instance.log.warn("Disabling serialization: #{e.message}")
@@ -43,4 +43,9 @@ DependencyDetection.defer do
43
43
  end
44
44
  end
45
45
  end
46
- DependencyDetection.detect!
46
+
47
+ # If Rails is defined, this gets called in an after_initialize hook
48
+ # see NewRelic::Control::Frameworks::Rails#init_config
49
+ unless defined?(Rails)
50
+ DependencyDetection.detect!
51
+ end
@@ -3,8 +3,8 @@ module NewRelic
3
3
  module VERSION #:nodoc:
4
4
  MAJOR = 3
5
5
  MINOR = 3
6
- TINY = 0
7
- BUILD = nil # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
6
+ TINY = 1
7
+ BUILD = 'beta1' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
8
8
  STRING = [MAJOR, MINOR, TINY, BUILD].compact.join('.')
9
9
  end
10
10
 
data/newrelic_rpm.gemspec CHANGED
@@ -5,14 +5,14 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = "newrelic_rpm"
8
- s.version = "3.3.0"
8
+ s.version = "3.3.1.beta1"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = ["Bill Kayser", "Jon Guymon", "Justin George", "Darin Swanson"]
12
- s.date = "2011-11-07"
12
+ s.date = "2011-11-11"
13
13
  s.description = "New Relic is a performance management system, developed by New Relic,\nInc (http://www.newrelic.com). New Relic provides you with deep\ninformation about the performance of your web application as it runs\nin production. The New Relic Ruby Agent is dual-purposed as a either a\nGem or plugin, hosted on\nhttp://github.com/newrelic/rpm/\n"
14
14
  s.email = "support@newrelic.com"
15
- s.executables = ["newrelic_cmd", "newrelic", "mongrel_rpm"]
15
+ s.executables = ["mongrel_rpm", "newrelic", "newrelic_cmd"]
16
16
  s.extra_rdoc_files = [
17
17
  "CHANGELOG",
18
18
  "LICENSE",
@@ -42,6 +42,7 @@ Gem::Specification.new do |s|
42
42
  "lib/new_relic/agent/error_collector.rb",
43
43
  "lib/new_relic/agent/instrumentation.rb",
44
44
  "lib/new_relic/agent/instrumentation/active_merchant.rb",
45
+ "lib/new_relic/agent/instrumentation/active_record.rb",
45
46
  "lib/new_relic/agent/instrumentation/acts_as_solr.rb",
46
47
  "lib/new_relic/agent/instrumentation/authlogic.rb",
47
48
  "lib/new_relic/agent/instrumentation/controller_instrumentation.rb",
@@ -58,10 +59,8 @@ Gem::Specification.new do |s|
58
59
  "lib/new_relic/agent/instrumentation/rack.rb",
59
60
  "lib/new_relic/agent/instrumentation/rails/action_controller.rb",
60
61
  "lib/new_relic/agent/instrumentation/rails/action_web_service.rb",
61
- "lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb",
62
62
  "lib/new_relic/agent/instrumentation/rails/errors.rb",
63
63
  "lib/new_relic/agent/instrumentation/rails3/action_controller.rb",
64
- "lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb",
65
64
  "lib/new_relic/agent/instrumentation/rails3/errors.rb",
66
65
  "lib/new_relic/agent/instrumentation/sinatra.rb",
67
66
  "lib/new_relic/agent/instrumentation/sunspot.rb",
@@ -21,6 +21,25 @@ class NewRelic::Agent::BrowserMonitoringTest < Test::Unit::TestCase
21
21
  mocha_teardown
22
22
  end
23
23
 
24
+ def test_browser_monitoring_start_time_is_reset_each_request
25
+ controller = Object.new
26
+ def controller.perform_action_without_newrelic_trace(method, options={});
27
+ # noop; instrument me
28
+ end
29
+ def controller.newrelic_metric_path; "foo"; end
30
+ controller.extend ::NewRelic::Agent::Instrumentation::ControllerInstrumentation
31
+ controller.extend ::NewRelic::Agent::BrowserMonitoring
32
+
33
+ controller.perform_action_with_newrelic_trace(:index)
34
+ first_request_start_time = controller.send(:browser_monitoring_start_time)
35
+ controller.perform_action_with_newrelic_trace(:index)
36
+ second_request_start_time = controller.send(:browser_monitoring_start_time)
37
+
38
+ # assert that these aren't the same time object
39
+ # the start time should be reinitialized each request to the controller
40
+ assert !(first_request_start_time.equal? second_request_start_time)
41
+ end
42
+
24
43
  def test_browser_timing_header_with_no_beacon_configuration
25
44
  NewRelic::Agent.instance.expects(:beacon_configuration).returns( nil)
26
45
  header = browser_timing_header
@@ -1,4 +1,5 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'..','..','..','test_helper'))
2
+
2
3
  class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::Unit::TestCase
3
4
  require 'active_record_fixtures'
4
5
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation
@@ -139,20 +140,22 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
139
140
  def test_metric_names_standard
140
141
  # fails due to a bug in rails 3 - log does not provide the correct
141
142
  # transaction type - it returns 'SQL' instead of 'Foo Create', for example.
142
- return if rails3? || defined?(JRuby) || isSqlite?
143
-
143
+ return if defined?(JRuby) || isSqlite?
144
+
144
145
  expected = %W[
145
146
  ActiveRecord/all
146
147
  ActiveRecord/find
147
- ActiveRecord/ActiveRecordFixtures::Order/find
148
148
  ActiveRecord/create
149
+ ActiveRecord/ActiveRecordFixtures::Order/find
150
+ ActiveRecord/ActiveRecordFixtures::Order/create
149
151
  Database/SQL/other
150
- RemoteService/sql/mysql/localhost
151
- ActiveRecord/ActiveRecordFixtures::Order/create]
152
+ RemoteService/sql/mysql/localhost]
152
153
 
153
154
  if NewRelic::Control.instance.rails_version < '2.1.0'
154
155
  expected += ['ActiveRecord/save',
155
156
  'ActiveRecord/ActiveRecordFixtures::Order/save']
157
+ elsif NewRelic::Control.instance.rails_version >= '3.0.0'
158
+ expected << 'Database/SQL/insert'
156
159
  end
157
160
 
158
161
  assert_calls_metrics(*expected) do
@@ -163,10 +166,14 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
163
166
  end
164
167
 
165
168
  metrics = NewRelic::Agent.instance.stats_engine.metrics
166
-
169
+
167
170
  compare_metrics expected, metrics
168
171
  check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/find", 1)
169
- check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 1)
172
+ if NewRelic::Control.instance.rails_version < '3.0.0'
173
+ check_metric_count("ActiveRecord/ActiveRecordFixtures::Order/create", 1)
174
+ else
175
+ check_metric_count("Database/SQL/insert", 1)
176
+ end
170
177
  end
171
178
 
172
179
  def test_join_metrics_jruby
@@ -346,6 +353,7 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
346
353
  metrics = NewRelic::Agent.instance.stats_engine.metrics
347
354
  compare_metrics [], metrics
348
355
  end
356
+
349
357
  def test_run_explains
350
358
  perform_action_with_newrelic_trace :name => 'bogosity' do
351
359
  ActiveRecordFixtures::Order.add_delay
@@ -353,10 +361,12 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
353
361
  end
354
362
 
355
363
  # that's a mouthful. perhaps we should ponder our API.
356
- segment = NewRelic::Agent.instance.transaction_sampler.last_sample.root_segment.called_segments.first.called_segments.first.called_segments.first
364
+ segment = NewRelic::Agent.instance.transaction_sampler.last_sample \
365
+ .root_segment.called_segments[0].called_segments[0].called_segments[0]
357
366
  regex = /^SELECT (["`]?#{ActiveRecordFixtures::Order.table_name}["`]?.)?\* FROM ["`]?#{ActiveRecordFixtures::Order.table_name}["`]?$/
358
367
  assert_match regex, segment.params[:sql].strip
359
368
  end
369
+
360
370
  def test_prepare_to_send
361
371
  perform_action_with_newrelic_trace :name => 'bogosity' do
362
372
  ActiveRecordFixtures::Order.add_delay
@@ -517,7 +527,31 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
517
527
  assert_equal 'preserve-me!', e.message
518
528
  end
519
529
  end
520
-
530
+
531
+ def test_remote_service_metric_respects_dynamic_connection_config
532
+ return unless isMysql?
533
+
534
+ # puts NewRelic::Agent::Database.config.inspect
535
+
536
+ ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
537
+ assert(NewRelic::Agent.get_stats('RemoteService/sql/mysql/localhost').call_count != 0)
538
+
539
+ config = ActiveRecordFixtures::Shipment.connection.instance_eval { @config }
540
+ config[:host] = '127.0.0.1'
541
+ connection = ActiveRecordFixtures::Shipment.establish_connection(config)
542
+
543
+ # puts ActiveRecord::Base.connection.instance_eval { @config }.inspect
544
+ # puts NewRelic::Agent::Database.config.inspect
545
+
546
+ ActiveRecordFixtures::Shipment.connection.execute('SHOW TABLES');
547
+ assert(NewRelic::Agent.get_stats('RemoteService/sql/mysql/127.0.0.1').call_count != 0)
548
+
549
+ config[:host] = 'localhost'
550
+ ActiveRecordFixtures::Shipment.establish_connection(config)
551
+
552
+ # raise NewRelic::Agent.instance.stats_engine.inspect
553
+ end
554
+
521
555
  private
522
556
 
523
557
  def rails3?
@@ -538,5 +572,4 @@ class NewRelic::Agent::Instrumentation::ActiveRecordInstrumentationTest < Test::
538
572
  def isSqlite?
539
573
  ActiveRecord::Base.configurations[rails_env]['adapter'] =~ /sqlite/i
540
574
  end
541
-
542
575
  end
@@ -270,20 +270,15 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
270
270
  check_metric_time('WebFrontend/QueueTime', 0.0, 0.001)
271
271
  end
272
272
 
273
-
274
- # check all the combinations to make sure that ordering doesn't
275
- # affect the return value
276
273
  def test_find_oldest_time
277
- test_arrays = [
274
+ test_array = [
275
+ ['c', Time.at(1002)],
278
276
  ['a', Time.at(1000)],
279
277
  ['b', Time.at(1001)],
280
- ['c', Time.at(1002)],
281
278
  ['d', Time.at(1000)],
282
279
  ]
283
- test_arrays = test_arrays.permutation
284
- test_arrays.each do |test_array|
285
- assert_equal find_oldest_time(test_array), Time.at(1000), "Should be the oldest time in the array"
286
- end
280
+ assert_equal(find_oldest_time(test_array), Time.at(1000),
281
+ "Should be the oldest time in the array")
287
282
  end
288
283
 
289
284
  # trivial test but the method doesn't do much
@@ -104,7 +104,7 @@ module NewRelic
104
104
  end
105
105
 
106
106
  def test_check_for_illegal_keys_negative
107
- test_keys = Hash[ALLOWED_KEYS.map {|x| [x, nil]}]
107
+ test_keys = Hash[*ALLOWED_KEYS.map {|x| [x, nil]}.flatten]
108
108
  check_for_illegal_keys!(test_keys)
109
109
  end
110
110
 
@@ -82,7 +82,7 @@ class NewRelic::Agent::RpmAgentTest < Test::Unit::TestCase # ActiveSupport::Test
82
82
 
83
83
  should "send_timeslice_data" do
84
84
  # this test fails due to a rubinius bug
85
- return if (RUBY_DESCRIPTION =~ /rubinius/i)
85
+ return if NewRelic::LanguageSupport.using_engine?('rbx')
86
86
  @agent.expects(:invoke_remote).returns({NewRelic::MetricSpec.new("/A/b/c") => 1, NewRelic::MetricSpec.new("/A/b/c", "/X") => 2, NewRelic::MetricSpec.new("/A/b/d") => 3 }.to_a)
87
87
  @agent.send :harvest_and_send_timeslice_data
88
88
  assert_equal 3, @agent.metric_ids.size
@@ -31,7 +31,7 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
31
31
  # this sql will not be captured
32
32
  @sampler.notice_sql "select * from test", "Database/test/select", nil, 0
33
33
  assert_not_nil @sampler.transaction_data
34
- assert_equal 2, @sampler.transaction_data.sql_data.count
34
+ assert_equal 2, @sampler.transaction_data.sql_data.size
35
35
  end
36
36
 
37
37
  def test_harvest_slow_sql
@@ -45,7 +45,7 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
45
45
  ]
46
46
  @sampler.harvest_slow_sql data
47
47
 
48
- assert_equal 2, @sampler.sql_traces.count
48
+ assert_equal 2, @sampler.sql_traces.size
49
49
  end
50
50
 
51
51
  def test_sql_aggregation
@@ -73,7 +73,7 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
73
73
  @sampler.harvest_slow_sql data
74
74
 
75
75
  sql_traces = @sampler.harvest
76
- assert_equal 2, sql_traces.count
76
+ assert_equal 2, sql_traces.size
77
77
  end
78
78
 
79
79
  def test_harvest_should_not_take_more_than_10
@@ -104,7 +104,7 @@ class NewRelic::Agent::SqlSamplerTest < Test::Unit::TestCase
104
104
  @sampler.harvest_slow_sql data
105
105
 
106
106
  sql_traces = @sampler.harvest
107
- assert_equal 2, sql_traces.count
107
+ assert_equal 2, sql_traces.size
108
108
  end
109
109
 
110
110
  def test_harvest_should_collect_explain_plans
@@ -22,6 +22,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
22
22
  # testing that the CA file we ship actually validates our server's
23
23
  # certificate. It's used for customers who enable verify_certificate
24
24
  def test_cert_file
25
+ return if ::RUBY_VERSION == '1.9.3'
25
26
  require 'socket'
26
27
  require 'openssl'
27
28
 
@@ -38,6 +39,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
38
39
  # certificates in a non-customer-facing place before setting them
39
40
  # live.
40
41
  def test_staging_cert_file
42
+ return if ::RUBY_VERSION == '1.9.3'
41
43
  require 'socket'
42
44
  require 'openssl'
43
45
 
@@ -151,6 +151,7 @@ class NewRelic::DataSerializationTest < Test::Unit::TestCase
151
151
  end
152
152
 
153
153
  def test_loading_does_not_seg_fault_if_gc_triggers
154
+ return if NewRelic::LanguageSupport.using_version?('1.8.6')
154
155
  require 'timeout'
155
156
 
156
157
  Thread.abort_on_exception = true
metadata CHANGED
@@ -1,15 +1,10 @@
1
- --- !ruby/object:Gem::Specification
1
+ --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
- version: !ruby/object:Gem::Version
4
- hash: 11
5
- prerelease:
6
- segments:
7
- - 3
8
- - 3
9
- - 0
10
- version: 3.3.0
3
+ version: !ruby/object:Gem::Version
4
+ version: 3.3.1.beta1
5
+ prerelease: 6
11
6
  platform: ruby
12
- authors:
7
+ authors:
13
8
  - Bill Kayser
14
9
  - Jon Guymon
15
10
  - Justin George
@@ -17,72 +12,66 @@ authors:
17
12
  autorequire:
18
13
  bindir: bin
19
14
  cert_chain: []
20
-
21
- date: 2011-11-07 00:00:00 Z
22
- dependencies:
23
- - !ruby/object:Gem::Dependency
15
+ date: 2011-11-11 00:00:00.000000000 Z
16
+ dependencies:
17
+ - !ruby/object:Gem::Dependency
24
18
  name: jeweler
25
- prerelease: false
26
- requirement: &id001 !ruby/object:Gem::Requirement
19
+ requirement: &2152161920 !ruby/object:Gem::Requirement
27
20
  none: false
28
- requirements:
29
- - - ">="
30
- - !ruby/object:Gem::Version
31
- hash: 3
32
- segments:
33
- - 0
34
- version: "0"
21
+ requirements:
22
+ - - ! '>='
23
+ - !ruby/object:Gem::Version
24
+ version: '0'
35
25
  type: :development
36
- version_requirements: *id001
37
- - !ruby/object:Gem::Dependency
38
- name: mocha
39
26
  prerelease: false
40
- requirement: &id002 !ruby/object:Gem::Requirement
27
+ version_requirements: *2152161920
28
+ - !ruby/object:Gem::Dependency
29
+ name: mocha
30
+ requirement: &2152161440 !ruby/object:Gem::Requirement
41
31
  none: false
42
- requirements:
43
- - - ">="
44
- - !ruby/object:Gem::Version
45
- hash: 3
46
- segments:
47
- - 0
48
- version: "0"
32
+ requirements:
33
+ - - ! '>='
34
+ - !ruby/object:Gem::Version
35
+ version: '0'
49
36
  type: :development
50
- version_requirements: *id002
51
- - !ruby/object:Gem::Dependency
52
- name: shoulda
53
37
  prerelease: false
54
- requirement: &id003 !ruby/object:Gem::Requirement
38
+ version_requirements: *2152161440
39
+ - !ruby/object:Gem::Dependency
40
+ name: shoulda
41
+ requirement: &2152160940 !ruby/object:Gem::Requirement
55
42
  none: false
56
- requirements:
57
- - - ">="
58
- - !ruby/object:Gem::Version
59
- hash: 3
60
- segments:
61
- - 0
62
- version: "0"
43
+ requirements:
44
+ - - ! '>='
45
+ - !ruby/object:Gem::Version
46
+ version: '0'
63
47
  type: :development
64
- version_requirements: *id003
65
- description: |
66
- New Relic is a performance management system, developed by New Relic,
48
+ prerelease: false
49
+ version_requirements: *2152160940
50
+ description: ! 'New Relic is a performance management system, developed by New Relic,
51
+
67
52
  Inc (http://www.newrelic.com). New Relic provides you with deep
53
+
68
54
  information about the performance of your web application as it runs
55
+
69
56
  in production. The New Relic Ruby Agent is dual-purposed as a either a
57
+
70
58
  Gem or plugin, hosted on
59
+
71
60
  http://github.com/newrelic/rpm/
72
61
 
62
+ '
73
63
  email: support@newrelic.com
74
- executables:
75
- - newrelic_cmd
76
- - newrelic
64
+ executables:
77
65
  - mongrel_rpm
66
+ - newrelic
67
+ - newrelic_cmd
78
68
  extensions: []
79
-
80
- extra_rdoc_files:
69
+ extra_rdoc_files:
81
70
  - CHANGELOG
82
71
  - LICENSE
83
72
  - README.rdoc
84
73
  - newrelic.yml
85
- files:
74
+ files:
86
75
  - CHANGELOG
87
76
  - LICENSE
88
77
  - README.rdoc
@@ -105,6 +94,7 @@ files:
105
94
  - lib/new_relic/agent/error_collector.rb
106
95
  - lib/new_relic/agent/instrumentation.rb
107
96
  - lib/new_relic/agent/instrumentation/active_merchant.rb
97
+ - lib/new_relic/agent/instrumentation/active_record.rb
108
98
  - lib/new_relic/agent/instrumentation/acts_as_solr.rb
109
99
  - lib/new_relic/agent/instrumentation/authlogic.rb
110
100
  - lib/new_relic/agent/instrumentation/controller_instrumentation.rb
@@ -121,10 +111,8 @@ files:
121
111
  - lib/new_relic/agent/instrumentation/rack.rb
122
112
  - lib/new_relic/agent/instrumentation/rails/action_controller.rb
123
113
  - lib/new_relic/agent/instrumentation/rails/action_web_service.rb
124
- - lib/new_relic/agent/instrumentation/rails/active_record_instrumentation.rb
125
114
  - lib/new_relic/agent/instrumentation/rails/errors.rb
126
115
  - lib/new_relic/agent/instrumentation/rails3/action_controller.rb
127
- - lib/new_relic/agent/instrumentation/rails3/active_record_instrumentation.rb
128
116
  - lib/new_relic/agent/instrumentation/rails3/errors.rb
129
117
  - lib/new_relic/agent/instrumentation/sinatra.rb
130
118
  - lib/new_relic/agent/instrumentation/sunspot.rb
@@ -344,61 +332,38 @@ files:
344
332
  - vendor/gems/metric_parser-0.1.0.pre1/lib/new_relic/metric_parser/web_transaction.rb
345
333
  homepage: http://www.github.com/newrelic/rpm
346
334
  licenses: []
347
-
348
- post_install_message: |
349
-
350
- PLEASE NOTE:
351
-
352
- Developer Mode is now a Rack middleware.
353
-
354
- Developer Mode is no longer available in Rails 2.1 and earlier.
355
- However, starting in version 2.12 you can use Developer Mode in any
356
- Rack based framework, in addition to Rails. To install developer mode
357
- in a non-Rails application, just add NewRelic::Rack::DeveloperMode to
358
- your middleware stack.
359
-
360
- If you are using JRuby, we recommend using at least version 1.4 or
361
- later because of issues with the implementation of the timeout library.
362
-
363
- Refer to the README.md file for more information.
364
-
365
- Please see http://github.com/newrelic/rpm/blob/master/CHANGELOG
366
- for a complete description of the features and enhancements available
367
- in version 3.3 of the Ruby Agent.
368
-
369
-
370
- rdoc_options:
335
+ post_install_message: ! "\nPLEASE NOTE:\n\nDeveloper Mode is now a Rack middleware.\n\nDeveloper
336
+ Mode is no longer available in Rails 2.1 and earlier.\nHowever, starting in version
337
+ 2.12 you can use Developer Mode in any\nRack based framework, in addition to Rails.
338
+ \ To install developer mode\nin a non-Rails application, just add NewRelic::Rack::DeveloperMode
339
+ to\nyour middleware stack.\n\nIf you are using JRuby, we recommend using at least
340
+ version 1.4 or \nlater because of issues with the implementation of the timeout
341
+ library.\n\nRefer to the README.md file for more information.\n\nPlease see http://github.com/newrelic/rpm/blob/master/CHANGELOG\nfor
342
+ a complete description of the features and enhancements available\nin version 3.3
343
+ of the Ruby Agent.\n \n"
344
+ rdoc_options:
371
345
  - --line-numbers
372
346
  - --inline-source
373
347
  - --title
374
348
  - New Relic Ruby Agent
375
- require_paths:
349
+ require_paths:
376
350
  - lib
377
- required_ruby_version: !ruby/object:Gem::Requirement
351
+ required_ruby_version: !ruby/object:Gem::Requirement
378
352
  none: false
379
- requirements:
380
- - - ">="
381
- - !ruby/object:Gem::Version
382
- hash: 3
383
- segments:
384
- - 0
385
- version: "0"
386
- required_rubygems_version: !ruby/object:Gem::Requirement
353
+ requirements:
354
+ - - ! '>='
355
+ - !ruby/object:Gem::Version
356
+ version: '0'
357
+ required_rubygems_version: !ruby/object:Gem::Requirement
387
358
  none: false
388
- requirements:
389
- - - ">="
390
- - !ruby/object:Gem::Version
391
- hash: 3
392
- segments:
393
- - 0
394
- version: "0"
359
+ requirements:
360
+ - - ! '>='
361
+ - !ruby/object:Gem::Version
362
+ version: '0'
395
363
  requirements: []
396
-
397
364
  rubyforge_project:
398
- rubygems_version: 1.8.11
365
+ rubygems_version: 1.8.10
399
366
  signing_key:
400
367
  specification_version: 3
401
368
  summary: New Relic Ruby Agent
402
369
  test_files: []
403
-
404
- has_rdoc:
@@ -1,118 +0,0 @@
1
- module NewRelic
2
- module Agent
3
- module Instrumentation
4
- module ActiveRecordInstrumentation
5
-
6
- def self.included(instrumented_class)
7
- instrumented_class.class_eval do
8
- alias_method :log_without_newrelic_instrumentation, :log
9
- alias_method :log, :log_with_newrelic_instrumentation
10
- protected :log
11
- end
12
- end
13
-
14
- def log_with_newrelic_instrumentation(sql, name, &block)
15
- return log_without_newrelic_instrumentation(sql, name, &block) unless NewRelic::Agent.is_execution_traced?
16
-
17
- if name && (parts = name.split " ") && parts.size == 2
18
- model = parts.first
19
- operation = parts.last.downcase
20
- metric_name = case operation
21
- when 'load' then 'find'
22
- when 'indexes', 'columns' then nil # fall back to DirectSQL
23
- when 'destroy', 'find', 'save', 'create' then operation
24
- when 'update' then 'save'
25
- else
26
- if model == 'Join'
27
- operation
28
- end
29
- end
30
- metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
31
- end
32
-
33
- if metric.nil?
34
- metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
35
- if metric.nil?
36
- if sql =~ /^(select|update|insert|delete|show)/i
37
- # Could not determine the model/operation so let's find a better
38
- # metric. If it doesn't match the regex, it's probably a show
39
- # command or some DDL which we'll ignore.
40
- metric = "Database/SQL/#{$1.downcase}"
41
- else
42
- metric = "Database/SQL/other"
43
- end
44
- end
45
- end
46
-
47
- if !metric
48
- log_without_newrelic_instrumentation(sql, name, &block)
49
- else
50
- metrics = [metric, "ActiveRecord/all"]
51
- metrics << "ActiveRecord/#{metric_name}" if metric_name
52
- if NewRelic::Agent::Database.config && NewRelic::Agent::Database.config[:adapter]
53
- type = NewRelic::Agent::Database.config[:adapter].sub(/\d*/, '')
54
- host = NewRelic::Agent::Database.config[:host] || 'localhost'
55
- metrics << "RemoteService/sql/#{type}/#{host}"
56
- end
57
-
58
- self.class.trace_execution_scoped(metrics) do
59
- t0 = Time.now
60
- begin
61
- log_without_newrelic_instrumentation(sql, name, &block)
62
- ensure
63
- elapsed_time = (Time.now - t0).to_f
64
- NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, NewRelic::Agent::Database.config,
65
- elapsed_time)
66
- NewRelic::Agent.instance.sql_sampler.notice_sql(sql, metric, NewRelic::Agent::Database.config,
67
- elapsed_time)
68
- end
69
- end
70
- end
71
- end
72
-
73
- end
74
- end
75
- end
76
- end
77
-
78
- DependencyDetection.defer do
79
- @name = :rails2_active_record
80
-
81
- depends_on do
82
- defined?(ActiveRecord) && defined?(ActiveRecord::Base)
83
- end
84
-
85
- depends_on do
86
- defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 2
87
- end
88
-
89
- depends_on do
90
- !NewRelic::Control.instance['skip_ar_instrumentation']
91
- end
92
-
93
- depends_on do
94
- !NewRelic::Control.instance['disable_activerecord_instrumentation']
95
- end
96
-
97
- executes do
98
- NewRelic::Agent.logger.debug 'Installing Rails 2 ActiveRecord instrumentation'
99
- end
100
-
101
- executes do
102
- ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
103
- include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
104
- end
105
- end
106
-
107
- executes do
108
- ActiveRecord::Base.class_eval do
109
- NewRelic::Agent::Database::ConnectionManager.instance.config = connection.instance_eval{ @config }
110
- class << self
111
- add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
112
- add_method_tracer :transaction, 'ActiveRecord/#{self.name}/transaction', :metric => false
113
- end
114
- end
115
- end
116
- end
117
-
118
- DependencyDetection.detect!
@@ -1,125 +0,0 @@
1
- module NewRelic
2
- module Agent
3
- module Instrumentation
4
- module ActiveRecordInstrumentation
5
-
6
- def self.included(instrumented_class)
7
- instrumented_class.class_eval do
8
- unless instrumented_class.method_defined?(:log_without_newrelic_instrumentation)
9
- alias_method :log_without_newrelic_instrumentation, :log
10
- alias_method :log, :log_with_newrelic_instrumentation
11
- protected :log
12
- end
13
- end
14
- end
15
-
16
- def log_with_newrelic_instrumentation(*args, &block)
17
-
18
- return log_without_newrelic_instrumentation(*args, &block) unless NewRelic::Agent.is_execution_traced?
19
-
20
- sql, name, binds = args
21
-
22
- if name && (parts = name.split " ") && parts.size == 2
23
- model = parts.first
24
- operation = parts.last.downcase
25
- metric_name = case operation
26
- when 'load', 'count', 'exists' then 'find'
27
- when 'indexes', 'columns' then nil # fall back to DirectSQL
28
- when 'destroy', 'find', 'save', 'create' then operation
29
- when 'update' then 'save'
30
- else
31
- if model == 'Join'
32
- operation
33
- end
34
- end
35
- metric = "ActiveRecord/#{model}/#{metric_name}" if metric_name
36
- end
37
-
38
- if metric.nil?
39
- metric = NewRelic::Agent::Instrumentation::MetricFrame.database_metric_name
40
- if metric.nil?
41
- if sql =~ /^(select|update|insert|delete|show)/i
42
- # Could not determine the model/operation so let's find a better
43
- # metric. If it doesn't match the regex, it's probably a show
44
- # command or some DDL which we'll ignore.
45
- metric = "Database/SQL/#{$1.downcase}"
46
- else
47
- metric = "Database/SQL/other"
48
- end
49
- end
50
- end
51
-
52
- if !metric
53
- log_without_newrelic_instrumentation(*args, &block)
54
- else
55
- metrics = [metric, "ActiveRecord/all"]
56
- metrics << "ActiveRecord/#{metric_name}" if metric_name
57
- if NewRelic::Agent::Database.config && NewRelic::Agent::Database.config[:adapter]
58
- type = NewRelic::Agent::Database.config[:adapter].sub(/\d*/, '')
59
- host = NewRelic::Agent::Database.config[:host] || 'localhost'
60
- metrics << "RemoteService/sql/#{type}/#{host}"
61
- end
62
-
63
- self.class.trace_execution_scoped(metrics) do
64
- sql, name, binds = args
65
- t0 = Time.now
66
- begin
67
- log_without_newrelic_instrumentation(*args, &block)
68
- ensure
69
- NewRelic::Agent.instance.transaction_sampler.notice_sql(sql, NewRelic::Agent::Database.config,
70
- (Time.now - t0).to_f)
71
- NewRelic::Agent.instance.sql_sampler.notice_sql(sql, metric, NewRelic::Agent::Database.config,
72
- (Time.now - t0).to_f)
73
- end
74
- end
75
- end
76
- end
77
-
78
- end
79
- end
80
- end
81
- end
82
-
83
- DependencyDetection.defer do
84
- @name = :rails3_active_record
85
-
86
- depends_on do
87
- defined?(ActiveRecord) && defined?(ActiveRecord::Base)
88
- end
89
-
90
- depends_on do
91
- defined?(::Rails) && ::Rails::VERSION::MAJOR.to_i == 3
92
- end
93
-
94
- depends_on do
95
- !NewRelic::Control.instance['skip_ar_instrumentation']
96
- end
97
-
98
- depends_on do
99
- !NewRelic::Control.instance['disable_activerecord_instrumentation']
100
- end
101
-
102
- executes do
103
- NewRelic::Agent.logger.debug 'Installing Rails 3 ActiveRecord instrumentation'
104
- end
105
-
106
- executes do
107
- Rails.configuration.after_initialize do
108
- ActiveRecord::ConnectionAdapters::AbstractAdapter.module_eval do
109
- include ::NewRelic::Agent::Instrumentation::ActiveRecordInstrumentation
110
- end
111
- end
112
- end
113
-
114
- executes do
115
- Rails.configuration.after_initialize do
116
- ActiveRecord::Base.class_eval do
117
- NewRelic::Agent::Database::ConnectionManager.instance.config = connection.instance_eval{ @config }
118
- class << self
119
- add_method_tracer :find_by_sql, 'ActiveRecord/#{self.name}/find_by_sql', :metric => false
120
- add_method_tracer :transaction, 'ActiveRecord/#{self.name}/transaction', :metric => false
121
- end
122
- end
123
- end
124
- end
125
- end