report

package
v0.1.99 Latest Latest
Warning

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

Go to latest
Published: Oct 10, 2026 License: Apache-2.0 Imports: 2 Imported by: 0

Documentation

Overview

Package report is the seam between the places errors surface (panic recovery, typed handlers, the frontend) and whatever collects them (the analytics pack). Without a reporter, Capture does nothing.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Capture

func Capture(ctx context.Context, e Error)

Capture sends e to the reporter, if any.

func WithLookup

func WithLookup(ctx context.Context, lookup func() Reporter) context.Context

WithLookup attaches a function that resolves the reporter at capture time, so a reporter registered after the handler was built is found.

Types

type Error

type Error struct {
	// Source is "server" or "client".
	Source    string         `json:"source"`
	Message   string         `json:"message"`
	Stack     string         `json:"stack,omitempty"`
	Route     string         `json:"route,omitempty"`
	Method    string         `json:"method,omitempty"`
	URL       string         `json:"url,omitempty"`
	RequestID string         `json:"requestId,omitempty"`
	UserID    string         `json:"userId,omitempty"`
	UserAgent string         `json:"userAgent,omitempty"`
	Extra     map[string]any `json:"extra,omitempty"`
	At        time.Time      `json:"at"`
}

Error is one captured failure.

type Reporter

type Reporter interface {
	Report(ctx context.Context, e Error)
}

Reporter receives captured errors. Implementations must not block the request: queue and return.

func From

func From(ctx context.Context) Reporter

From returns the reporter for ctx, or nil.

Jump to

Keyboard shortcuts

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