breaklogs

package
v1.4.35 Latest Latest
Warning

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

Go to latest
Published: Nov 8, 2026 License: MIT Imports: 13 Imported by: 0

Documentation

Index

Constants

View Source
const AllContainers = "*"

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

View Source
const ClockTolerance = 5 * time.Second

ClockTolerance permits bounded replica skew without rewriting evidence time.

View Source
const MaxBytes = 8 << 20
View Source
const MaxHistoryBytesPerRoot = 64 << 10
View Source
const MaxHistoryPodsPerRoot = 2 * MaxManifestPods
View Source
const MaxManifestPods = 20
View Source
const MaxMetadataBytes = 2 << 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 AdmitLinkedCall added in v1.4.34

func AdmitLinkedCall(ctx context.Context) bool

AdmitLinkedCall is shared by all pod reads and time splits in one query.

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 ManifestIdentity added in v1.4.34

func ManifestIdentity(root string, at time.Time) string

func Merge

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

func MergeManifests added in v1.4.34

func MergeManifests(state *State, incoming []Manifest, now time.Time) error

func NextCursor

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

func ObservePods added in v1.4.34

func ObservePods(state *State, pods []ManifestPod, now time.Time)

ObservePods retains only verified owner-chain metadata from complete inventory. Unknown lifetimes remain unknown; a name or workload prefix is never proof.

func PodPriority added in v1.4.34

func PodPriority(pod ManifestPod) int

PodPriority orders irreplaceable retired identity, broken live identity, then resampleable healthy live identity, both globally and within each workload.

func ResolveLinkedLine added in v1.4.34

func ResolveLinkedLine(pods []ManifestPod, line LinkedLine) (ManifestPod, ManifestContainer, bool)

ResolveLinkedLine refuses overlapping same-name UIDs and unobserved restarts.

func SettingsKey

func SettingsKey(org, cluster string) string

func TerminationEnd added in v1.4.34

func TerminationEnd(at time.Time) time.Time

TerminationEnd includes the complete second reported by Kubernetes status, whose whole-second timestamps bound nanosecond kubelet log timestamps.

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"`
	IngestDelay  *int              `json:"ingest_delay,omitempty"`
}

func (CaptureSettings) IngestionDelay added in v1.4.34

func (settings CaptureSettings) IngestionDelay(kind string) time.Duration

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 {
	ReadyAt    time.Time `json:"ready_at,omitempty,omitzero"`
	SnapshotID string    `json:"snapshot_id,omitempty"`
	ObservedAt time.Time `json:"observed_at,omitempty,omitzero"`
	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 Manifest added in v1.4.34

type Manifest struct {
	ID            string        `json:"id"`
	OccurrenceID  string        `json:"occurrence_id,omitempty"`
	Namespace     string        `json:"namespace"`
	RootUID       string        `json:"root_uid"`
	BreakAt       time.Time     `json:"break_at"`
	From          time.Time     `json:"from"`
	To            time.Time     `json:"to"`
	CapturedAt    time.Time     `json:"captured_at"`
	Pods          []ManifestPod `json:"pods"`
	Truncated     bool          `json:"truncated,omitempty"`
	SettleAt      time.Time     `json:"settle_at,omitempty,omitzero"`
	Attempts      int           `json:"attempts"`
	Done          bool          `json:"done,omitempty"`
	SettlingUntil time.Time     `json:"settling_until,omitempty,omitzero"`
	SettleEpoch   time.Time     `json:"settle_epoch,omitempty,omitzero"`
}

Manifest contains identity evidence, never labels, environment or log text.

type ManifestContainer added in v1.4.34

type ManifestContainer struct {
	Name                string    `json:"name"`
	Init                bool      `json:"init,omitempty"`
	Restarts            int32     `json:"restarts"`
	StartedAt           time.Time `json:"started_at,omitempty,omitzero"`
	TerminationAt       time.Time `json:"termination_at,omitempty,omitzero"`
	TerminationReason   string    `json:"termination_reason,omitempty"`
	TerminationExitCode int32     `json:"termination_exit_code,omitempty"`
	PreviousStartedAt   time.Time `json:"previous_started_at,omitempty,omitzero"`
	CurrentTermination  bool      `json:"current_termination,omitempty"`
	CurrentEndedAt      time.Time `json:"current_ended_at,omitempty,omitzero"`
}

type ManifestPod added in v1.4.34

type ManifestPod struct {
	Namespace string    `json:"namespace"`
	RootUID   string    `json:"root_uid"`
	Name      string    `json:"name"`
	UID       string    `json:"uid"`
	Node      string    `json:"node,omitempty"`
	Broken    bool      `json:"broken,omitempty"`
	CreatedAt time.Time `json:"created_at"`
	// LastSeen bounds a vanished pod when its exact deletion time is unknown.
	// A later complete inventory proves absence, not survival until that LIST.
	LastSeen   time.Time           `json:"last_seen"`
	DeletedAt  time.Time           `json:"deleted_at,omitempty,omitzero"`
	Containers []ManifestContainer `json:"containers"`
}

type Query

type Query struct {
	OccurrenceID                                    string
	Center                                          time.Time
	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 ReadError added in v1.4.34

type ReadError struct {
	Class string
}

ReadError is a safe upstream class. It deliberately contains neither the upstream response body nor credential-bearing transport/configuration text.

func (*ReadError) Error added in v1.4.34

func (err *ReadError) Error() string

type Result

type Result struct {
	Lines     []LinkedLine
	Truncated bool
	Complete  []Gap
	Rejected  bool
}

func ReadWindow added in v1.4.34

func ReadWindow(ctx context.Context, reader LinkedReader, query LinkedQuery) (Result, error)

ReadWindow spends a whole-query budget, not a per-split line budget. Only disjoint, non-truncated leaves can claim coverage. Three logical queries and 6000 returned lines are ceilings, not a promise of completeness. Native adapters batch the verified Pod set in each query and separately bound pages/lifecycle requests; truncation leaves explicit gaps.

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 {
	Source              string    `json:"source,omitempty"`
	OccurrenceID        string    `json:"occurrence_id,omitempty"`
	BreakAt             time.Time `json:"break_at,omitempty,omitzero"`
	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,omitzero"`
	Container           string    `json:"container"`
	Init                bool      `json:"init"`
	Slot                string    `json:"slot"`
	TerminationAt       time.Time `json:"termination_at,omitempty,omitzero"`
	TerminationReason   string    `json:"termination_reason,omitempty"`
	TerminationExitCode int32     `json:"termination_exit_code,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 {
	CacheKey  string                             `json:"-"`
	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 {
	PodHistoryAt          time.Time            `json:"pod_history_at,omitempty,omitzero"`
	PodHistoryTruncatedAt time.Time            `json:"pod_history_truncated_at,omitempty,omitzero"`
	PodHistoryGaps        []Gap                `json:"pod_history_gaps,omitempty"`
	Manifests             []Manifest           `json:"manifests,omitempty"`
	PodHistory            []ManifestPod        `json:"pod_history,omitempty"`
	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