Help us shape the future of Go! Take the 2026 Go Developer Survey

breaklogs

package
v1.4.33 Latest Latest
Warning

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

Go to latest
Published: Oct 30, 2026 License: MIT Imports: 12 Imported by: 0

Documentation

Index

Constants

View Source
const AllContainers = "*"

AllContainers is the Container value that merges every container's lines.

View Source
const MaxBytes = 8 << 20
View Source
const MaxSnapshots = 2000
View Source
const Retention = 24 * time.Hour

Variables

View Source
var ErrInvalid = errors.New("invalid break logs request")

Functions

func CursorOffset

func CursorOffset(scope string, query Query, digest string, now time.Time) (int, time.Time, error)

func Identity

func Identity(snapshot Snapshot) string

func Level

func Level(text string) string

func Merge

func Merge(current *State, incoming []Snapshot, gaps []Gap, job string, now time.Time) error

func NextCursor

func NextCursor(scope string, query Query, digest string, offset int, observed time.Time) string

func SettingsKey

func SettingsKey(org, cluster string) string

func UpdateSettings

func UpdateSettings(provider storage.Provider, key string, update func(*SettingsState) error) error

Types

type Alerts

type Alerts struct {
	Enabled   bool      `json:"enabled"`
	Level     string    `json:"level"`
	EnabledAt time.Time `json:"enabled_at"`
	UpdatedBy string    `json:"updated_by"`
}

type CaptureSettings

type CaptureSettings struct {
	LinkedSource string            `json:"linked_source"`
	Fields       map[string]Fields `json:"fields"`
}

type ContainerObservation

type ContainerObservation struct {
	PodUID    string
	Container string
	Init      bool
	Slot      string
	Restarts  int32
	Deleted   bool
	Forbidden bool
	Deferred  bool
}

type Coverage

type Coverage struct {
	State  string `json:"state"`
	Gaps   []Gap  `json:"gaps"`
	Reason string `json:"reason,omitempty"`
	Tip    bool   `json:"tip"`
}

func Assess

func Assess(from, to time.Time, snapshots []Snapshot, container ContainerObservation) Coverage

func Cover

func Cover(from, to time.Time, intervals []Gap, failures []Gap, linkedClosed bool) Coverage

func CoverObserved

func CoverObserved(from, to, now time.Time, intervals, failures []Gap) Coverage

type Fields

type Fields struct {
	Namespace string `json:"namespace"`
	Pod       string `json:"pod"`
	Container string `json:"container"`
	Time      string `json:"time,omitempty"`
	Message   string `json:"message,omitempty"`
}

func DefaultFields

func DefaultFields(kind string) Fields

func NormalizeFields

func NormalizeFields(kind string, fields Fields) (Fields, error)

type Gap

type Gap struct {
	SnapshotID string    `json:"snapshot_id,omitempty"`
	ObservedAt time.Time `json:"observed_at,omitempty"`
	From       time.Time `json:"from"`
	To         time.Time `json:"to"`
	Namespace  string    `json:"namespace,omitempty"`
	RootUID    string    `json:"root_uid,omitempty"`
	PodUID     string    `json:"pod_uid,omitempty"`
	Container  string    `json:"container,omitempty"`
	Reason     string    `json:"reason,omitempty"`
}

func ResolveBudgetGaps

func ResolveBudgetGaps(gaps []Gap, snapshots []Snapshot) []Gap

type Health

type Health struct {
	State string    `json:"state"`
	At    time.Time `json:"at"`
}

type Learning

type Learning struct {
	Logs    bool  `json:"logs"`
	Metrics bool  `json:"metrics"`
	Traces  bool  `json:"traces"`
	Scope   Scope `json:"scope"`
}

type Line

type Line struct {
	At   time.Time `json:"at"`
	Text string    `json:"text"`
}

type LinkedLine

type LinkedLine struct {
	At        time.Time `json:"at"`
	Pod       string    `json:"pod"`
	Container string    `json:"container"`
	Text      string    `json:"text"`
}

type LinkedQuery

type LinkedQuery struct {
	Namespace string
	PodPrefix string
	Pods      []string
	Container string
	From, To  time.Time
	Limit     int
}

func (LinkedQuery) Validate

func (query LinkedQuery) Validate() error

type LinkedReader

type LinkedReader interface {
	Read(context.Context, LinkedQuery) (Result, error)
	Preview(LinkedQuery) string
}

type Query

type Query struct {
	Namespace, RootUID, Mode, Level, Search, Cursor string
	// Container selects one container by name. Empty asks for the break's main
	// container and AllContainers merges every container.
	Container string
	Pods      []string
	From, To  time.Time
	Limit     int
}

func (Query) Validate

func (query Query) Validate() error

type Result

type Result struct {
	Lines     []LinkedLine
	Truncated bool
}

type Scope

type Scope struct {
	Include []string `json:"include"`
	Exclude []string `json:"exclude"`
}

type Settings

type Settings struct {
	Learning  Learning        `json:"learning"`
	BreakLogs CaptureSettings `json:"break_logs"`
	Alerts    Alerts          `json:"alerts"`
}

type SettingsState

type SettingsState struct {
	Settings Settings          `json:"settings"`
	Health   map[string]Health `json:"health"`
}

func LoadSettings

func LoadSettings(provider storage.Provider, key string) (SettingsState, error)

type Snapshot

type Snapshot struct {
	BreakAt       time.Time `json:"break_at,omitempty"`
	ID            string    `json:"id"`
	Cluster       string    `json:"cluster"`
	Namespace     string    `json:"namespace"`
	RootUID       string    `json:"root_uid"`
	Pod           string    `json:"pod"`
	PodUID        string    `json:"pod_uid"`
	PodCreatedAt  time.Time `json:"pod_created_at,omitempty"`
	Container     string    `json:"container"`
	Init          bool      `json:"init"`
	Slot          string    `json:"slot"`
	TerminationAt time.Time `json:"termination_at,omitempty"`
	Restarts      int32     `json:"restarts"`
	CapturedAt    time.Time `json:"captured_at"`
	From          time.Time `json:"from"`
	To            time.Time `json:"to"`
	Lines         []Line    `json:"lines"`
	Truncated     bool      `json:"truncated"`
}

type Source

type Source struct {
	Name      string                             `json:"name"`
	Type      string                             `json:"type"`
	Scope     string                             `json:"scope"`
	Health    string                             `json:"health"`
	CheckedAt *time.Time                         `json:"checked_at,omitempty"`
	Build     func(Fields) (LinkedReader, error) `json:"-"`
}

type State

type State struct {
	Snapshots []Snapshot           `json:"snapshots"`
	Gaps      []Gap                `json:"gaps"`
	Jobs      map[string]time.Time `json:"jobs,omitempty"`
}

Jump to

Keyboard shortcuts

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