retention

package
v2.16.0 Latest Latest
Warning

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

Go to latest
Published: Nov 27, 2026 License: MIT Imports: 5 Imported by: 0 modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

Documentation

Overview

Package retention deletes old events in the background when the config asks for it. By default nothing is deleted.

Index

Constants

View Source
const Interval = time.Minute

Interval is how often the cleaner runs.

Variables

This section is empty.

Functions

This section is empty.

Types

type Cleaner

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

Cleaner applies a Policy. Deletes go through the store, so attachments and module data go with the events, as with a delete from the UI.

func New

func New(db *sql.DB, store event.Store, policy Policy, onDeleted func(uuid, project string), pruners ...Pruner) *Cleaner

New returns a cleaner. onDeleted (may be nil) is called for each deleted event, so open UIs drop it. pruners age out rows with no event card when MaxAge is set.

func (*Cleaner) Run

func (c *Cleaner) Run(ctx context.Context)

Run cleans at once and then every Interval until ctx is done.

func (*Cleaner) RunOnce

func (c *Cleaner) RunOnce(ctx context.Context) (int, error)

RunOnce deletes what the policy allows to delete and returns how many rows went: events, and with MaxAge the pruners' rows.

type Policy

type Policy struct {
	MaxAge    time.Duration // delete events older than this
	MaxEvents int           // keep at most this many unpinned events, newest first
}

Policy says what to delete. Zero values switch a rule off; pinned events are never deleted and do not count towards MaxEvents.

func (Policy) On

func (p Policy) On() bool

On reports whether any rule is set.

type Pruner

type Pruner interface {
	PruneBefore(ctx context.Context, cutoff time.Time) (int, error)
}

Pruner deletes rows that have no event card older than cutoff (Sentry logs, metrics, traces); module.AgePruner satisfies it.

Jump to

Keyboard shortcuts

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