diff options
author | Stan Hu <stanhu@gmail.com> | 2022-01-31 19:51:15 +0300 |
---|---|---|
committer | Stan Hu <stanhu@gmail.com> | 2022-01-31 19:53:34 +0300 |
commit | 6f23e35ffe9665ab17af54824a7de2b014829069 (patch) | |
tree | 6c5d022f854337c727c1cffcf86243dfdba389a5 /internal/auth/auth.go | |
parent | e64c47ca1b29c96dee50b6d4fca3b6777b4426f2 (diff) |
fix: ensure logging status codes field names are consistent
LabKit logs all HTTP responses with a `status` field of an integer. We
ensure that all errors now use this convention and store the full
status text as `status_text`.
This is needed to enusre Elasticsearch doesn't drop logs due to
mapping conflicts.
Changelog: fixed
Diffstat (limited to 'internal/auth/auth.go')
-rw-r--r-- | internal/auth/auth.go | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/internal/auth/auth.go b/internal/auth/auth.go index 2f0395df..98bbf49d 100644 --- a/internal/auth/auth.go +++ b/internal/auth/auth.go @@ -18,6 +18,7 @@ import ( "github.com/gorilla/sessions" "github.com/sirupsen/logrus" "gitlab.com/gitlab-org/labkit/errortracking" + "gitlab.com/gitlab-org/labkit/log" "golang.org/x/crypto/hkdf" "gitlab.com/gitlab-org/gitlab-pages/internal/httperrors" @@ -538,7 +539,10 @@ func (a *Auth) checkAuthentication(w http.ResponseWriter, r *http.Request, domai if resp.StatusCode != http.StatusOK { // call serve404 handler when auth fails err := fmt.Errorf("unexpected response fetching access token status: %d", resp.StatusCode) - logRequest(r).WithError(err).WithField("status", resp.Status).Error("Unexpected response fetching access token") + logRequest(r).WithError(err).WithFields(log.Fields{ + "status": resp.StatusCode, + "status_text": resp.Status, + }).Error("Unexpected response fetching access token") captureErrWithReqAndStackTrace(err, r) domain.ServeNotFoundAuthFailed(w, r) return true |