diff --git a/util/httputil/context.go b/util/httputil/context.go index 5b0b983cb..10169d890 100644 --- a/util/httputil/context.go +++ b/util/httputil/context.go @@ -34,23 +34,23 @@ func ContextWithPath(ctx context.Context, path string) context.Context { // ContextFromRequest returns a new context from a requests with identifiers of // the request to be used later when logging the query. func ContextFromRequest(ctx context.Context, r *http.Request) context.Context { - m := map[string]string{ + reqCtxVal := map[string]string{ "method": r.Method, } // r.RemoteAddr has no defined format, so don't return error if we cannot split it into IP:Port. ip, _, _ := net.SplitHostPort(r.RemoteAddr) if ip != "" { - m["clientIP"] = ip + reqCtxVal["clientIP"] = ip } var path string if v := ctx.Value(pathParam); v != nil { path = v.(string) - m["path"] = path + reqCtxVal["path"] = path } return promql.NewOriginContext(ctx, map[string]interface{}{ - "httpRequest": m, + "httpRequest": reqCtxVal, }) }