Skip to content

Commit

Permalink
Split only the necessary number of values.
Browse files Browse the repository at this point in the history
As suggested by @pellared. Good suggestion, that.

Co-authored-by: Robert Pająk <pellared@hotmail.com>
  • Loading branch information
garthk and pellared committed Oct 14, 2021
1 parent 3750ec2 commit e4e4e7c
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion semconv/v1.4.0/http.go
Expand Up @@ -225,7 +225,7 @@ func HTTPServerAttributesFromHTTPRequest(serverName, route string, request *http
attrs = append(attrs, HTTPRouteKey.String(route))
}
if values, ok := request.Header["X-Forwarded-For"]; ok && len(values) > 0 {
if addresses := strings.Split(values[0], ","); len(addresses) > 0 {
if addresses := strings.SplitN(values[0], ",", 2); len(addresses) > 0 {
attrs = append(attrs, HTTPClientIPKey.String(addresses[0]))
}
}
Expand Down

0 comments on commit e4e4e7c

Please sign in to comment.