From 49d0d63e40ca0b0ce483242a02869eb7799c113a Mon Sep 17 00:00:00 2001 From: Troels Thomsen Date: Sun, 16 Jun 2024 10:12:42 +0200 Subject: [PATCH] Verify port equivalence --- .../instrumentation/excon/instrumentation_test.rb | 3 +++ .../http/test/instrumentation/http/patches/connection_test.rb | 3 +++ .../instrumentation/net/http/instrumentation_test.rb | 3 +++ 3 files changed, 9 insertions(+) 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