correlation

package
v0.0.0-...-9b56f5e Latest Latest
Warning

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

Go to latest
Published: Feb 23, 2026 License: MIT Imports: 5 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func ID

func ID(ctx context.Context) (string, bool)

ID extracts the correlation ID from ctx, returning ("", false) if not present.

func NewID

func NewID() string

NewID generates an 8-character hex correlation ID (4 random bytes).

func WithID

func WithID(ctx context.Context, id string) context.Context

WithID returns a new context carrying the given correlation ID.

Types

type Handler

type Handler struct {
	// contains filtered or unexported fields
}

Handler wraps an existing slog.Handler to automatically inject a "correlation_id" attribute when the context carries one.

func NewHandler

func NewHandler(inner slog.Handler) *Handler

NewHandler creates a correlation-aware handler wrapping the given handler.

func (*Handler) Enabled

func (h *Handler) Enabled(ctx context.Context, level slog.Level) bool

func (*Handler) Handle

func (h *Handler) Handle(ctx context.Context, r slog.Record) error

func (*Handler) WithAttrs

func (h *Handler) WithAttrs(attrs []slog.Attr) slog.Handler

func (*Handler) WithGroup

func (h *Handler) WithGroup(name string) slog.Handler

Jump to

Keyboard shortcuts

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