newrelic_rpm 3.5.8.70 → 3.5.8.72

Sign up to get free protection for your applications and to get access to all the features.
data.tar.gz.sig CHANGED
Binary file
@@ -33,8 +33,11 @@ module NewRelic
33
33
  return yield unless NewRelic::Agent.is_execution_traced?
34
34
 
35
35
  t0, segment = start_trace( http, request )
36
- response = yield
37
- finish_trace( t0, segment, request, response, http ) if t0
36
+ begin
37
+ response = yield
38
+ ensure
39
+ finish_trace( t0, segment, request, response, http ) if t0
40
+ end
38
41
 
39
42
  return response
40
43
  end
@@ -60,24 +63,28 @@ module NewRelic
60
63
  # +response+ and the given +http+ connection.
61
64
  def finish_trace( t0, segment, request, response, http )
62
65
  t1 = Time.now
63
-
64
- # Figure out which metrics we need to report based on the request and response
65
- # The last (most-specific) one is scoped.
66
- metrics = metrics_for( http, request, response )
67
- scoped_metric = metrics.pop
68
-
69
- # Report the metrics
70
66
  duration = t1.to_f - t0.to_f
71
- metrics.each { |metric| get_metric(metric).trace_call(duration) }
72
- get_scoped_metric( scoped_metric ).trace_call( duration )
73
67
 
74
- # Add TT custom parameters
75
- stats_engine.rename_scope_segment( scoped_metric )
76
- extract_custom_parameters( response ) if response_is_crossapp?( response )
68
+ begin
69
+ if request && response && http
70
+ # Figure out which metrics we need to report based on the request and response
71
+ # The last (most-specific) one is scoped.
72
+ metrics = metrics_for( http, request, response )
73
+ scoped_metric = metrics.pop
77
74
 
78
- # Change the name of the segment to the scoped metric and then pop it.
79
- stats_engine.pop_scope( segment, duration, t1 )
75
+ # Report the metrics
76
+ metrics.each { |metric| get_metric(metric).trace_call(duration) }
77
+ get_scoped_metric( scoped_metric ).trace_call( duration )
80
78
 
79
+ # Add TT custom parameters
80
+ stats_engine.rename_scope_segment( scoped_metric )
81
+ extract_custom_parameters( response ) if response_is_crossapp?( response )
82
+ end
83
+ ensure
84
+ # We always need to pop the scope stack to avoid an inconsistent
85
+ # state, which will prevent tracing of the whole transaction.
86
+ stats_engine.pop_scope( segment, duration, t1 )
87
+ end
81
88
  rescue NewRelic::Agent::CrossAppTracing::Error => err
82
89
  NewRelic::Agent.logger.debug "while cross app tracing", err
83
90
  rescue => err
@@ -30,7 +30,6 @@ class Net::HTTPResponse
30
30
  end
31
31
  end
32
32
  end
33
-
34
33
 
35
34
  class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::TestCase
36
35
  include NewRelic::Agent::Instrumentation::ControllerInstrumentation,
@@ -449,4 +448,14 @@ class NewRelic::Agent::Instrumentation::NetInstrumentationTest < Test::Unit::Tes
449
448
  assert_equal res, CANNED_RESPONSE.instance_variable_get( :@body )
450
449
  end
451
450
 
451
+ def test_scope_stack_integrity_maintained_on_request_failure
452
+ @socket.stubs(:write).raises('fake network error')
453
+ with_config(:"cross_application_tracer.enabled" => true) do
454
+ assert_nothing_raised do
455
+ expected = @engine.push_scope('dummy')
456
+ Net::HTTP.get(URI.parse('http://www.google.com/index.html')) rescue nil
457
+ @engine.pop_scope(expected, 42)
458
+ end
459
+ end
460
+ end
452
461
  end
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.8.70
4
+ version: 3.5.8.72
5
5
  prerelease:
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-28 00:00:00.000000000 Z
44
+ date: 2013-03-01 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