Documentation
¶
Index ¶
Constants ¶
View Source
const ( // LevelTrace is a verbosity level below debug used for deep troubleshooting. LevelTrace = slog.Level(-8) )
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type PeriodicStatsSnapshot ¶ added in v1.0.6
type PeriodicStatsSnapshot[T any] struct { Stats T WindowStart time.Time WindowEnd time.Time WindowDuration time.Duration }
PeriodicStatsSnapshot captures a flushed periodic stats window.
type PeriodicStatsWindow ¶ added in v1.0.6
type PeriodicStatsWindow[T any] struct { // contains filtered or unexported fields }
PeriodicStatsWindow tracks stats samples and emits a snapshot at a bounded cadence.
When emitFirst is false, the first sample starts the cadence window and the first flush occurs once interval has elapsed.
When emitFirst is true, the first sample flushes immediately, then subsequent samples follow the interval cadence.
func NewPeriodicStatsWindow ¶ added in v1.0.6
func NewPeriodicStatsWindow[T any](emitFirst bool, mergeFn func(*T, T)) *PeriodicStatsWindow[T]
NewPeriodicStatsWindow builds a periodic tracker.
func (*PeriodicStatsWindow[T]) Record ¶ added in v1.0.6
func (w *PeriodicStatsWindow[T]) Record(now time.Time, interval time.Duration, sample T) (PeriodicStatsSnapshot[T], bool)
Record adds a sample into the pending window and returns a snapshot when the cadence interval is reached.
func (*PeriodicStatsWindow[T]) Reset ¶ added in v1.0.6
func (w *PeriodicStatsWindow[T]) Reset()
Reset clears pending samples and cadence state.
Click to show internal directories.
Click to hide internal directories.