-
Notifications
You must be signed in to change notification settings - Fork 598
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #2218 from newrelic/callback_fallback
- Loading branch information
Showing
4 changed files
with
51 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
38 changes: 38 additions & 0 deletions
38
test/multiverse/suites/net_http/net_http_core_instrumentation_test.rb
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# This file is distributed under New Relic's license terms. | ||
# See https://github.com/newrelic/newrelic-ruby-agent/blob/main/LICENSE for complete details. | ||
# frozen_string_literal: true | ||
|
||
require 'net_http_test_cases' | ||
|
||
class Testbed | ||
include NewRelic::Agent::Instrumentation::NetHTTP | ||
|
||
def address; 'localhost'; end | ||
def use_ssl?; false; end | ||
def port; 1138; end | ||
end | ||
|
||
class NetHttpTest < Minitest::Test | ||
# This test will see that `segment` is `nil` within the `ensure` block of | ||
# `request_with_tracing` to confirm that we check for `nil` prior to | ||
# attempting to call `#finish` on `segment`. | ||
# https://github.com/newrelic/newrelic-ruby-agent/issues/2213 | ||
def test_segment_might_fail_to_start | ||
t = Testbed.new | ||
response = 'I am a response, which an exception will prevent you from receiving unless you handle a nil segment' | ||
|
||
segment = nil | ||
def segment.add_request_headers(_request); end | ||
def segment.process_response_headers(_response); end | ||
|
||
request = Minitest::Mock.new | ||
2.times { request.expect :path, '/' } | ||
request.expect :method, 'GET' | ||
|
||
NewRelic::Agent::Tracer.stub :start_external_request_segment, segment do | ||
result = t.request_with_tracing(request) { response } | ||
|
||
assert_equal response, result | ||
end | ||
end | ||
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters