Documentation
¶
Overview ¶
Package obs holds the runtime's observability primitives shared by the lord and the Go SDK: structured logging and the in-process metric registry. Logs and metrics are configured from the environment so that a thrall (a child OS process) inherits the same setup the lord injects, without any per-SDK wiring.
Index ¶
- Constants
- func ClampHeartbeatIntervalMs(ms int) int
- func HeartbeatInterval() time.Duration
- func LevelFromEnv() slog.Level
- func NewLogger() *slog.Logger
- func NewWithWriter(w io.Writer) *slog.Logger
- type Metrics
- func (m *Metrics) Add(name string, labels map[string]string, delta float64)
- func (m *Metrics) Counter(name, help string)
- func (m *Metrics) Delete(name string, labels map[string]string)
- func (m *Metrics) Gauge(name, help string)
- func (m *Metrics) Inc(name string, labels map[string]string)
- func (m *Metrics) Set(name string, labels map[string]string, value float64)
- func (m *Metrics) WriteText(w io.Writer) error
Constants ¶
const ( // DefaultHeartbeatIntervalMs is the heartbeat interval when unset (the historical 2s). DefaultHeartbeatIntervalMs = 2000 // MinHeartbeatIntervalMs floors the interval so a typo cannot flood the bus / peg the CPU. MinHeartbeatIntervalMs = 100 )
const ( EnvLogLevel = "AETHER_LOG_LEVEL" // debug | info | warn | error (default info) EnvLogFormat = "AETHER_LOG_FORMAT" // json | text (default text) )
Environment variables that configure logging. The lord reads them for itself and injects them into every thrall it spawns, so the whole tree logs consistently.
const EnvHeartbeatIntervalMs = "AETHER_HEARTBEAT_INTERVAL_MS"
EnvHeartbeatIntervalMs is the environment variable the lord injects into a thrall so its SDK heartbeats at the manifest-configured interval; the lord derives its reaper threshold from the same value, so the two never drift.
Variables ¶
This section is empty.
Functions ¶
func ClampHeartbeatIntervalMs ¶
ClampHeartbeatIntervalMs normalizes a configured interval in milliseconds: a non-positive value falls back to the default, and a too-small value is raised to the minimum floor.
func HeartbeatInterval ¶
HeartbeatInterval resolves the SDK heartbeat interval from the environment (empty or invalid -> default, clamped to the minimum). Used by the Go SDK; the TS/Python SDKs mirror it.
func LevelFromEnv ¶
LevelFromEnv resolves AETHER_LOG_LEVEL to a slog.Level. An empty or unknown value falls back to info, so a typo never silences the runtime.
Types ¶
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics is a minimal in-process metric registry that renders Prometheus text exposition. It deliberately avoids a client library: the runtime needs only counters and gauges with a small label set, and hand-rolling the exposition keeps the dependency surface thin and the model exporter-agnostic (an OTLP bridge could read the same registry later).
A metric is identified by its name plus its label set; the same name may carry many label combinations (one series each). All operations are safe for concurrent use.
func (*Metrics) Add ¶
Add adds delta to the series identified by name+labels (creating it at zero first).
func (*Metrics) Counter ¶
Counter registers (once) a counter metric with help text. Registering the same name twice is a no-op, so callers can declare metrics wherever they are first used.
func (*Metrics) Delete ¶
Delete removes the series identified by name+labels (the metric itself stays registered). Unknown series are ignored. Used to drop a stopped thrall's per-name series so they do not linger in the exposition with a frozen value.