Documentation
¶
Overview ¶
Package embedded implements observe.LogStore as a lightweight in-process store that ships in runed by default. It is Core-tier: label match, line substring/regex grep, and count_over_time histograms (optionally grouped by a label dimension). It backs "every cluster gets persistent logs with zero extra services" (plan §2, §4.3).
The MVP keeps records in a bounded in-memory ring with a background retention sweeper. It is intentionally simple and lives entirely behind the observe.LogStore interface, so a purpose-built segment store (or the existing Badger store) can replace it later without touching any caller. See plan §8 (open question: embedded store engine).
Index ¶
- Constants
- type Config
- type Store
- func (s *Store) Capabilities() observe.Capabilities
- func (s *Store) Close() error
- func (s *Store) Execute(ctx context.Context, q *observe.Query) (observe.ResultStream, error)
- func (s *Store) Health(ctx context.Context) error
- func (s *Store) Labels(ctx context.Context, sel observe.Selector) ([]observe.LabelValue, error)
- func (s *Store) Len() int
- func (s *Store) Stats() observe.StoreStats
- func (s *Store) Write(ctx context.Context, batch []observe.LogRecord) error
Constants ¶
const ( // DefaultMaxRecords bounds the in-memory ring. On overflow the oldest // records are evicted first (drop-oldest), mirroring the Outbox policy. DefaultMaxRecords = 500_000 // DefaultRetention is the maximum age a record is kept before the sweeper // evicts it. Matches the runefile default of 7 days. DefaultRetention = 7 * 24 * time.Hour // DefaultQueryLimit caps returned log lines when a Query sets Limit=0. DefaultQueryLimit = 1000 )
Defaults can be overridden via Config.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// MaxRecords bounds the in-memory ring. Zero uses DefaultMaxRecords.
MaxRecords int
// Retention is the max record age. Zero uses DefaultRetention; negative
// disables age-based eviction (only the size bound applies).
Retention time.Duration
// Logger; defaults to the global logger with component "observe.embedded".
Logger log.Logger
// Dir, when non-empty, enables disk persistence: the store writes a
// write-ahead log under this directory (node-local, under the runed data
// dir) and replays it on startup so logs survive a runed restart. Empty =
// in-memory only (tests, ephemeral). Persistence is best-effort — a disk
// failure logs a warning and degrades to in-memory rather than erroring.
Dir string
// MaxDiskBytes is the hard cap on WAL disk usage (drop-oldest segments).
// Zero uses the package default. Only applies when Dir is set.
MaxDiskBytes int64
// contains filtered or unexported fields
}
Config configures the embedded store.
type Store ¶
type Store struct {
// contains filtered or unexported fields
}
Store is the embedded, in-process observe.LogStore.
func New ¶
New constructs an embedded store and starts its retention sweeper. Call Close to stop the sweeper.
func (*Store) Capabilities ¶
func (s *Store) Capabilities() observe.Capabilities
Capabilities reports the embedded store handshake: Core tier only. No raw SQL, no percentiles, no cheap high-cardinality filters.
func (*Store) Execute ¶
Execute runs a Core-tier query against the in-memory ring. RawSQL is rejected (Advanced tier only). Metric queries (Aggregation set) yield a count/rate/ bytes histogram; everything else yields filtered log rows.
func (*Store) Labels ¶
Labels enumerates label names (Selector.Name == "") or the values of a named dimension, ranked by occurrence count. Honours Selector.Match and the time window.
func (*Store) Stats ¶
func (s *Store) Stats() observe.StoreStats
Stats reports the store's current footprint for the dashboard Sources page.