ring

package
v0.4.2 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: MIT Imports: 1 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Ring

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

Ring is a fixed size ring buffer of completed traces. The slots are allocated once and rewritten in place, so retention costs no allocation per trace. It is not safe for concurrent use; the tracer holds its lock around every call.

func New

func New(size int) *Ring

New returns a ring buffer retaining size traces. A size of zero retains nothing.

func (*Ring) Cap

func (r *Ring) Cap() int

Cap returns the retention limit.

func (*Ring) Find

func (r *Ring) Find(id string) (*model.Trace, bool)

Find returns the retained trace with the given ID.

func (*Ring) Len

func (r *Ring) Len() int

Len returns the number of retained traces.

func (*Ring) List

func (r *Ring) List() []*model.Trace

List returns the retained traces, newest first. The pointers alias the ring slots, so they are valid until the next Push; callers copy the values out under the lock they hold around every call.

func (*Ring) Push

func (r *Ring) Push(t *model.Trace) bool

Push clones a trace into the next slot, overwriting the oldest one when the buffer is full. The clone reuses the evicted slot's allocations, so steady state retention allocates nothing; the pointer is not kept. It reports whether a trace was evicted.

func (*Ring) Reset

func (r *Ring) Reset()

Reset drops every retained trace.

Jump to

Keyboard shortcuts

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