From bce017f56f2413872a3a904067d6d19d173a9904 Mon Sep 17 00:00:00 2001 From: Christine Dodrill Date: Wed, 27 Mar 2019 07:40:42 -0700 Subject: [PATCH] shadow errors --- cmd/site/main.go | 13 ++++++++----- internal/middleware/metrics.go | 6 +++--- 2 files changed, 11 insertions(+), 8 deletions(-) diff --git a/cmd/site/main.go b/cmd/site/main.go index 3719095..e3987b3 100644 --- a/cmd/site/main.go +++ b/cmd/site/main.go @@ -30,11 +30,15 @@ func main() { port = "29384" } + ctx := ln.WithF(opname.With(context.Background(), "main"), ln.F{ + "port": port, + }) + prometheus.Register(prommod.NewCollector("christine")) s, err := Build() if err != nil { - ln.FatalErr(context.Background(), err, ln.Action("Build")) + ln.FatalErr(ctx, err, ln.Action("Build")) } mux := http.NewServeMux() @@ -43,8 +47,8 @@ func main() { }) mux.Handle("/", s) - ln.Log(context.Background(), ln.F{"action": "http_listening", "port": port}) - http.ListenAndServe(":"+port, mux) + ln.Log(ctx, ln.Action("http_listening")) + ln.FatalErr(ctx, http.ListenAndServe(":"+port, mux)) } // Site is the parent object for https://christine.website's backend. @@ -56,7 +60,6 @@ type Site struct { jsonFeed *jsonfeed.Feed mux *http.ServeMux - sitemap []byte xffmw *xff.XFF } @@ -189,7 +192,7 @@ func Build() (*Site, error) { }) s.mux.Handle("/sitemap.xml", middleware.Metrics("sitemap", http.HandlerFunc(func(w http.ResponseWriter, r *http.Request) { w.Header().Set("Content-Type", "application/xml") - smi.WriteTo(w) + _, _ = smi.WriteTo(w) }))) return s, nil diff --git a/internal/middleware/metrics.go b/internal/middleware/metrics.go index df4816d..f9d7e0f 100644 --- a/internal/middleware/metrics.go +++ b/internal/middleware/metrics.go @@ -26,9 +26,9 @@ var ( ) func init() { - prometheus.Register(requestCounter) - prometheus.Register(requestDuration) - prometheus.Register(requestInFlight) + _ = prometheus.Register(requestCounter) + _ = prometheus.Register(requestDuration) + _ = prometheus.Register(requestInFlight) } // Metrics captures request duration, request count and in-flight request count