Skip to content

Commit

Permalink
Log warning for slow requests
Browse files Browse the repository at this point in the history
  • Loading branch information
David Robertson committed Jun 23, 2023
1 parent f4e935c commit b47ebaa
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion sync3/handler/handler.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,8 +209,10 @@ func (h *SyncLiveHandler) ServeHTTP(w http.ResponseWriter, req *http.Request) {
func (h *SyncLiveHandler) serve(w http.ResponseWriter, req *http.Request) error {
start := time.Now()
defer func() {
if time.Since(start) > 50*time.Second {
dur := time.Since(start)
if dur > 50*time.Second {
h.slowReqs.Add(1.0)
internal.DecorateLogger(req.Context(), log.Warn()).Dur("duration", dur).Msg("slow request")
}
}()
var requestBody sync3.Request
Expand Down

0 comments on commit b47ebaa

Please sign in to comment.