internal/worker: log full request URL
Log the request's query params as well as the path.
Also repeat the URL at the end to make it easier to match them up.
Change-Id: Ic68c43c71ecca5749e10609c1630efb20327ea52
Reviewed-on: https://go-review.googlesource.com/c/pkgsite-metrics/+/471775
Run-TryBot: Jonathan Amsterdam <jba@google.com>
Reviewed-by: Zvonimir Pavlinovic <zpavlinovic@google.com>
TryBot-Result: Gopher Robot <gobot@golang.org>
diff --git a/internal/worker/server.go b/internal/worker/server.go
index c1f6f93..fb92a02 100644
--- a/internal/worker/server.go
+++ b/internal/worker/server.go
@@ -154,13 +154,19 @@
ctx = log.NewContext(ctx, logger)
r = r.WithContext(ctx)
- log.Infof(ctx, "starting %s", r.URL.Path)
+ // For logging, construct a string with the entire URL except scheme and host.
+ url2 := *r.URL
+ url2.Scheme = ""
+ url2.Host = ""
+ urlString := url2.String()
+
+ log.Infof(ctx, "starting %s", urlString)
w2 := &responseWriter{ResponseWriter: w}
if err := handler(w2, r); err != nil {
derrors.Report(err)
s.serveError(ctx, w2, r, err)
}
- logger.Info("request end",
+ logger.Info(fmt.Sprintf("ending %s", urlString),
"latency", time.Since(start),
"status", translateStatus(w2.status))
})