You've already forked opentelemetry-go
mirror of
https://github.com/open-telemetry/opentelemetry-go.git
synced 2026-06-03 18:35:08 +02:00
Remove http.target attr from ServerRequest (#3687)
* Remove http.target attr from ServerRequest * Update changelog * Remove trailing space in changelog
This commit is contained in:
@@ -157,7 +157,14 @@ func (c *HTTPConv) ClientRequest(req *http.Request) []attribute.KeyValue {
|
||||
// "net.sock.peer.addr", "net.sock.peer.port", "http.user_agent", "enduser.id",
|
||||
// "http.client_ip".
|
||||
func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.KeyValue {
|
||||
n := 5 // Method, scheme, target, proto, and host name.
|
||||
// TODO: This currently does not add the specification required
|
||||
// `http.target` attribute. It has too high of a cardinality to safely be
|
||||
// added. An alternate should be added, or this comment removed, when it is
|
||||
// addressed by the specification. If it is ultimately decided to continue
|
||||
// not including the attribute, the HTTPTargetKey field of the HTTPConv
|
||||
// should be removed as well.
|
||||
|
||||
n := 4 // Method, scheme, proto, and host name.
|
||||
var host string
|
||||
var p int
|
||||
if server == "" {
|
||||
@@ -199,14 +206,6 @@ func (c *HTTPConv) ServerRequest(server string, req *http.Request) []attribute.K
|
||||
attrs = append(attrs, c.proto(req.Proto))
|
||||
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))
|
||||
}
|
||||
|
||||
@@ -167,7 +167,6 @@ func TestHTTPServerRequest(t *testing.T) {
|
||||
assert.ElementsMatch(t,
|
||||
[]attribute.KeyValue{
|
||||
attribute.String("http.method", "GET"),
|
||||
attribute.String("http.target", "/"),
|
||||
attribute.String("http.scheme", "http"),
|
||||
attribute.String("http.flavor", "1.1"),
|
||||
attribute.String("net.host.name", srvURL.Hostname()),
|
||||
@@ -208,7 +207,6 @@ func TestHTTPServerRequestFailsGracefully(t *testing.T) {
|
||||
assert.NotPanics(t, func() { got = hc.ServerRequest("", req) })
|
||||
want := []attribute.KeyValue{
|
||||
attribute.String("http.method", "GET"),
|
||||
attribute.String("http.target", ""),
|
||||
attribute.String("http.scheme", "http"),
|
||||
attribute.String("http.flavor", ""),
|
||||
attribute.String("net.host.name", ""),
|
||||
|
||||
Reference in New Issue
Block a user