From e4e4e7cf8762354d623a8773bad3c7e9270b6aff Mon Sep 17 00:00:00 2001 From: Garth Kidd Date: Fri, 15 Oct 2021 10:13:34 +1100 Subject: [PATCH] Split only the necessary number of values. MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit As suggested by @pellared. Good suggestion, that. Co-authored-by: Robert PajÄ…k --- semconv/v1.4.0/http.go | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/semconv/v1.4.0/http.go b/semconv/v1.4.0/http.go index 844649e5983..f7157c66086 100644 --- a/semconv/v1.4.0/http.go +++ b/semconv/v1.4.0/http.go @@ -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])) } }