newrelic_rpm 3.2.0.beta2 → 3.2.0

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.

@@ -469,7 +469,7 @@ module NewRelic
469
469
  def check_sql_sampler_status
470
470
  # disable sql sampling if disabled by the server
471
471
  # and we're not in dev mode
472
- if @sql_sampler.config.fetch('enabled', true) && ['raw', 'obfuscated'].include?(@sql_sampler.config.fetch('record_sql', 'obfuscated').to_s)
472
+ if @sql_sampler.config.fetch('enabled', true) && ['raw', 'obfuscated'].include?(@sql_sampler.config.fetch('record_sql', 'obfuscated').to_s) && @transaction_sampler.config.fetch('enabled', true)
473
473
  @sql_sampler.enable
474
474
  else
475
475
  @sql_sampler.disable
@@ -758,13 +758,13 @@ module NewRelic
758
758
  # Reconfigure the transaction tracer
759
759
  @transaction_sampler.configure!
760
760
  @sql_sampler.configure!
761
- @should_send_samples = @config_should_send_samples = sampler_config.fetch('enabled', true)
762
- @should_send_random_samples = sampler_config.fetch('random_sample', false)
761
+ @should_send_samples = @config_should_send_samples = @transaction_sampler.config.fetch('enabled', true)
762
+ @should_send_random_samples = @transaction_sampler.config.fetch('random_sample', false)
763
763
  set_sql_recording!
764
764
 
765
765
  # default to 2.0, string 'apdex_f' will turn into your
766
766
  # apdex * 4
767
- @slowest_transaction_threshold = sampler_config.fetch('transaction_threshold', 2.0).to_f
767
+ @slowest_transaction_threshold = @transaction_sampler.config.fetch('transaction_threshold', 2.0).to_f
768
768
  @slowest_transaction_threshold = apdex_f if apdex_f_threshold?
769
769
  end
770
770
 
@@ -774,6 +774,9 @@ module NewRelic
774
774
  def configure_transaction_tracer!(server_enabled, sample_rate)
775
775
  # Ask the server for permission to send transaction samples.
776
776
  # determined by subscription license.
777
+ @transaction_sampler.config['enabled'] = server_enabled
778
+ @sql_sampler.disable unless @transaction_sampler.config['enabled']
779
+
777
780
  @should_send_samples = @config_should_send_samples && server_enabled
778
781
 
779
782
  if @should_send_samples
@@ -795,7 +798,7 @@ module NewRelic
795
798
  # transactions. This gears well with using apdex since you
796
799
  # will attempt to send any transactions that register as 'failing'
797
800
  def apdex_f_threshold?
798
- sampler_config.fetch('transaction_threshold', '') =~ /apdex_f/i
801
+ @transaction_sampler.config.fetch('transaction_threshold', '') =~ /apdex_f/i
799
802
  end
800
803
 
801
804
  # Sets the sql recording configuration by trying to detect
@@ -803,7 +806,7 @@ module NewRelic
803
806
  # 'false', 'none', and friends. Otherwise, we accept 'raw',
804
807
  # and unrecognized values default to 'obfuscated'
805
808
  def set_sql_recording!
806
- record_sql_config = sampler_config.fetch('record_sql', :obfuscated)
809
+ record_sql_config = @transaction_sampler.config.fetch('record_sql', :obfuscated)
807
810
  case record_sql_config.to_s
808
811
  when 'off'
809
812
  @record_sql = :off
@@ -826,11 +829,6 @@ module NewRelic
826
829
  log.warn("Agent is configured to send raw SQL to the service") if @record_sql == :raw
827
830
  end
828
831
 
829
- # gets the sampler configuration from the control object's settings
830
- def sampler_config
831
- NewRelic::Control.instance.fetch('transaction_tracer', {})
832
- end
833
-
834
832
  # Asks the collector to tell us which sub-collector we
835
833
  # should be reporting to, and then does the name resolution
836
834
  # on that host so we don't block on DNS during the normal
@@ -33,7 +33,6 @@ module NewRelic
33
33
  @explain_enabled = config.fetch('explain_enabled', true)
34
34
  @stack_trace_threshold = config.fetch('stack_trace_threshold',
35
35
  0.5).to_f
36
- # config.fetch('enabled', true) ? self.enable : self.disable
37
36
  end
38
37
 
39
38
  def config
@@ -45,16 +45,18 @@ module NewRelic
45
45
  # @segment_limit and @stack_trace_threshold come from the
46
46
  # configuration file, with built-in defaults that should
47
47
  # suffice for most customers
48
- config = NewRelic::Control.instance
49
- sampler_config = config.fetch('transaction_tracer', {})
50
48
 
51
- # enable if sampler_config.fetch('enabled', true)
49
+ # enable if config.fetch('enabled', true)
52
50
 
53
- @segment_limit = sampler_config.fetch('limit_segments', 4000)
54
- @stack_trace_threshold = sampler_config.fetch('stack_trace_threshold', 0.500).to_f
55
- @explain_threshold = sampler_config.fetch('explain_threshold', 0.5).to_f
56
- @explain_enabled = sampler_config.fetch('explain_enabled', true)
57
- @transaction_threshold = sampler_config.fetch('transation_threshold', 2.0)
51
+ @segment_limit = config.fetch('limit_segments', 4000)
52
+ @stack_trace_threshold = config.fetch('stack_trace_threshold', 0.500).to_f
53
+ @explain_threshold = config.fetch('explain_threshold', 0.5).to_f
54
+ @explain_enabled = config.fetch('explain_enabled', true)
55
+ @transaction_threshold = config.fetch('transation_threshold', 2.0)
56
+ end
57
+
58
+ def config
59
+ NewRelic::Control.instance.fetch('transaction_tracer', {})
58
60
  end
59
61
 
60
62
  # Returns the current sample id, delegated from `builder`
@@ -36,7 +36,7 @@ module NewRelic
36
36
  # Merge the given options into the config options.
37
37
  # They might be a nested hash
38
38
  def merge_options(options, hash=self)
39
- options.each do |key, val |
39
+ options.each do |key, val|
40
40
  case
41
41
  when key == :config then next
42
42
  when val.is_a?(Hash)
@@ -66,6 +66,7 @@ module NewRelic
66
66
 
67
67
  def remove_server_controlled_configs
68
68
  settings.delete('transaction_tracer')
69
+ settings.delete('slow_sql')
69
70
  settings.delete('error_collector')
70
71
  settings.delete('capture_params')
71
72
  end
@@ -67,7 +67,7 @@ module NewRelic
67
67
 
68
68
  def reset
69
69
  NewRelic::Agent.instance.transaction_sampler.reset!
70
- NewRelic::Agent.instance.sql_sampler.reset
70
+ NewRelic::Agent.instance.sql_sampler.reset!
71
71
  ::Rack::Response.new{|r| r.redirect('/newrelic/')}.finish
72
72
  end
73
73
 
@@ -4,7 +4,7 @@ module NewRelic
4
4
  MAJOR = 3
5
5
  MINOR = 2
6
6
  TINY = 0
7
- BUILD = 'beta2' #'0' # Set to nil for a release, 'beta1', 'alpha', etc for prerelease builds
7
+ BUILD = nil #'0' # 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
 
@@ -5,7 +5,7 @@
5
5
 
6
6
  Gem::Specification.new do |s|
7
7
  s.name = %q{newrelic_rpm}
8
- s.version = "3.2.0.beta2"
8
+ s.version = "3.2.0"
9
9
 
10
10
  s.required_rubygems_version = Gem::Requirement.new(">= 0") if s.respond_to? :required_rubygems_version=
11
11
  s.authors = [%q{Bill Kayser}, %q{Jon Guymon}, %q{Justin George}, %q{Darin Swanson}]
@@ -1,6 +1,8 @@
1
1
  require File.expand_path(File.join(File.dirname(__FILE__),'..', '..', '..','test_helper'))
2
2
  class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
3
3
  require 'new_relic/agent/agent'
4
+
5
+ # I don't like this, we should be testing a third party, not ourselves -Jon
4
6
  include NewRelic::Agent::Agent::Connect
5
7
 
6
8
  def setup
@@ -8,6 +10,8 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
8
10
  @keep_retrying = nil
9
11
  @connect_attempts = 1
10
12
  @connect_retry_period = 0
13
+ @transaction_sampler = NewRelic::Agent::TransactionSampler.new
14
+ @sql_sampler = NewRelic::Agent::SqlSampler.new
11
15
  end
12
16
 
13
17
  def test_tried_to_connect?
@@ -213,9 +217,6 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
213
217
  'explain_threshold' => 0.75,
214
218
  'explain_enabled' => true
215
219
  }
216
-
217
- @transaction_sampler = NewRelic::Agent::TransactionSampler.new
218
- @sql_sampler = NewRelic::Agent::SqlSampler.new
219
220
 
220
221
  config_transaction_tracer
221
222
 
@@ -263,45 +264,45 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
263
264
  end
264
265
 
265
266
  def test_apdex_f_threshold_positive
266
- self.expects(:sampler_config).returns({'transaction_threshold' => 'apdex_f'})
267
+ NewRelic::Control.instance.settings['transaction_tracer'] = { 'transaction_threshold' => 'apdex_f' }
267
268
  assert apdex_f_threshold?
268
269
  end
269
270
 
270
271
  def test_apdex_f_threshold_negative
271
- self.expects(:sampler_config).returns({'transaction_threshold' => 'WHEE'})
272
+ NewRelic::Control.instance.settings['transaction_tracer'] = { 'transaction_threshold' => 'WHEE' }
272
273
  assert !apdex_f_threshold?
273
274
  end
274
275
 
275
276
  def test_set_sql_recording_default
276
- self.expects(:sampler_config).returns({})
277
+ NewRelic::Control.instance.settings['transaction_tracer'] = { }
277
278
  self.expects(:log_sql_transmission_warning?)
278
279
  set_sql_recording!
279
280
  assert_equal :obfuscated, @record_sql, " should default to :obfuscated, was #{@record_sql}"
280
281
  end
281
282
 
282
283
  def test_set_sql_recording_off
283
- self.expects(:sampler_config).returns({'record_sql' => 'off'})
284
+ NewRelic::Control.instance.settings['transaction_tracer'] = {'record_sql' => 'off'}
284
285
  self.expects(:log_sql_transmission_warning?)
285
286
  set_sql_recording!
286
287
  assert_equal :off, @record_sql, "should be set to :off, was #{@record_sql}"
287
288
  end
288
289
 
289
290
  def test_set_sql_recording_none
290
- self.expects(:sampler_config).returns({'record_sql' => 'none'})
291
+ NewRelic::Control.instance.settings['transaction_tracer'] = {'record_sql' => 'none'}
291
292
  self.expects(:log_sql_transmission_warning?)
292
293
  set_sql_recording!
293
294
  assert_equal :off, @record_sql, "should be set to :off, was #{@record_sql}"
294
295
  end
295
296
 
296
297
  def test_set_sql_recording_raw
297
- self.expects(:sampler_config).returns({'record_sql' => 'raw'})
298
+ NewRelic::Control.instance.settings['transaction_tracer'] = {'record_sql' => 'raw'}
298
299
  self.expects(:log_sql_transmission_warning?)
299
300
  set_sql_recording!
300
301
  assert_equal :raw, @record_sql, "should be set to :raw, was #{@record_sql}"
301
302
  end
302
303
 
303
304
  def test_set_sql_recording_falsy
304
- self.expects(:sampler_config).returns({'record_sql' => false})
305
+ NewRelic::Control.instance.settings['transaction_tracer'] = {'record_sql' => false}
305
306
  self.expects(:log_sql_transmission_warning?)
306
307
  set_sql_recording!
307
308
  assert_equal :off, @record_sql, "should be set to :off, was #{@record_sql}"
@@ -321,11 +322,6 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
321
322
  log_sql_transmission_warning?
322
323
  end
323
324
 
324
- def test_sampler_config
325
- NewRelic::Control.instance.expects(:fetch).with('transaction_tracer', {})
326
- sampler_config
327
- end
328
-
329
325
  def test_set_collector_host_positive
330
326
  control = mocked_control
331
327
  self.expects(:invoke_remote).with(:get_redirect_host).returns('collector-deux.newrelic.com')
@@ -371,8 +367,9 @@ class NewRelic::Agent::Agent::ConnectTest < Test::Unit::TestCase
371
367
  self.expects(:log_connection!).with(config)
372
368
  self.expects(:configure_transaction_tracer!).with(true, 10)
373
369
  self.expects(:configure_error_collector!).with(true)
374
- @transaction_sampler = mock('transaction sampler', :configure! => true)
375
- @sql_sampler = mock('sql sampler', :configure! => true)
370
+ @transaction_sampler = stub('transaction sampler', :configure! => true,
371
+ :config => {})
372
+ @sql_sampler = stub('sql sampler', :configure! => true)
376
373
  finish_setup(config)
377
374
  assert_equal 'fishsticks', @agent_id
378
375
  assert_equal 'pasta sauce', @report_period
@@ -13,10 +13,10 @@ class NewRelic::ControlTest < Test::Unit::TestCase
13
13
  NewRelic::Agent.shutdown
14
14
  end
15
15
 
16
- # def test_cert_file_path
17
- # assert @control.cert_file_path
18
- # assert_equal File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'cert', 'cacert.pem')), @control.cert_file_path
19
- # end
16
+ def test_cert_file_path
17
+ assert @control.cert_file_path
18
+ assert_equal File.expand_path(File.join(File.dirname(__FILE__), '..', '..', 'cert', 'cacert.pem')), @control.cert_file_path
19
+ end
20
20
 
21
21
  # This test does not actually use the ruby agent in any way - it's
22
22
  # testing that the CA file we ship actually validates our server's
@@ -190,7 +190,7 @@ class NewRelic::ControlTest < Test::Unit::TestCase
190
190
  @control['developer_mode'] = true
191
191
  @control['monitor_mode'] = false
192
192
  end
193
-
193
+
194
194
  def test_sql_tracer_disabled
195
195
  forced_start(:slow_sql => { :enabled => false }, :monitor_mode => true)
196
196
  NewRelic::Agent::Agent.instance.check_sql_sampler_status
@@ -209,6 +209,32 @@ class NewRelic::ControlTest < Test::Unit::TestCase
209
209
  'sql tracer enabled when config calls for disabled')
210
210
  end
211
211
 
212
+ def test_sql_tracer_disabled_when_tt_disabled
213
+ forced_start(:transaction_tracer => { :enabled => false },
214
+ :slow_sql => { :enabled => true },
215
+ :developer_mode => false, :monitor_mode => true)
216
+ NewRelic::Agent::Agent.instance.check_sql_sampler_status
217
+
218
+ assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
219
+ 'sql enabled when transaction tracer disabled')
220
+
221
+ @control['developer_mode'] = true
222
+ @control['monitor_mode'] = false
223
+ end
224
+
225
+ def test_sql_tracer_disabled_when_tt_disabled_by_server
226
+ forced_start(:slow_sql => { :enabled => true },
227
+ :transaction_tracer => { :enabled => true },
228
+ :monitor_mode => true)
229
+ NewRelic::Agent::Agent.instance.check_sql_sampler_status
230
+ NewRelic::Agent::Agent.instance.finish_setup('collect_traces' => false)
231
+
232
+ assert(!NewRelic::Agent::Agent.instance.sql_sampler.enabled?,
233
+ 'sql enabled when tracing disabled by server')
234
+
235
+ @control['monitor_mode'] = false
236
+ end
237
+
212
238
  def test_merging_options
213
239
  NewRelic::Control.send :public, :merge_options
214
240
  @control.merge_options :api_port => 66, :transaction_tracer => { :explain_threshold => 2.0 }
metadata CHANGED
@@ -1,8 +1,8 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: newrelic_rpm
3
3
  version: !ruby/object:Gem::Version
4
- version: 3.2.0.beta2
5
- prerelease: 6
4
+ version: 3.2.0
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Bill Kayser
@@ -16,7 +16,7 @@ date: 2011-10-13 00:00:00.000000000Z
16
16
  dependencies:
17
17
  - !ruby/object:Gem::Dependency
18
18
  name: jeweler
19
- requirement: &2153262420 !ruby/object:Gem::Requirement
19
+ requirement: &2155893600 !ruby/object:Gem::Requirement
20
20
  none: false
21
21
  requirements:
22
22
  - - ! '>='
@@ -24,10 +24,10 @@ dependencies:
24
24
  version: '0'
25
25
  type: :development
26
26
  prerelease: false
27
- version_requirements: *2153262420
27
+ version_requirements: *2155893600
28
28
  - !ruby/object:Gem::Dependency
29
29
  name: mocha
30
- requirement: &2153261700 !ruby/object:Gem::Requirement
30
+ requirement: &2155892300 !ruby/object:Gem::Requirement
31
31
  none: false
32
32
  requirements:
33
33
  - - ! '>='
@@ -35,10 +35,10 @@ dependencies:
35
35
  version: '0'
36
36
  type: :development
37
37
  prerelease: false
38
- version_requirements: *2153261700
38
+ version_requirements: *2155892300
39
39
  - !ruby/object:Gem::Dependency
40
40
  name: shoulda
41
- requirement: &2153261000 !ruby/object:Gem::Requirement
41
+ requirement: &2155890120 !ruby/object:Gem::Requirement
42
42
  none: false
43
43
  requirements:
44
44
  - - ! '>='
@@ -46,7 +46,7 @@ dependencies:
46
46
  version: '0'
47
47
  type: :development
48
48
  prerelease: false
49
- version_requirements: *2153261000
49
+ version_requirements: *2155890120
50
50
  description: ! 'New Relic is a performance management system, developed by New Relic,
51
51
 
52
52
  Inc (http://www.newrelic.com). New Relic provides you with deep