diff options
| author | Taras Madan <tarasmadan@google.com> | 2024-11-04 11:30:19 +0100 |
|---|---|---|
| committer | Taras Madan <tarasmadan@google.com> | 2024-11-04 11:47:46 +0000 |
| commit | 7bfecfb91238ca7d15ec9dc565b887278b8160be (patch) | |
| tree | effe9af7a709252e9b8320b38b0419485191fcb8 /dashboard/app/handler.go | |
| parent | 2c4d2e02c3ededab70593ceb9631a2b551823be1 (diff) | |
dashboard/api: log trace id and return it to the client
It allows to later get all the associated records in logs explorer.
Diffstat (limited to 'dashboard/app/handler.go')
| -rw-r--r-- | dashboard/app/handler.go | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/dashboard/app/handler.go b/dashboard/app/handler.go index 4213d4eaf..e737c2b0b 100644 --- a/dashboard/app/handler.go +++ b/dashboard/app/handler.go @@ -43,11 +43,13 @@ func handleContext(fn contextHandler) http.Handler { if err := fn(c, w, r); err != nil { hdr := commonHeaderRaw(c, r) data := &struct { - Header *uiHeader - Error string + Header *uiHeader + Error string + TraceID string }{ - Header: hdr, - Error: err.Error(), + Header: hdr, + Error: err.Error(), + TraceID: strings.Join(r.Header["X-Cloud-Trace-Context"], " "), } if err == ErrAccess { if hdr.LoginLink != "" { @@ -83,7 +85,7 @@ func logErrorPrepareStatus(c context.Context, err error) int { logf = log.Warningf status = clientError.HTTPStatus() } - logf(c, "%v", err) + logf(c, "appengine error: %v", err) return status } |
