errlog

package
v0.21.0 Latest Latest
Warning

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

Go to latest
Published: Oct 5, 2026 License: AGPL-3.0 Imports: 8 Imported by: 0

Documentation

Overview

Package errlog finishes a unit of work that failed: it decides the level of the result record, marks the span and counts errors without a recorded origin, from one errs.Report.

It does not write the record. The boundary logs it with its own logger and a context-taking call, so the correlation handler in internal/logger adds request_id, trace_id and span_id:

result := errlog.Finish(ctx, "http.request", err, errlog.Options{})
logger.LogAttrs(ctx, result.Level, "request failed", result.Attrs()...)

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Options

type Options struct {
	// Async marks a unit with no external caller (a background run, a
	// scheduled job, an event dispatch). A client fault there is this
	// process's fault.
	Async bool
	// WillRetry reports that the unit will be retried automatically.
	WillRetry bool
}

Options describes how the unit of work ended.

type Result

type Result struct {
	Report errs.Report
	Level  slog.Level
	// contains filtered or unexported fields
}

Result is the error outcome of a unit of work and its record level.

func Event

func Event(ctx context.Context, operation string, err error, opts Options) Result

Event gives the fields of an event record: one failed attempt in a retry loop, a fallback, or a swallowed error. Its level is always WARN. An event does not decide the unit's outcome, so the span is left alone; an error without a recorded origin is still counted.

func Finish

func Finish(ctx context.Context, operation string, err error, opts Options) Result

Finish attributes err at the end of a unit of work, sets the span status and counts an error without a recorded origin. A nil err is a success. ctx is the unit's own context, the one its span and cancellation belong to.

func (Result) Attrs

func (r Result) Attrs() []slog.Attr

Attrs returns the error fields of the record. A successful unit has none.

Jump to

Keyboard shortcuts

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