Skip to content

Commit

Permalink
Merge branch 'main' into reg-cback-varidic
Browse files Browse the repository at this point in the history
  • Loading branch information
MrAlias authored Jan 13, 2023
2 parents 2bd6671 + 4286352 commit 66bef3c
Show file tree
Hide file tree
Showing 2 changed files with 26 additions and 1 deletion.
2 changes: 1 addition & 1 deletion semconv/internal/v2/http.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,7 +84,7 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
h = req.URL.Host
}
peer, p := firstHostPort(h, req.Header.Get("Host"))
port := requiredHTTPPort(req.TLS != nil, p)
port := requiredHTTPPort(req.URL != nil && req.URL.Scheme == "https", p)
if port > 0 {
n++
}
Expand Down
25 changes: 25 additions & 0 deletions semconv/internal/v2/http_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,31 @@ func TestHTTPClientResponse(t *testing.T) {
}, got)
}

func TestHTTPSClientRequest(t *testing.T) {
req := &http.Request{
Method: http.MethodGet,
URL: &url.URL{
Scheme: "https",
Host: "127.0.0.1:443",
Path: "/resource",
},
Proto: "HTTP/1.0",
ProtoMajor: 1,
ProtoMinor: 0,
}

assert.Equal(
t,
[]attribute.KeyValue{
attribute.String("http.method", "GET"),
attribute.String("http.flavor", "1.0"),
attribute.String("http.url", "https://127.0.0.1:443/resource"),
attribute.String("net.peer.name", "127.0.0.1"),
},
hc.ClientRequest(req),
)
}

func TestHTTPClientRequest(t *testing.T) {
const (
user = "alice"
Expand Down

0 comments on commit 66bef3c

Please sign in to comment.