Documentation
¶
Overview ¶
Package tsdb defines the embedded time-series store contract (spec §3.10): per-series ring buffers, 15s raw resolution for 24h + 5m downsampled for 30d. Implementation is task T-59; the fake lives in testutil.
Index ¶
Constants ¶
const ( RawStep = 15 * time.Second RawRetention = 24 * time.Hour DownStep = 5 * time.Minute DownRetention = 30 * 24 * time.Hour )
Resolutions stored by the ring TSDB.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Config ¶
type Config struct {
// Path is the flat file the rings persist to. Empty disables persistence
// (in-memory only, e.g. tests).
Path string
Clock clock.Clock
Logger *slog.Logger
}
Config configures a RingStore.
type RingStore ¶
type RingStore struct {
// contains filtered or unexported fields
}
RingStore is the on-node ring TSDB (spec §3.10). Zero series persist to a flat file; a background goroutine flushes every 60s until Close.
func Open ¶
Open builds a RingStore, loading any existing file (a missing or corrupt file starts empty with a warning) and starting the periodic flusher.
func (*RingStore) Flush ¶
Flush garbage-collects stale series then persists the rings to disk. A no-op when persistence is disabled (empty Path).
func (*RingStore) Keys ¶
Keys lists series matching a scope filter. Empty scope matches all; empty scopeID matches all ids within the scope.
type SeriesKey ¶
type SeriesKey struct {
// Metric name: "cpu_percent", "memory_bytes", "rps", ...
Metric string
// Scope: "node", "instance", "env", "app".
Scope string
// ID of the scoped object.
ScopeID string
}
SeriesKey identifies one series.
type Store ¶
type Store interface {
// Record adds a sample (typically every 15s per series). Out-of-order
// samples older than the current slot are dropped.
Record(key SeriesKey, p Point)
// Query returns points in [since, until] at the best-fitting resolution
// for step (RawStep or DownStep).
Query(key SeriesKey, since, until time.Time, step time.Duration) []Point
// Keys lists series matching a scope filter ("" matches all).
Keys(scope, scopeID string) []SeriesKey
// Flush persists ring state to disk (called periodically and on stop).
Flush() error
Close() error
}
Store is the per-node TSDB.