newrelic_rpm 3.6.2.90.beta → 3.6.2.96

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
data/CHANGELOG CHANGED
@@ -10,6 +10,11 @@
10
10
  recording slow SQL calls. See https://newrelic.com/docs/ruby/sequel-instrumentation
11
11
  for full details.
12
12
 
13
+ * Thread profiling fix
14
+
15
+ The prior release of the agent (version 3.6.1) broke thread profiling. A
16
+ profile would appear to run, but return no data. This has been fixed.
17
+
13
18
  * Fix for over-counted Net::HTTP calls
14
19
 
15
20
  Under some circumstances, calls into Net::HTTP were being counted twice in
@@ -28,20 +28,25 @@ module NewRelic
28
28
  # the user's subscription level precludes its use. The server is the
29
29
  # ultimate authority regarding subscription levels, so we expect it to
30
30
  # do the real enforcement there.
31
- def apply_feature_gates(hash, existing_config)
31
+ def apply_feature_gates(server_config, existing_config)
32
32
  gated_features = {
33
33
  :'transaction_tracer.enabled' => 'collect_traces',
34
34
  :'slow_sql.enabled' => 'collect_traces',
35
35
  :'error_collector.enabled' => 'collect_errors'
36
36
  }
37
37
  gated_features.each do |feature, gate_key|
38
- unless hash[gate_key].nil?
39
- existing_value = existing_config[feature]
40
- allowed_by_server = hash[gate_key]
41
- hash[feature] = (allowed_by_server && existing_value)
38
+ if server_config.has_key?(gate_key)
39
+ allowed_by_server = server_config[gate_key]
40
+ requested_value = ungated_value(feature, existing_config)
41
+ effective_value = (allowed_by_server && requested_value)
42
+ server_config[feature] = effective_value
42
43
  end
43
44
  end
44
45
  end
46
+
47
+ def ungated_value(key, existing_config)
48
+ self.has_key?(key) ? self[key] : existing_config[key]
49
+ end
45
50
  end
46
51
  end
47
52
  end
@@ -74,15 +74,13 @@ module NewRelic
74
74
  end
75
75
 
76
76
  # Helper method for timing supportability metrics
77
- def record_supportability_metrics_timed(metrics)
77
+ def record_supportability_metrics_timed(metric)
78
78
  start_time = Time.now
79
79
  yield
80
80
  end_time = Time.now
81
81
  duration = (end_time - start_time).to_f
82
82
  ensure
83
- record_metrics(metrics) do |stat|
84
- stat.record_data_point(duration)
85
- end
83
+ ::NewRelic::Agent.record_metric(metric, duration)
86
84
  end
87
85
 
88
86
  # Helper for recording a straight value into the count
@@ -15,8 +15,9 @@ module NewRelic
15
15
  def self.bucket_thread(thread, profile_agent_code)
16
16
  if thread.key?(:newrelic_label)
17
17
  return profile_agent_code ? :agent : :ignore
18
- elsif !thread[:newrelic_transaction].nil?
19
- thread[:newrelic_transaction].request.nil? ? :background : :request
18
+ elsif thread[:newrelic_transaction].respond_to?(:last) &&
19
+ thread[:newrelic_transaction].last
20
+ thread[:newrelic_transaction].last.request.nil? ? :background : :request
20
21
  else
21
22
  :other
22
23
  end
@@ -21,10 +21,14 @@ class ThreadProfilingTest < Test::Unit::TestCase
21
21
 
22
22
  @agent = NewRelic::Agent.instance
23
23
  @thread_profiler = @agent.thread_profiler
24
+ @threads = []
24
25
  end
25
26
 
26
27
  def teardown
27
28
  $collector.reset
29
+
30
+ @threads.each { |t| t.kill }
31
+ @threads = nil
28
32
  end
29
33
 
30
34
  START_COMMAND = [[666,{
@@ -35,7 +39,7 @@ class ThreadProfilingTest < Test::Unit::TestCase
35
39
  "duration" => 0.5,
36
40
  "only_runnable_threads" => false,
37
41
  "only_request_threads" => false,
38
- "profile_agent_code" => false
42
+ "profile_agent_code" => true
39
43
  }
40
44
  }]]
41
45
 
@@ -57,13 +61,20 @@ class ThreadProfilingTest < Test::Unit::TestCase
57
61
  def test_thread_profiling
58
62
  @agent.send(:check_for_agent_commands)
59
63
 
64
+ run_thread { NewRelic::Agent::Transaction.start(:controller, :request => stub) }
65
+ run_thread { NewRelic::Agent::Transaction.start(:task) }
66
+
60
67
  let_it_finish
61
68
 
62
69
  profile_data = $collector.calls_for('profile_data')[0]
63
70
  assert_equal('666', profile_data.run_id)
64
71
 
65
- poll_count = profile_data[1][0][3]
66
- assert poll_count > 25, "Expected poll_count > 25, but was #{poll_count}"
72
+ assert profile_data.poll_count > 25, "Expected poll_count > 25, but was #{profile_data.poll_count}"
73
+
74
+ assert_saw_traces(profile_data, "OTHER")
75
+ assert_saw_traces(profile_data, "AGENT")
76
+ assert_saw_traces(profile_data, "REQUEST")
77
+ assert_saw_traces(profile_data, "BACKGROUND")
67
78
  end
68
79
 
69
80
  def test_thread_profiling_can_stop
@@ -77,10 +88,16 @@ class ThreadProfilingTest < Test::Unit::TestCase
77
88
  profile_data = $collector.calls_for('profile_data')[0]
78
89
  assert_equal('666', profile_data.run_id)
79
90
 
80
- poll_count = profile_data[1][0][3]
81
- assert poll_count < 10, "Expected poll_count < 10, but was #{poll_count}"
91
+ assert profile_data.poll_count < 10, "Expected poll_count < 10, but was #{profile_data.poll_count}"
82
92
  end
83
93
 
94
+ # Runs a thread we expect to span entire test and be killed at the end
95
+ def run_thread
96
+ Thread.new do
97
+ yield
98
+ sleep(10)
99
+ end
100
+ end
84
101
 
85
102
  def let_it_finish
86
103
  Timeout.timeout(5) do
@@ -91,6 +108,11 @@ class ThreadProfilingTest < Test::Unit::TestCase
91
108
 
92
109
  NewRelic::Agent.shutdown
93
110
  end
111
+
112
+ def assert_saw_traces(profile_data, type)
113
+ assert !profile_data.traces[type].empty?, "Missing #{type} traces"
114
+ end
115
+
94
116
  end
95
117
  end
96
118
 
@@ -98,5 +98,40 @@ module NewRelic::Agent::Configuration
98
98
  assert !@source[:'slow_sql.enabled']
99
99
  assert !@source[:'transaction_tracer.enabled']
100
100
  end
101
+
102
+ def test_should_enable_gated_features_when_server_says_yes_and_existing_says_no
103
+ rsp = {
104
+ 'collect_errors' => true,
105
+ 'collect_traces' => true,
106
+ 'agent_config' => {
107
+ 'transaction_tracer.enabled' => true,
108
+ 'slow_sql.enabled' => true,
109
+ 'error_collector.enabled' => true
110
+ }
111
+ }
112
+ existing_config = {
113
+ :'error_collector.enabled' => false,
114
+ :'slow_sql.enabled' => false,
115
+ :'transaction_tracer.enabled' => false
116
+ }
117
+ @source = ServerSource.new(rsp, existing_config)
118
+ assert @source[:'error_collector.enabled']
119
+ assert @source[:'slow_sql.enabled']
120
+ assert @source[:'transaction_tracer.enabled']
121
+ end
122
+
123
+ def test_should_not_gate_when_gating_keys_absent
124
+ rsp = {
125
+ 'agent_config' => {
126
+ 'transaction_tracer.enabled' => true,
127
+ 'slow_sql.enabled' => true,
128
+ 'error_collector.enabled' => true
129
+ }
130
+ }
131
+ @source = ServerSource.new(rsp, {})
132
+ assert @source[:'error_collector.enabled']
133
+ assert @source[:'slow_sql.enabled']
134
+ assert @source[:'transaction_tracer.enabled']
135
+ end
101
136
  end
102
137
  end
@@ -26,7 +26,7 @@ class ThreadTest < Test::Unit::TestCase
26
26
  t = ::Thread.new {}
27
27
  txn = NewRelic::Agent::Transaction.new
28
28
  txn.request = "has a request"
29
- t[:newrelic_transaction] = txn
29
+ t[:newrelic_transaction] = [txn]
30
30
 
31
31
  assert_equal :request, NewRelic::Agent::AgentThread.bucket_thread(t, DONT_CARE)
32
32
  end
@@ -34,14 +34,14 @@ class ThreadTest < Test::Unit::TestCase
34
34
  def test_bucket_thread_as_background
35
35
  t = ::Thread.new {}
36
36
  txn = NewRelic::Agent::Transaction.new
37
- t[:newrelic_transaction] = txn
37
+ t[:newrelic_transaction] = [txn]
38
38
 
39
39
  assert_equal :background, NewRelic::Agent::AgentThread.bucket_thread(t, DONT_CARE)
40
40
  end
41
41
 
42
42
  def test_bucket_thread_as_other_if_nil_txn
43
43
  t = ::Thread.new {}
44
- t[:newrelic_transaction] = nil
44
+ t[:newrelic_transaction] = []
45
45
 
46
46
  assert_equal :other, NewRelic::Agent::AgentThread.bucket_thread(t, DONT_CARE)
47
47
  end
@@ -218,9 +218,12 @@ module NewRelic
218
218
  end
219
219
 
220
220
  class ProfileDataPost < AgentPost
221
+ attr_accessor :poll_count, :traces
221
222
  def initialize(opts={})
222
223
  super
224
+ @poll_count = @body[1][0][3]
223
225
  @body[1][0][4] = unblob(@body[1][0][4]) if @format == :json
226
+ @traces = @body[1][0][4]
224
227
  end
225
228
  end
226
229
 
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.6.2.90.beta
5
- prerelease: 9
4
+ version: 3.6.2.96
5
+ prerelease:
6
6
  platform: ruby
7
7
  authors:
8
8
  - Jason Clark
@@ -41,7 +41,7 @@ cert_chain:
41
41
  cHUySWFQWE92bTNUOEc0TzZxWnZobkxoL1VpZW4rK0RqOGVGQmVjVFBvTThw
42
42
  VmpLM3BoNQpuL0V3dVpDY0U2Z2h0Q0NNCi0tLS0tRU5EIENFUlRJRklDQVRF
43
43
  LS0tLS0K
44
- date: 2013-05-06 00:00:00.000000000 Z
44
+ date: 2013-05-09 00:00:00.000000000 Z
45
45
  dependencies: []
46
46
  description: ! 'New Relic is a performance management system, developed by New Relic,
47
47
 
@@ -516,13 +516,15 @@ post_install_message: ! "\n# New Relic Ruby Agent Release Notes #\n\n## v3.6.2 #
516
516
  Sequel support\n\n The Ruby agent now supports Sequel, a database toolkit for Ruby.
517
517
  This\n includes capturing SQL calls and model operations in transaction traces,
518
518
  and\n recording slow SQL calls. See https://newrelic.com/docs/ruby/sequel-instrumentation\n
519
- \ for full details.\n\n* Fix for over-counted Net::HTTP calls\n\n Under some circumstances,
520
- calls into Net::HTTP were being counted twice in\n metrics and transaction traces.
521
- This has been fixed.\n\n* Missing traced errors for Resque applications\n\n Traced
522
- errors weren't displaying for some Resque workers, although the errors\n were factored
523
- into the overall count graphs. This has been fixed, and traced\n errors should
524
- be available again after upgrading the agent.\n\nSee https://github.com/newrelic/rpm/blob/master/CHANGELOG
525
- for a full list of\nchanges.\n"
519
+ \ for full details.\n\n* Thread profiling fix\n\n The prior release of the agent
520
+ (version 3.6.1) broke thread profiling. A\n profile would appear to run, but return
521
+ no data. This has been fixed.\n\n* Fix for over-counted Net::HTTP calls\n\n Under
522
+ some circumstances, calls into Net::HTTP were being counted twice in\n metrics
523
+ and transaction traces. This has been fixed.\n\n* Missing traced errors for Resque
524
+ applications\n\n Traced errors weren't displaying for some Resque workers, although
525
+ the errors\n were factored into the overall count graphs. This has been fixed,
526
+ and traced\n errors should be available again after upgrading the agent.\n\nSee
527
+ https://github.com/newrelic/rpm/blob/master/CHANGELOG for a full list of\nchanges.\n"
526
528
  rdoc_options:
527
529
  - --line-numbers
528
530
  - --inline-source
metadata.gz.sig CHANGED
Binary file