reqlog

package
v1.166.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 20, 2026 License: Apache-2.0 Imports: 6 Imported by: 0

Documentation

Overview

Package reqlog logs a failure an HTTP handler met while serving a request (#2728).

A handler whose caller went away mid-request (a browser panning a map away, the tile renderer abandoning a page) sees its reads fail with the request's own context canceled. Nothing failed on the server: nobody was waiting for the answer any more. Logged at ERROR, those lines read as outages to every soak, alert and dashboard that counts ERROR, and hide the real failures that look the same. Failed logs them at DEBUG, and a failure met while the caller is still there at ERROR, in one place for every handler. .semgrep/go-request-error-log.yml refuses slog.ErrorContext on a request's context anywhere else.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func CallerGone

func CallerGone(r *http.Request, err error) bool

CallerGone reports whether the request's caller stopped waiting: its context is done, or err is the cancellation that ended the read.

func Failed

func Failed(r *http.Request, msg string, err error, attrs ...any) bool

Failed logs msg with err (sanitized for the log) and attrs: at ERROR while the caller is waiting, at DEBUG once it has gone. It returns whether the caller has gone, so a handler may skip writing an answer nobody reads.

Types

This section is empty.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL