diagnostics

package
v0.9.6-dev.3 Latest Latest
Warning

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

Go to latest
Published: Sep 20, 2026 License: GPL-3.0 Imports: 18 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Index

Constants

View Source
const (
	MaxDepth = 32
	MaxNodes = 64
	MaxBytes = 256 << 10
)

Capture limits apply before protocol encoding and terminal rendering.

View Source
const MaxHTTPBodyBytes = 256 << 10

MaxHTTPBodyBytes bounds retained upstream failure bodies, before JSON encoding.

Variables

This section is empty.

Functions

func AlreadyReported

func AlreadyReported(err error) bool

AlreadyReported reports whether err carries a diagnostic ownership marker.

func AvailabilityText added in v0.9.5

func AvailabilityText(state protocol.DiagnosticState) string

AvailabilityText describes missing remote content without inventing a cause.

func BoundText added in v0.9.5

func BoundText(text string) string

BoundText bounds an individual original text value using the capture budget.

func Classification added in v0.9.5

func Classification(err error) (protocol.APIError, bool)

Classification finds the outer API classification with bounded graph traversal.

func Describe added in v0.9.5

func Describe(ctx context.Context, record Record) protocol.Diagnostic

Describe captures one occurrence without publishing it or consulting a logger.

func EscapeTerminal added in v0.9.5

func EscapeTerminal(value string) string

EscapeTerminal renders control characters as text while preserving line breaks and tabs. It never changes the captured snapshot used for JSON or copying.

func FailureLevel

func FailureLevel(ctx context.Context, err error) (slog.Level, bool)

FailureLevel classifies an operation failure for diagnostic logging.

func HTTPBody added in v0.9.4

func HTTPBody(raw []byte) string

HTTPBody bounds retained error payloads without retaining response objects.

func HTTPOperation added in v0.9.4

func HTTPOperation(method, path string) string

HTTPOperation removes user-controlled path segments and query parameters.

func MarkReported

func MarkReported(err error) error

MarkReported marks err as already reported by its diagnostic owner.

func NormalCancellation added in v0.9.4

func NormalCancellation(ctx context.Context, err error) bool

NormalCancellation reports whether active cancellation ended an operation. An elapsed request deadline remains an inspectable failure. It lets non-log failure callbacks retain their shutdown semantics.

func ReportError added in v0.9.5

func ReportError(ctx context.Context, reporter Reporter, record Record) error

ReportError synchronously obtains the occurrence published by an injected owner. A missing reporter still preserves details for CLI errors before logger setup.

func ReturnWarnings added in v0.9.5

func ReturnWarnings(ctx context.Context, warnings protocol.WarningOutcome)

ReturnWarnings returns already published occurrences to the invoking adapter. Replaying an operation returns its original warnings without publishing again.

func Snapshot added in v0.9.5

func Snapshot(err error) (protocol.Diagnostic, bool)

Snapshot returns an occurrence attached to this failure, not a joined child.

func TerminalText added in v0.9.5

func TerminalText(label string, snapshot protocol.Diagnostic) string

TerminalText renders the shared summary and original-detail sections.

func WithOperation added in v0.9.5

func WithOperation(ctx context.Context, operation OperationMetadata) context.Context

WithOperation attaches copied operation metadata to a non-nil context.

func WithSnapshot added in v0.9.5

func WithSnapshot(err error, snapshot protocol.Diagnostic) error

WithSnapshot retains cause traversal while attaching an immutable occurrence.

func Wrap

func Wrap(api protocol.APIError, cause error) error

Wrap combines a public API error with its internal cause.

Types

type CapturedText added in v0.9.5

type CapturedText struct {
	Text      string
	Truncated bool
	Reason    string
}

CapturedText holds original text and explicit collection limits.

func Capture added in v0.9.5

func Capture(err error) CapturedText

Capture formats an error graph without redaction or additional stack capture.

type HTTPError added in v0.9.4

type HTTPError struct {
	Operation string
	URL       string
	Phase     string
	Status    int
	Body      string
	// BodyTruncated records an upstream collection limit independently of text.
	BodyTruncated bool
	Cause         error
	RetryDelay    time.Duration
}

HTTPError retains original upstream diagnostics for shared bounded capture. Error provides the basic assertion; DiagnosticText supplies the collected cause.

func HandshakeError added in v0.9.4

func HandshakeError(operation string, response *http.Response, cause error) *HTTPError

HandshakeError captures the failed websocket dial response. The websocket adapter returns a closed-network-body copy capped at 1024 bytes; mark that upstream library limit rather than claiming a complete error payload.

func (*HTTPError) DiagnosticText added in v0.9.4

func (e *HTTPError) DiagnosticText() string

DiagnosticText returns original HTTP details for diagnostic capture.

func (*HTTPError) Error added in v0.9.4

func (e *HTTPError) Error() string

func (*HTTPError) RetryAfter added in v0.9.4

func (e *HTTPError) RetryAfter() time.Duration

RetryAfter exposes a parsed upstream retry delay to the provider read policy.

func (*HTTPError) Unwrap added in v0.9.4

func (e *HTTPError) Unwrap() error

type History added in v0.9.5

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

History retains immutable occurrence snapshots for one process lifetime.

func NewHistory added in v0.9.5

func NewHistory(options HistoryOptions) (*History, error)

NewHistory constructs an independent process history without touching disk.

func (*History) Add added in v0.9.5

Add assigns a new occurrence identity even when another record has the same text.

func (*History) Get added in v0.9.5

Get returns a copy of one occurrence, distinguishing expiry from an unknown ID.

func (*History) List added in v0.9.5

func (h *History) List(instance string, after uint64, limit int) protocol.DiagnosticList

List returns metadata after a sequence; a foreign instance starts a new timeline.

type HistoryOptions added in v0.9.5

type HistoryOptions struct {
	InstanceID string
	MaxRecords int
	MaxBytes   int
	Now        func() time.Time
}

HistoryOptions bounds process-owned diagnostic history. Zero limits use daemon defaults.

type OperationMetadata added in v0.9.5

type OperationMetadata struct {
	ID   string
	Name string
}

OperationMetadata identifies a logical operation across diagnostic outlets.

func OperationFromContext added in v0.9.5

func OperationFromContext(ctx context.Context) (OperationMetadata, bool)

OperationFromContext retrieves an explicitly bound operation identity.

type Owner added in v0.9.5

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

Owner publishes occurrences to process history and an optional file outlet. It owns neither a goroutine nor the lifetime of the borrowed file outlet.

func NewOwner added in v0.9.5

func NewOwner(history *History, file Reporter) *Owner

NewOwner connects an independent in-memory history to an optional reporter.

func (*Owner) Report added in v0.9.5

func (o *Owner) Report(ctx context.Context, record Record)

Report synchronously publishes a diagnostic at its executing owner boundary.

type Record

type Record struct {
	Component string
	Event     string
	Level     slog.Level
	Err       error
	Summary   string
	Object    string
	// Snapshot is populated by an owner before forwarding to a file outlet.
	Snapshot *protocol.Diagnostic
	// contains filtered or unexported fields
}

Record describes one internal diagnostic event. It must not be serialized.

type Reporter

type Reporter func(context.Context, Record)

Reporter records an internal diagnostic event at an owning boundary.

type Result added in v0.9.5

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

Result is a call-scoped diagnostic result, separate from persisted business data. A control adapter supplies it to receive warnings from use cases that return either a value or only an error. It never owns or stores a context.

func WithResult added in v0.9.5

func WithResult(ctx context.Context) (context.Context, *Result)

WithResult creates a result receiver for this call and its child operations.

func (*Result) Warnings added in v0.9.5

func (r *Result) Warnings() protocol.WarningOutcome

Warnings returns a copy of the diagnostic result without transferring ownership.

Jump to

Keyboard shortcuts

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