Welcome to mirror list, hosted at ThFree Co, Russian Federation.

gitlab.com/gitlab-org/gitlab-pages.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorStan Hu <stanhu@gmail.com>2022-01-31 19:51:15 +0300
committerStan Hu <stanhu@gmail.com>2022-01-31 19:53:34 +0300
commit6f23e35ffe9665ab17af54824a7de2b014829069 (patch)
tree6c5d022f854337c727c1cffcf86243dfdba389a5 /internal
parente64c47ca1b29c96dee50b6d4fca3b6777b4426f2 (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')
-rw-r--r--internal/auth/auth.go6
-rw-r--r--internal/httprange/http_reader.go5
2 files changed, 9 insertions, 2 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
diff --git a/internal/httprange/http_reader.go b/internal/httprange/http_reader.go
index b9affc6d..08779bc8 100644
--- a/internal/httprange/http_reader.go
+++ b/internal/httprange/http_reader.go
@@ -87,7 +87,10 @@ func (r *Reader) ensureResponse() error {
// cleanup body on failure from r.setResponse to avoid memory leak
res.Body.Close()
- logging.LogRequest(req).WithError(err).WithField("status", res.Status).Error(rangeRequestFailedErrMsg)
+ logging.LogRequest(req).WithError(err).WithFields(log.Fields{
+ "status": res.StatusCode,
+ "status_text": res.Status,
+ }).Error(rangeRequestFailedErrMsg)
}
return err