Documentation
¶
Overview ¶
Package logx holds the logging conventions shared by every Jōei component, so a log line reads the same whichever subsystem wrote it.
Every request gets one ID, minted by Middleware at the edge of the server. It reaches the client as the X-Request-Id header, the request's log lines as the request_id field, JSON error bodies and the console request feed — so one ID ties together everything a single request left behind.
Field vocabulary (use these names, never synonyms):
component subsystem that wrote the line: server, proxy,
metadata_filter, docker, console, telemetry, auth
request_id the request's ID (via Logger, never set by hand)
ecosystem pypi | npm | maven | rubygems | go | docker
package package name (Docker: the repository)
version package version (Docker: tag or digest as requested)
classifier Maven classifier, when present
digest Docker content digest
path request path, for requests that name no package
verdict, gate, outcome of a gated request (see Outcome)
reason, status,
duration_ms
upstream_attempts per-mirror attempt list (upstream.Attempts)
error the error (zerolog's Err)
Messages are short lowercase phrases without a subsystem prefix; the component field carries the subsystem.
Index ¶
- Constants
- func Ensure(r *http.Request) (*http.Request, string)
- func Logger(ctx context.Context, base zerolog.Logger) zerolog.Logger
- func Middleware(next http.Handler) http.Handler
- func Outcome(log zerolog.Logger, ev gate.Event)
- func RequestID(ctx context.Context) string
- func WithRequestID(ctx context.Context, id string) context.Context
Constants ¶
const HeaderRequestID = "X-Request-Id"
HeaderRequestID is the response header that carries the request ID.
const MsgOutcome = "request gated"
MsgOutcome is the message of the single line each gated request ends with.
Variables ¶
This section is empty.
Functions ¶
func Ensure ¶
Ensure returns r carrying a request ID, minting one when r has none, and that ID. Handlers call it so they work the same mounted behind Middleware or used directly.
func Logger ¶
Logger returns base with the request_id field of ctx's request, or base unchanged outside a request.
func Middleware ¶
Middleware gives every request an ID and returns it in the X-Request-Id response header.
func Outcome ¶
Outcome writes the one line a gated request ends with, mirroring the telemetry event it records. log must already carry the request's identity fields (request_id, ecosystem, package, version). PASS and CACHE log at info, BLOCK and client-side errors (4xx) at warn, other errors at error.
Types ¶
This section is empty.