obs

package
v0.7.0 Latest Latest
Warning

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

Go to latest
Published: Aug 21, 2026 License: MIT Imports: 9 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 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

View Source
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
)
View Source
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.

View Source
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

func ClampHeartbeatIntervalMs(ms int) int

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

func HeartbeatInterval() time.Duration

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

func LevelFromEnv() slog.Level

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.

func NewLogger

func NewLogger() *slog.Logger

NewLogger builds the runtime logger from the environment, writing to stderr. Child processes inherit stderr from the lord, so lord and thrall logs land on one stream; the per-record attributes (component, app, name) keep them tellable apart.

func NewWithWriter

func NewWithWriter(w io.Writer) *slog.Logger

NewWithWriter is NewLogger with an explicit sink - used by tests to capture output. The handler format follows AETHER_LOG_FORMAT (json for machines, text for dev).

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 NewMetrics

func NewMetrics() *Metrics

NewMetrics creates an empty registry.

func (*Metrics) Add

func (m *Metrics) Add(name string, labels map[string]string, delta float64)

Add adds delta to the series identified by name+labels (creating it at zero first).

func (*Metrics) Counter

func (m *Metrics) Counter(name, help string)

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

func (m *Metrics) Delete(name string, labels map[string]string)

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.

func (*Metrics) Gauge

func (m *Metrics) Gauge(name, help string)

Gauge registers (once) a gauge metric with help text.

func (*Metrics) Inc

func (m *Metrics) Inc(name string, labels map[string]string)

Inc adds 1 to the counter series identified by name+labels.

func (*Metrics) Set

func (m *Metrics) Set(name string, labels map[string]string, value float64)

Set assigns an absolute value to the gauge series identified by name+labels.

func (*Metrics) WriteText

func (m *Metrics) WriteText(w io.Writer) error

WriteText renders the registry in Prometheus text exposition format, with metrics and their series in a stable (sorted) order so the output is deterministic.

Jump to

Keyboard shortcuts

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