newrelic_rpm 3.5.7.57.beta → 3.5.7.58.beta
Sign up to get free protection for your applications and to get access to all the features.
- data.tar.gz.sig +0 -0
- data/lib/new_relic/agent/instrumentation/controller_instrumentation.rb +1 -1
- data/lib/new_relic/agent/instrumentation/queue_time.rb +9 -2
- data/test/new_relic/agent/instrumentation/controller_instrumentation_test.rb +4 -5
- data/test/new_relic/agent/instrumentation/queue_time_test.rb +7 -0
- metadata +2 -2
- metadata.gz.sig +0 -0
data.tar.gz.sig
CHANGED
Binary file
|
@@ -443,7 +443,7 @@ module NewRelic
|
|
443
443
|
# for the start time is found.
|
444
444
|
def _detect_upstream_wait(now)
|
445
445
|
if newrelic_request_headers
|
446
|
-
queue_start = QueueTime.parse_frontend_timestamp(newrelic_request_headers)
|
446
|
+
queue_start = QueueTime.parse_frontend_timestamp(newrelic_request_headers, now)
|
447
447
|
QueueTime.record_frontend_metrics(queue_start, now) if queue_start
|
448
448
|
end
|
449
449
|
queue_start || now
|
@@ -18,14 +18,21 @@ module NewRelic
|
|
18
18
|
|
19
19
|
module_function
|
20
20
|
|
21
|
-
def parse_frontend_timestamp(headers)
|
21
|
+
def parse_frontend_timestamp(headers, now=Time.now)
|
22
22
|
candidate_headers = [ REQUEST_START_HEADER, QUEUE_START_HEADER,
|
23
23
|
MIDDLEWARE_START_HEADER ]
|
24
|
-
candidate_headers.map do |header|
|
24
|
+
earliest = candidate_headers.map do |header|
|
25
25
|
if headers[header]
|
26
26
|
parse_timestamp(timestamp_string_from_header_value(headers[header]))
|
27
27
|
end
|
28
28
|
end.compact.min
|
29
|
+
|
30
|
+
if earliest && earliest > now
|
31
|
+
NewRelic::Agent.logger.debug("Negative queue time detected, treating as zero: start=#{earliest.to_f} > now=#{now.to_f}")
|
32
|
+
earliest = now
|
33
|
+
end
|
34
|
+
|
35
|
+
earliest
|
29
36
|
end
|
30
37
|
|
31
38
|
def record_frontend_metrics(start_time, now=Time.now)
|
@@ -11,11 +11,10 @@ class NewRelic::Agent::Instrumentation::ControllerInstrumentationTest < Test::Un
|
|
11
11
|
|
12
12
|
def test_detect_upstream_wait_basic
|
13
13
|
start_time = Time.now
|
14
|
-
object = TestObject.new
|
15
14
|
# should return the start time above by default
|
16
15
|
@object.expects(:newrelic_request_headers).returns({:request => 'headers'}).twice
|
17
16
|
NewRelic::Agent::Instrumentation::QueueTime.expects(:parse_frontend_timestamp) \
|
18
|
-
.with({:request => 'headers'}).returns(start_time)
|
17
|
+
.with({:request => 'headers'}, start_time).returns(start_time)
|
19
18
|
assert_equal(start_time, @object.send(:_detect_upstream_wait, start_time))
|
20
19
|
end
|
21
20
|
|
@@ -24,17 +23,17 @@ class NewRelic::Agent::Instrumentation::ControllerInstrumentationTest < Test::Un
|
|
24
23
|
runs_at = start_time + 1
|
25
24
|
@object = TestObject.new
|
26
25
|
@object.expects(:newrelic_request_headers).returns(true).twice
|
27
|
-
NewRelic::Agent::Instrumentation::QueueTime.expects(:parse_frontend_timestamp)
|
26
|
+
NewRelic::Agent::Instrumentation::QueueTime.expects(:parse_frontend_timestamp) \
|
27
|
+
.with(true, runs_at).returns(start_time)
|
28
28
|
assert_equal(start_time, @object.send(:_detect_upstream_wait, runs_at))
|
29
29
|
end
|
30
30
|
|
31
31
|
def test_detect_upstream_wait_swallows_errors
|
32
32
|
start_time = Time.now
|
33
|
-
object = TestObject.new
|
34
33
|
# should return the start time above when an error is raised
|
35
34
|
@object.expects(:newrelic_request_headers).returns({:request => 'headers'}).twice
|
36
35
|
NewRelic::Agent::Instrumentation::QueueTime.expects(:parse_frontend_timestamp) \
|
37
|
-
.with({:request => 'headers'}).raises("an error")
|
36
|
+
.with({:request => 'headers'}, start_time).raises("an error")
|
38
37
|
assert_equal(start_time, @object.send(:_detect_upstream_wait, start_time))
|
39
38
|
end
|
40
39
|
end
|
@@ -54,6 +54,13 @@ class NewRelic::Agent::Instrumentation::QueueTimeTest < Test::Unit::TestCase
|
|
54
54
|
assert_in_delta(seconds_ago(60), QueueTime.parse_frontend_timestamp(header), 0.1)
|
55
55
|
end
|
56
56
|
|
57
|
+
def test_parse_frontend_timestamp_from_header_negative
|
58
|
+
now = Time.now
|
59
|
+
the_future = Time.at(now.to_f + 60)
|
60
|
+
header = { 'HTTP_X_REQUEST_START' => the_future.to_f.to_s }
|
61
|
+
assert_in_delta(now, QueueTime.parse_frontend_timestamp(header, now), 0.1)
|
62
|
+
end
|
63
|
+
|
57
64
|
def test_recording_queue_time_metric
|
58
65
|
assert_metric_value_in_delta(60, 'WebFrontend/QueueTime', 0.1) do
|
59
66
|
QueueTime.record_frontend_metrics(Time.at(Time.now.to_f - 60))
|
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.5.7.
|
4
|
+
version: 3.5.7.58.beta
|
5
5
|
prerelease: 9
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -41,7 +41,7 @@ cert_chain:
|
|
41
41
|
cHUySWFQWE92bTNUOEc0TzZxWnZobkxoL1VpZW4rK0RqOGVGQmVjVFBvTThw
|
42
42
|
VmpLM3BoNQpuL0V3dVpDY0U2Z2h0Q0NNCi0tLS0tRU5EIENFUlRJRklDQVRF
|
43
43
|
LS0tLS0K
|
44
|
-
date: 2013-02-
|
44
|
+
date: 2013-02-19 00:00:00.000000000 Z
|
45
45
|
dependencies: []
|
46
46
|
description: ! 'New Relic is a performance management system, developed by New Relic,
|
47
47
|
|
metadata.gz.sig
CHANGED
Binary file
|