mirror of
https://github.com/VictoriaMetrics/VictoriaMetrics.git
synced 2026-05-17 08:36:55 +03:00
app/{vmagent,vminsert}: follow-up for 1cfa183c2b
- Call httpserver.GetQuotedRemoteAddr() and httpserver.GetRequestURI() only when the error occurs. This saves CPU time on fast path when there are no parsing errors. - Create a helper function - httpserver.LogError() - for logging the error with the request uri and remote addr context.
This commit is contained in:
@@ -705,3 +705,10 @@ func Redirect(w http.ResponseWriter, url string) {
|
||||
// This may require browser cache cleaning after the incorrect redirect is fixed.
|
||||
w.WriteHeader(http.StatusFound)
|
||||
}
|
||||
|
||||
// LogError logs the errStr with the context from req.
|
||||
func LogError(req *http.Request, errStr string) {
|
||||
uri := GetRequestURI(req)
|
||||
remoteAddr := GetQuotedRemoteAddr(req)
|
||||
logger.Errorf("uri: %s, remote address: %q: %s", uri, remoteAddr, errStr)
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user