Add the duration and start time to logged completed requests. (#13682)

This commit is contained in:
Nick Cabatoff 2022-01-20 08:55:30 -05:00 committed by GitHub
parent 4230749d9e
commit 279e0d4332
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 9 additions and 1 deletions

3
changelog/13682.txt Normal file
View File

@ -0,0 +1,3 @@
```release-note:improvement
core: Add duration and start_time to completed requests log entries
```

View File

@ -3044,7 +3044,12 @@ func (c *Core) LogCompletedRequests(reqID string, statusCode int) {
// there is only one writer to this map, so skip checking for errors
reqData := v.(InFlightReqData)
c.logger.Log(logLevel, "completed_request", "client_id", reqData.ClientID, "client_address", reqData.ClientRemoteAddr, "status_code", statusCode, "request_path", reqData.ReqPath, "request_method", reqData.Method)
c.logger.Log(logLevel, "completed_request",
"start_time", reqData.StartTime.Format(time.RFC3339),
"duration", fmt.Sprintf("%dms", time.Now().Sub(reqData.StartTime).Milliseconds()),
"client_id", reqData.ClientID,
"client_address", reqData.ClientRemoteAddr, "status_code", statusCode, "request_path", reqData.ReqPath,
"request_method", reqData.Method)
}
func (c *Core) ReloadLogRequestsLevel() {