logctx

package
v1.47.0 Latest Latest
Warning

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

Go to latest
Published: Sep 14, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package logctx ties log lines back to the request that produced them.

httpserver.CorrelationIDMiddleware puts the resolved correlation ID in the request context, but only LabKit's access logger reads it back out. Every other line a request produces — cache hit/miss, upstream fetch, offload — comes from a component logger that never saw the request, so an operator holding a job's "Gitaly correlation ID" can find the access line and nothing else. WithCorrelation is the one-line bridge: components keep their own base logger and stamp the ID onto it wherever a context is in hand.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func WithCorrelation

func WithCorrelation(ctx context.Context, base *slog.Logger) *slog.Logger

WithCorrelation returns base with the context's correlation ID attached as correlation_id, the same field name and value the access log uses.

It returns base unchanged when the context carries no ID, which covers background work on a detached context: such lines get no correlation_id rather than an empty one. To keep an ID across a detached context, derive the logger while the request context is still in hand and pass that logger to the background work.

Types

This section is empty.

Jump to

Keyboard shortcuts

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