diff --git a/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb b/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb index a70228463..4301f853a 100644 --- a/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb +++ b/instrumentation/excon/test/opentelemetry/instrumentation/excon/instrumentation_test.rb @@ -215,6 +215,8 @@ end it 'emits span on connect' do + port = nil + TCPServer.open('localhost', 0) do |server| Thread.start do server.accept @@ -231,6 +233,7 @@ _(span.name).must_equal 'connect' _(span.attributes['net.peer.name']).must_equal('localhost') _(span.attributes['net.peer.port']).wont_be_nil + _(span.attributes['net.peer.port']).must_equal(port) assert_http_spans(target: '/example', exception: 'Excon::Error::Timeout') end diff --git a/instrumentation/http/test/instrumentation/http/patches/connection_test.rb b/instrumentation/http/test/instrumentation/http/patches/connection_test.rb index fc0b2b2a4..fe7e1caa1 100644 --- a/instrumentation/http/test/instrumentation/http/patches/connection_test.rb +++ b/instrumentation/http/test/instrumentation/http/patches/connection_test.rb @@ -24,6 +24,8 @@ describe '#connect' do it 'emits span on connect' do + port = nil + WebMock.allow_net_connect! TCPServer.open('localhost', 0) do |server| Thread.start { server.accept } @@ -38,6 +40,7 @@ _(span.name).must_equal 'HTTP CONNECT' _(span.attributes['net.peer.name']).must_equal('localhost') _(span.attributes['net.peer.port']).wont_be_nil + _(span.attributes['net.peer.port']).must_equal(port) ensure WebMock.disable_net_connect! end diff --git a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb index fb4d61a92..0d7b162b7 100644 --- a/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb +++ b/instrumentation/net_http/test/opentelemetry/instrumentation/net/http/instrumentation_test.rb @@ -210,6 +210,8 @@ describe '#connect' do it 'emits span on connect' do + port = nil + WebMock.allow_net_connect! TCPServer.open('localhost', 0) do |server| Thread.start { server.accept } @@ -225,6 +227,7 @@ _(span.name).must_equal 'connect' _(span.attributes['net.peer.name']).must_equal('localhost') _(span.attributes['net.peer.port']).wont_be_nil + _(span.attributes['net.peer.port']).must_equal(port) ensure WebMock.disable_net_connect! end