Commit e794dabb988b321a0c99a378eb1469e9681b6ede

Parents: 55622c8ce99e85536810c9e3b405aa7347368c94

From: Moritz Poldrack <git@moritz.sh>
Date: Mon Nov 20 13:35:48 2023 +0700

log: log handling-time

		

Stats

internal/handler/serve-http.go +5/-0

Changeset

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
diff --git a/internal/handler/serve-http.go b/internal/handler/serve-http.go
index ffee6578ffe1787b0d2c8d250e0cf88eca9667d6..56160f17f62b6c0b60fa3890b410865544847ef8 100644
--- a/internal/handler/serve-http.go
+++ b/internal/handler/serve-http.go
@@ -5,6 +5,7 @@ 	"bytes"
 	"log/slog"
 	"path/filepath"
 	"strings"
+	"time"
 
 	"git.sr.ht/~mpldr/gogit/internal/conman"
 	"git.sr.ht/~mpldr/gogit/internal/handler/templates"
@@ -13,7 +14,11 @@ 	"github.com/valyala/fasthttp"
 )
 
 func (h *Handler) Serve(ctx *fasthttp.RequestCtx) {
+	start := time.Now()
 	log := slog.With("requestID", h.requestID.Add(1))
+	defer func() {
+		log.Debug("request completed", "duration", time.Since(start))
+	}()
 	log.Info(
 		"incoming request",
 		"method", ctx.Method(),