Documentation
¶
Index ¶
Constants ¶
const AutoExplainThreshold = 5
AutoExplainThreshold is the occurrence count at which an error group is automatically given an explanation.
Variables ¶
This section is empty.
Functions ¶
func BuildAutoExplanation ¶
func BuildAutoExplanation(g *ErrorGroup) string
BuildAutoExplanation produces a short, deterministic explanation for an error group that has become significant (crossed AutoExplainThreshold occurrences). It is generated from the group's own data — no external LLM, no cross-package dependency — so it can be computed inline during ingest.
func Fingerprint ¶
Fingerprint computes a stable fingerprint for an error event based on the message and the first 3 stack frames.
Types ¶
type Breadcrumb ¶
type Breadcrumb struct {
Timestamp time.Time `json:"timestamp"`
Category string `json:"category"` // "http", "console", "navigation", "ui"
Message string `json:"message"`
Level string `json:"level"` // "info", "warning", "error"
Data map[string]any `json:"data"`
}
Breadcrumb records an event leading up to an error.
type ErrorEvent ¶
type ErrorEvent struct {
ID string `json:"id"`
GroupID string `json:"group_id"` // fingerprint
Timestamp time.Time `json:"timestamp"`
SessionID string `json:"session_id"`
URL string `json:"url"`
UserAgent string `json:"user_agent"`
Message string `json:"message"`
Stack string `json:"stack"`
Breadcrumbs []Breadcrumb `json:"breadcrumbs"` // events leading up to error
Context map[string]any `json:"context"` // request headers, body, etc.
Release string `json:"release"`
Service string `json:"service"`
TraceID string `json:"trace_id"` // link to distributed trace
}
ErrorEvent represents a single error occurrence.
type ErrorGroup ¶
type ErrorGroup struct {
ID string `json:"id"` // fingerprint hash
Message string `json:"message"` // error message
Type string `json:"type"` // "TypeError", "ValidationError", etc.
Source string `json:"source"` // file:line or service name
Stack string `json:"stack"` // full stack trace
Count int `json:"count"` // total occurrences
Sessions int `json:"sessions"` // unique sessions affected
FirstSeen time.Time `json:"first_seen"`
LastSeen time.Time `json:"last_seen"`
Status string `json:"status"` // "unresolved", "resolved", "ignored"
Release string `json:"release"` // release/deploy where first seen
Tags map[string]string `json:"tags"`
// AutoExplanation is a deterministic summary generated once the group
// crosses AutoExplainThreshold occurrences.
AutoExplanation string `json:"auto_explanation,omitempty"`
}
ErrorGroup represents a class of errors grouped by fingerprint.
type ErrorStore ¶
type ErrorStore interface {
// IngestError ingests a single error event, creating or updating the group.
IngestError(event ErrorEvent) error
// GetGroups returns error groups filtered by status. Pass "" for all statuses.
GetGroups(status string, limit int) ([]ErrorGroup, error)
// GetGroup returns a single error group by ID (fingerprint).
GetGroup(id string) (*ErrorGroup, error)
// GetEvents returns error events for a group, most recent first.
GetEvents(groupID string, limit int) ([]ErrorEvent, error)
// UpdateGroupStatus sets the status of an error group.
UpdateGroupStatus(id string, status string) error
}
ErrorStore defines the interface for persisting and querying structured errors.