newrelic_rpm 3.7.1.182 → 3.7.1.188

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
@@ -1,2 +1,2 @@
1
- Nw}7��{ .[`�]��T��C�\� �ް����>�"����Z�eQ �귅��/������$�s4BM@��d3*��%��w��[o}��B^��hz�O6
2
- Z����CV!C��j����� ��[@�W��K�+��l��7�� 7Ɯ_��RXMצ�Hx���s4[J��
1
+ �� �ڪb��f�� w+�;Q�ڇ0g� �Q�* �0T�hA(� ���9��Ohr��
2
+ )~��U�6�.g�V]�F�<�@!���{�1�Ug��k1�����͆c����[�5vgUH�:�L��WM��6������
data/CHANGELOG CHANGED
@@ -33,6 +33,12 @@
33
33
  calling through to the uninstrumented version of this method. This has been
34
34
  fixed in 3.7.1.182. Thanks to Yuki Miyauchi for the fix!
35
35
 
36
+ * Correct first reported metric timespan for forking dispatchers (3.7.1.188)
37
+
38
+ The first time a newly-forked process (in some configurations) reported metric
39
+ data, it would use the startup time of the parent process as the start time
40
+ for that metric data instead of its own start time. This has been fixed.
41
+
36
42
  ## v3.7.0 ##
37
43
 
38
44
  * Official Rubinius support (for Rubinius >= 2.2.1)
@@ -23,14 +23,13 @@ module NewRelic
23
23
  # 534: v2 (shows up in 2.1.0, our first tag)
24
24
 
25
25
  attr_accessor :request_timeout, :agent_id
26
- attr_reader :collector, :marshaller, :metric_id_cache, :last_metric_harvest_time
26
+ attr_reader :collector, :marshaller, :metric_id_cache
27
27
 
28
28
  def initialize(license_key=nil, collector=control.server)
29
29
  @license_key = license_key || Agent.config[:license_key]
30
30
  @collector = collector
31
31
  @request_timeout = Agent.config[:timeout]
32
32
  @metric_id_cache = {}
33
- @last_metric_harvest_time = Time.now
34
33
 
35
34
  @audit_logger = ::NewRelic::Agent::AuditLogger.new
36
35
  Agent.config.register_callback(:'audit_log.enabled') do |enabled|
@@ -88,6 +87,11 @@ module NewRelic
88
87
  metric_spec_hash['scope'])
89
88
  metric_id_cache[metric_spec] = metric_id
90
89
  end
90
+ rescue => e
91
+ # If we've gotten this far, we don't want this error to propagate and
92
+ # make this post appear to have been non-successful, which would trigger
93
+ # re-aggregation of the same metric data into the next post, so just log
94
+ NewRelic::Agent.logger.error("Failed to fill metric ID cache from response, error details follow ", e)
91
95
  end
92
96
 
93
97
  # The collector wants to recieve metric data in a format that's different
@@ -111,17 +115,17 @@ module NewRelic
111
115
  end
112
116
 
113
117
  def metric_data(stats_hash)
114
- harvest_time = stats_hash.harvested_at || Time.now
118
+ timeslice_start = stats_hash.started_at
119
+ timeslice_end = stats_hash.harvested_at || Time.now
115
120
  metric_data_array = build_metric_data_array(stats_hash)
116
121
  result = invoke_remote(
117
122
  :metric_data,
118
123
  @agent_id,
119
- @last_metric_harvest_time.to_f,
120
- harvest_time.to_f,
124
+ timeslice_start.to_f,
125
+ timeslice_end.to_f,
121
126
  metric_data_array
122
127
  )
123
128
  fill_metric_id_cache(result)
124
- @last_metric_harvest_time = harvest_time
125
129
  result
126
130
  end
127
131
 
@@ -145,7 +145,7 @@ module NewRelic
145
145
  end
146
146
 
147
147
  def apply_rules_to_metric_data(rules_engine, stats_hash)
148
- renamed_stats = NewRelic::Agent::StatsHash.new
148
+ renamed_stats = NewRelic::Agent::StatsHash.new(stats_hash.started_at)
149
149
  stats_hash.each do |spec, stats|
150
150
  new_name = rules_engine.rename(spec.name)
151
151
  new_spec = NewRelic::MetricSpec.new(new_name, spec.scope)
@@ -18,18 +18,20 @@ require 'new_relic/agent/internal_agent_error'
18
18
  module NewRelic
19
19
  module Agent
20
20
  class StatsHash < ::Hash
21
- attr_accessor :harvested_at
21
+ attr_accessor :started_at, :harvested_at
22
22
 
23
- def initialize
24
- super { |hash, key| hash[key] = NewRelic::Agent::Stats.new }
23
+ def initialize(started_at=Time.now)
24
+ @started_at = started_at
25
+ super() { |hash, key| hash[key] = NewRelic::Agent::Stats.new }
25
26
  end
26
27
 
27
28
  def marshal_dump
28
- Hash[self]
29
+ [@started_at, Hash[self]]
29
30
  end
30
31
 
31
- def marshal_load(hash)
32
- self.merge!(hash)
32
+ def marshal_load(data)
33
+ @started_at = data.shift
34
+ self.merge!(data.shift)
33
35
  end
34
36
 
35
37
  def ==(other)
@@ -86,6 +88,9 @@ module NewRelic
86
88
  end
87
89
 
88
90
  def merge!(other)
91
+ if other.is_a?(StatsHash) && other.started_at < @started_at
92
+ @started_at = other.started_at
93
+ end
89
94
  other.each do |key,val|
90
95
  begin
91
96
  if self.has_key?(key)
@@ -43,9 +43,12 @@ module Environments
43
43
  Bundler.with_clean_env do
44
44
  dir = File.expand_path(dir)
45
45
  puts "", yellow("Running tests for #{dir}")
46
- bundle(dir)
47
- create_database(dir)
48
- status = run(dir)
46
+ status = bundle(dir)
47
+ if status.success?
48
+ create_database(dir)
49
+ status = run(dir)
50
+ end
51
+
49
52
  if !status.success?
50
53
  overall_status += 1
51
54
  failures << dir
@@ -99,6 +102,7 @@ module Environments
99
102
 
100
103
  bundling = red(bundling) unless $?.success?
101
104
  puts bundling
105
+ $?
102
106
  end
103
107
 
104
108
  # Would be nice to get our unit tests decoupled from the actual DB, but
@@ -1,4 +1,4 @@
1
- source 'http://rubygems.org'
1
+ source 'https://rubygems.org'
2
2
 
3
3
  gem 'rake'
4
4
 
@@ -9,7 +9,7 @@ gem 'rack-test'
9
9
  platforms :rbx do
10
10
  gem "rubysl"
11
11
  gem "rubysl-test-unit"
12
- gem "rubysl-json"
12
+ gem "json"
13
13
  gem "psych"
14
14
  gem "racc" # https://github.com/rubinius/rubinius/issues/2632
15
15
  end
@@ -22,7 +22,7 @@ end
22
22
 
23
23
  platforms :rbx do
24
24
  gem "rubysl"
25
- gem "rubysl-json"
25
+ gem "json"
26
26
  # If we don't skip the require here, test-unit tries to install its at_exit
27
27
  # hook and run when we run our rake task to create the test DB.
28
28
  gem "rubysl-test-unit", :require => false
@@ -107,7 +107,7 @@ module Multiverse
107
107
  return unless is_rbx?
108
108
 
109
109
  f.puts "gem 'rubysl', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .rubysl./
110
- f.puts "gem 'rubysl-json', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .rubysl-json./
110
+ f.puts "gem 'json', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .json./
111
111
  f.puts "gem 'racc', :platforms => [:rbx]" unless gemfile_text =~ /^\s*gem .racc./
112
112
  end
113
113
 
@@ -0,0 +1,76 @@
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 'newrelic_rpm'
6
+ require 'multiverse_helpers'
7
+
8
+ class HarvestTimestampsTest < MiniTest::Unit::TestCase
9
+ include MultiverseHelpers
10
+
11
+ setup_and_teardown_agent
12
+
13
+ def test_resets_metric_data_timestamps_after_forking
14
+ t0 = freeze_time
15
+
16
+ t1 = advance_time 10
17
+ NewRelic::Agent.after_fork
18
+
19
+ t2 = advance_time 10
20
+ trigger_metric_data_post
21
+
22
+ metric_data_post = $collector.calls_for('metric_data').first
23
+ start_ts, end_ts = metric_data_post[1..2]
24
+
25
+ assert_equal(t1.to_f, start_ts)
26
+ assert_equal(t2.to_f, end_ts)
27
+ end
28
+
29
+ def test_start_timestamp_maintained_on_harvest_failure
30
+ t0 = freeze_time.to_f
31
+
32
+ NewRelic::Agent.after_fork
33
+
34
+ $collector.stub('metric_data', {}, 503)
35
+ t1 = advance_time(10).to_f
36
+ trigger_metric_data_post
37
+ first_post = last_metric_data_post
38
+
39
+ $collector.reset
40
+ t2 = advance_time(10).to_f
41
+ trigger_metric_data_post
42
+ second_post = last_metric_data_post
43
+
44
+ assert_equal([t0, t1], first_post[1..2])
45
+ assert_equal([t0, t2], second_post[1..2])
46
+ end
47
+
48
+ def test_timestamps_updated_even_if_filling_metric_id_cache_fails
49
+ t0 = freeze_time.to_f
50
+
51
+ NewRelic::Agent.after_fork
52
+
53
+ # Induce a failure in filling the metric ID cache by handing back a bogus
54
+ # response to the first metric_data post.
55
+ $collector.stub('metric_data', [[[[]]]], 200)
56
+ t1 = advance_time(10).to_f
57
+ trigger_metric_data_post
58
+ first_post = last_metric_data_post
59
+
60
+ $collector.reset
61
+ t2 = advance_time(10).to_f
62
+ trigger_metric_data_post
63
+ second_post = last_metric_data_post
64
+
65
+ assert_equal([t0, t1], first_post[1..2])
66
+ assert_equal([t1, t2], second_post[1..2])
67
+ end
68
+
69
+ def trigger_metric_data_post
70
+ NewRelic::Agent.agent.send(:transmit_data)
71
+ end
72
+
73
+ def last_metric_data_post
74
+ $collector.calls_for('metric_data').last
75
+ end
76
+ end
@@ -7,6 +7,7 @@
7
7
 
8
8
  if RUBY_VERSION >= '1.9'
9
9
 
10
+ require 'thread'
10
11
  require 'multiverse_helpers'
11
12
 
12
13
  class ThreadProfilingTest < MiniTest::Unit::TestCase
@@ -60,11 +61,11 @@ class ThreadProfilingTest < MiniTest::Unit::TestCase
60
61
  # go only let a few cycles through, so we check less than 10
61
62
 
62
63
  def test_thread_profiling
63
- issue_command(START_COMMAND)
64
-
65
64
  run_thread { NewRelic::Agent::Transaction.start(:controller, :request => stub) }
66
65
  run_thread { NewRelic::Agent::Transaction.start(:task) }
67
66
 
67
+ issue_command(START_COMMAND)
68
+
68
69
  let_it_finish
69
70
 
70
71
  profile_data = $collector.calls_for('profile_data')[0]
@@ -79,11 +80,11 @@ class ThreadProfilingTest < MiniTest::Unit::TestCase
79
80
 
80
81
  def test_thread_profiling_with_pruby_marshaller
81
82
  with_config(:marshaller => 'pruby') do
82
- issue_command(START_COMMAND)
83
-
84
83
  run_thread { NewRelic::Agent::Transaction.start(:controller, :request => stub) }
85
84
  run_thread { NewRelic::Agent::Transaction.start(:task) }
86
85
 
86
+ issue_command(START_COMMAND)
87
+
87
88
  let_it_finish
88
89
  end
89
90
 
@@ -118,15 +119,29 @@ class ThreadProfilingTest < MiniTest::Unit::TestCase
118
119
 
119
120
  # Runs a thread we expect to span entire test and be killed at the end
120
121
  def run_thread
121
- Thread.new do
122
+ q = Queue.new
123
+ @threads ||= []
124
+ @threads << Thread.new do
122
125
  yield
123
- sleep(10)
126
+ q.push('.')
127
+ sleep # sleep until explicitly woken in join_background_threads
124
128
  end
129
+ q.pop # block until the thread has had a chance to start up
125
130
  end
126
131
 
127
132
  def let_it_finish
128
133
  wait_for_backtrace_service_poll(:timeout => 10.0, :iterations => 10)
129
134
  harvest
135
+ join_background_threads
136
+ end
137
+
138
+ def join_background_threads
139
+ if @threads
140
+ @threads.each do |thread|
141
+ thread.run
142
+ thread.join
143
+ end
144
+ end
130
145
  end
131
146
 
132
147
  def harvest
@@ -5,15 +5,11 @@ end
5
5
  gemfile <<-RB
6
6
  gem 'curb', '0.8.1'
7
7
  gem 'rack'
8
- if RUBY_VERSION < '1.9.0'
9
- gem 'json'
10
- end
8
+ gem 'json', :platforms => [:rbx, :mri_18]
11
9
  RB
12
10
 
13
11
  gemfile <<-RB
14
12
  gem 'curb', '~> 0.8.4'
15
13
  gem 'rack'
16
- if RUBY_VERSION < '1.9.0'
17
- gem 'json'
18
- end
14
+ gem 'json', :platforms => [:rbx, :mri_18]
19
15
  RB
@@ -5,7 +5,7 @@ end
5
5
  omit_collector!
6
6
 
7
7
  gemfile <<-RB
8
+ gem 'json', '>= 1.8.1'
8
9
  gem 'datamapper'
9
10
  gem 'dm-sqlite-adapter'
10
11
  RB
11
-
@@ -8,8 +8,6 @@ excon_versions.each do |excon_version|
8
8
  gemfile <<-RB
9
9
  gem 'excon', '~> #{excon_version}'
10
10
  gem 'rack'
11
- if RUBY_VERSION < '1.9.0'
12
- gem 'json'
13
- end
11
+ gem 'json', :platforms => [:rbx, :mri_18]
14
12
  RB
15
13
  end
@@ -8,8 +8,6 @@ httpclient_versions.each do |httpclient_version|
8
8
  gemfile <<-RB
9
9
  gem 'httpclient', '~> #{httpclient_version}'
10
10
  gem 'rack'
11
- if RUBY_VERSION < '1.9.0'
12
- gem 'json'
13
- end
11
+ gem 'json', :platforms => [:rbx, :mri_18]
14
12
  RB
15
13
  end
@@ -1,6 +1,4 @@
1
1
  gemfile <<-RB
2
2
  gem 'rack'
3
- if RUBY_VERSION < '1.9.0'
4
- gem 'json'
5
- end
3
+ gem 'json', :platforms => [:rbx, :mri_18]
6
4
  RB
@@ -12,9 +12,7 @@ end
12
12
  gemfile <<-RB
13
13
  gem 'typhoeus', '~> 0.6.3'
14
14
  gem 'rack'
15
- if RUBY_VERSION < '1.9.0'
16
- gem 'json'
17
- end
15
+ gem 'json', :platforms => [:rbx, :mri_18]
18
16
  RB
19
17
 
20
18
  gemfile <<-RB
@@ -23,9 +21,7 @@ gemfile <<-RB
23
21
 
24
22
  gem 'typhoeus', '~> 0.5.4'
25
23
  gem 'rack'
26
- if RUBY_VERSION < '1.9.0'
27
- gem 'json'
28
- end
24
+ gem 'json', :platforms => [:rbx, :mri_18]
29
25
  RB
30
26
 
31
27
  # Earliest supported version
@@ -35,9 +31,7 @@ gemfile <<-RB
35
31
 
36
32
  gem 'typhoeus', '0.5.3'
37
33
  gem 'rack'
38
- if RUBY_VERSION < '1.9.0'
39
- gem 'json'
40
- end
34
+ gem 'json', :platforms => [:rbx, :mri_18]
41
35
  RB
42
36
 
43
37
  # Prior to supported versions
@@ -47,7 +41,5 @@ gemfile <<-RB
47
41
 
48
42
  gem 'typhoeus', '0.5.2'
49
43
  gem 'rack'
50
- if RUBY_VERSION < '1.9.0'
51
- gem 'json'
52
- end
44
+ gem 'json', :platforms => [:rbx, :mri_18]
53
45
  RB
@@ -252,20 +252,20 @@ class NewRelicServiceTest < Test::Unit::TestCase
252
252
  assert_equal(42, results.first.metric_id)
253
253
  end
254
254
 
255
- def test_metric_data_tracks_last_harvest_time
255
+ def test_metric_data_harvest_time_based_on_stats_hash_creation
256
256
  t0 = freeze_time
257
+ dummy_rsp = 'met rick date uhh'
258
+ @http_handle.respond_to(:metric_data, dummy_rsp)
257
259
 
258
- @http_handle.respond_to(:metric_data, [])
260
+ advance_time 10
261
+ stats_hash = NewRelic::Agent::StatsHash.new
262
+ advance_time 1
263
+ stats_hash.harvested_at = Time.now
259
264
 
260
- hash = build_stats_hash('a' => 1)
261
- advance_time(1)
262
- @service.metric_data(hash)
263
- assert_equal(t0, @service.last_metric_harvest_time)
265
+ @service.metric_data(stats_hash)
264
266
 
265
- t1 = advance_time(60)
266
- hash = build_stats_hash('a' => 1)
267
- @service.metric_data(hash)
268
- assert_equal(t1, @service.last_metric_harvest_time)
267
+ timeslice_start = @http_handle.last_request_payload[1]
268
+ assert timeslice_start >= t0.to_f + 10
269
269
  end
270
270
 
271
271
  def test_error_data
@@ -109,11 +109,23 @@ class NewRelic::Agent::StatsHashTest < Test::Unit::TestCase
109
109
  assert_equal(1, hash1[specs[3]].call_count)
110
110
  end
111
111
 
112
+ def test_merge_re_sets_started_at_if_needed
113
+ t0 = Time.at(0)
114
+ t1 = Time.at(100)
115
+
116
+ hash0 = NewRelic::Agent::StatsHash.new(t0)
117
+ hash1 = NewRelic::Agent::StatsHash.new(t1)
118
+
119
+ hash1.merge!(hash0)
120
+ assert_equal(t0, hash1.started_at)
121
+ end
122
+
112
123
  def test_marshal_dump
113
124
  @hash.record('foo', 1)
114
125
  @hash.record('bar', 2)
115
126
  copy = Marshal.load(Marshal.dump(@hash))
116
127
  assert_equal(@hash, copy)
128
+ assert_equal(@hash.started_at, copy.started_at)
117
129
  end
118
130
 
119
131
  def test_borked_default_proc_can_record_metric
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: 3.7.1.182
4
+ version: 3.7.1.188
5
5
  prerelease:
6
6
  platform: ruby
7
7
  authors:
@@ -40,7 +40,7 @@ cert_chain:
40
40
  cHUySWFQWE92bTNUOEc0TzZxWnZobkxoL1VpZW4rK0RqOGVGQmVjVFBvTThw
41
41
  VmpLM3BoNQpuL0V3dVpDY0U2Z2h0Q0NNCi0tLS0tRU5EIENFUlRJRklDQVRF
42
42
  LS0tLS0K
43
- date: 2013-12-31 00:00:00.000000000 Z
43
+ date: 2014-01-20 00:00:00.000000000 Z
44
44
  dependencies:
45
45
  - !ruby/object:Gem::Dependency
46
46
  name: rake
@@ -586,6 +586,7 @@ files:
586
586
  - test/multiverse/suites/agent_only/collector_exception_handling_test.rb
587
587
  - test/multiverse/suites/agent_only/config/newrelic.yml
588
588
  - test/multiverse/suites/agent_only/cross_application_tracing_test.rb
589
+ - test/multiverse/suites/agent_only/harvest_timestamps_test.rb
589
590
  - test/multiverse/suites/agent_only/http_response_code_test.rb
590
591
  - test/multiverse/suites/agent_only/key_transactions_test.rb
591
592
  - test/multiverse/suites/agent_only/logging_test.rb
@@ -988,7 +989,11 @@ post_install_message: ! "# New Relic Ruby Agent Release Notes #\n\n## v3.7.1 ##\
988
989
  now be more accurate.\n\n* Fix for Mongo ensure_index instrumentation (3.7.1.182)\n\n
989
990
  \ The Mongo instrumentation for ensure_index in 3.7.1.180 was not properly\n calling
990
991
  through to the uninstrumented version of this method. This has been\n fixed in
991
- 3.7.1.182. Thanks to Yuki Miyauchi for the fix!\n\nSee https://github.com/newrelic/rpm/blob/master/CHANGELOG
992
+ 3.7.1.182. Thanks to Yuki Miyauchi for the fix!\n\n* Correct first reported metric
993
+ timespan for forking dispatchers (3.7.1.188)\n\n The first time a newly-forked
994
+ process (in some configurations) reported metric\n data, it would use the startup
995
+ time of the parent process as the start time\n for that metric data instead of
996
+ its own start time. This has been fixed.\n\nSee https://github.com/newrelic/rpm/blob/master/CHANGELOG
992
997
  for a full list of\nchanges.\n"
993
998
  rdoc_options:
994
999
  - --line-numbers
metadata.gz.sig CHANGED
Binary file