You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Spec check: should net.client.ip be filled consistently for both IPv4 and IPv6?
Environment
OS: Any
Architecture: Any
Go Version: 1.15
opentelemetry-go version: 1.0.1
Steps To Reproduce
Fire up any “hello, world” implementation on port 8090
Make requests via HTTP and HTTPS, eg. curl -4 :8090 and curl -6 :8090
Observe net.peer.ip is populated for IPv4 ("127.0.0.1") but not for IPv6
Observe net.peer.name is populated for IPv6 ("[::1]") but not for IPv4
Expected behavior
I expect net.peer.ip to contain the network peer IP address for both IPv4 and IPv6.
In the IPv6 case, r.RemoteAddr is "[::1]:54321" matching RFC 5952's Notes on Combining IPv6 Addresses with Port Numbers. net.SplitHostPort splits that to {"::1", "54321"} but we're not using it. Rather, we're using strings.LastIndexOf and trusting net.ParseIP will handle [::1]. It doesn't, so we end up with net.peer.name set to [::1] and net.peer.ip absent:
* Fix IPv6 handling errors in semconv.NetAttributesFromHTTPRequest
fixes#2283
* Enter PR number in CHANGELOG
* Remove unnecessary creation and then assignment
Standardize order of checks for IP, Name, Port
* Assume happy path when parsing host and port
i.e. assume net.SplitHostPort(input) will succeed
* Get rid of uint64 for port
* Fix git merge of main by adding back strings import
Co-authored-by: Tyler Yahn <[email protected]>
Co-authored-by: Tyler Yahn <[email protected]>
Description
Spec check: should net.client.ip be filled consistently for both IPv4 and IPv6?
Environment
Steps To Reproduce
curl -4 :8090
andcurl -6 :8090
net.peer.ip
is populated for IPv4 ("127.0.0.1"
) but not for IPv6net.peer.name
is populated for IPv6 ("[::1]"
) but not for IPv4Expected behavior
I expect
net.peer.ip
to contain the network peer IP address for both IPv4 and IPv6.In the IPv6 case,
r.RemoteAddr
is"[::1]:54321"
matching RFC 5952's Notes on Combining IPv6 Addresses with Port Numbers.net.SplitHostPort
splits that to{"::1", "54321"}
but we're not using it. Rather, we're usingstrings.LastIndexOf
and trustingnet.ParseIP
will handle[::1]
. It doesn't, so we end up withnet.peer.name
set to[::1]
andnet.peer.ip
absent:opentelemetry-go/semconv/v1.4.0/http.go
Lines 54 to 78 in cdf67dd
The text was updated successfully, but these errors were encountered: