limits

package
v0.8.2 Latest Latest
Warning

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

Go to latest
Published: Nov 19, 2026 License: Apache-2.0 Imports: 5 Imported by: 0

Documentation

Overview

Package limits counts hits on Snellius's own size limits and logs them, rate-limited, so operators can spot capacity problems or abuse (D-100, D-112). A record names the limit and the install, never an object or a namespace.

Index

Constants

View Source
const Message = "size limit hit"

Message is the log line's message.

View Source
const Window = time.Minute

Window is the shortest time between two log lines for one limit and install.

Variables

All lists every Limit: the counter's only label values.

Functions

This section is empty.

Types

type Limit

type Limit string

Limit names one of Snellius's own size limits: the counter's label value.

const (
	// AuthzChecks is the per-request cap on uncached permission checks (D-100).
	AuthzChecks Limit = "authz-checks"
	// DelegationEdges caps the selected delegation edges of an install (rules §5.7).
	DelegationEdges Limit = "delegation-edges"
	// DelegationContexts caps the delegation contexts computed for an install.
	DelegationContexts Limit = "delegation-contexts"
	// DelegationMatchers caps the matcher steps of an install's delegation traversal.
	DelegationMatchers Limit = "delegation-matchers"
	// DelegationDepth caps the routes on one delegation path.
	DelegationDepth Limit = "delegation-depth"
	// DelegationRetained caps the delegation contexts an install keeps for display.
	DelegationRetained Limit = "delegation-retained-contexts"
)

The limits. The delegation ones are per install, hit while a model is built.

type Recorder

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

Recorder counts every hit in snellius_limit_hits_total{limit} and logs at most one warning per limit and install per Window; an ended window's held-back hits are logged when a later line drops it. Safe for concurrent use.

func New

func New(r *obs.Registry, log *slog.Logger, now func() time.Time) *Recorder

New registers the counter on r, every limit at zero. A nil r, log or now means a private registry, slog.Default() and time.Now.

func (*Recorder) Hit

func (r *Recorder) Hit(l Limit, install, session string)

Hit records one hit of l for install. session is the request's audit ID for a request limit and "" for a compute bound. An unknown l and a nil r do nothing.

Jump to

Keyboard shortcuts

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