Skip to content

Commit

Permalink
feat: add http.target to otelmux (#1)
Browse files Browse the repository at this point in the history
  • Loading branch information
rohankmr414 authored and utkarsh-var committed Aug 7, 2024
1 parent 52e3d20 commit 9708d7e
Showing 1 changed file with 9 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -330,7 +330,7 @@ func (c *httpConv) ServerRequest(server string, req *http.Request) []attribute.K
net.sock.host.port The request doesn't have access to the underlying socket.
*/
n := 4 // Method, scheme, proto, and host name.
n := 5 // Method, scheme, proto, and host name.
var host string
var p int
if server == "" {
Expand Down Expand Up @@ -384,6 +384,14 @@ func (c *httpConv) ServerRequest(server string, req *http.Request) []attribute.K
attrs = append(attrs, c.scheme(req.TLS != nil))
attrs = append(attrs, c.NetConv.HostName(host))

if req.URL != nil {
attrs = append(attrs, c.HTTPTargetKey.String(req.URL.RequestURI()))
} else {
// This should never occur if the request was generated by the net/http
// package. Fail gracefully, if it does though.
attrs = append(attrs, c.HTTPTargetKey.String(req.RequestURI))
}

if hostPort > 0 {
attrs = append(attrs, c.NetConv.HostPort(hostPort))
}
Expand Down

0 comments on commit 9708d7e

Please sign in to comment.