observability

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Sep 4, 2026 License: Apache-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package observability owns Astrate's Prometheus registry and the health/readiness/metrics HTTP surface under /astrate/v1 (docs/DESIGN.md §5.2). The engine and trigger executor self-register their collectors through Registerer(); the broker-session and DB-pool gauges are attached from caller-supplied closures, so this package imports neither the broker nor the store and stays at the top of the dependency order.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func MountServiceCompat added in v0.2.0

func MountServiceCompat(mux *http.ServeMux, service string, check Check)

MountServiceCompat registers the upstream-parity unauthenticated GET /{service}/health endpoint. The Astarte Dashboard polls one per service (appengine, realmmanagement, pairing) for its API status indicators; only the status code matters to it, but the body mirrors upstream's envelope.

Deliberate deviation 18 (docs/COMPATIBILITY.md): upstream answers a static 200 here, so the indicator it feeds cannot ever go red. Astrate runs check — the same dependency probe that backs /astrate/v1/readiness — and answers 503 when it fails, which is strictly safer for whoever is reading the Dashboard. A nil check keeps upstream's static 200.

func MountVersionCompat added in v0.2.0

func MountVersionCompat(mux *http.ServeMux, service, version string)

MountVersionCompat registers GET /{service}/version for one service.

func VersionHandler added in v0.2.0

func VersionHandler(version string) http.HandlerFunc

VersionHandler answers GET .../version with the upstream envelope {"data":"<version>"} (measured upstream 1.2.0, verify-versions.json).

Types

type Check

type Check func(ctx context.Context) error

Check reports a dependency's readiness; a nil error means ready. The store DB ping and a broker-listener check are the two §5.2 readiness backends.

type DBPoolStats

type DBPoolStats struct {
	AcquiredConns int32
	IdleConns     int32
	TotalConns    int32
	MaxConns      int32
}

DBPoolStats is the subset of pgxpool.Stat exposed as gauges; the caller maps store.Stat() onto it (keeping pgx out of this package).

type Health

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

Health is the Astrate-native operational surface (docs/DESIGN.md §5.2): liveness, readiness, and the Prometheus scrape endpoint, all under /astrate/v1 so they never collide with the upstream API namespace.

func NewHealth

func NewHealth(metrics http.Handler) *Health

NewHealth builds the surface around an existing metrics handler.

func (*Health) AddReadiness

func (h *Health) AddReadiness(name string, check Check)

AddReadiness registers a named dependency probed by /readiness.

func (*Health) Mount

func (h *Health) Mount(mux *http.ServeMux)

Mount registers the endpoints on mux.

type Metrics

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

Metrics owns the process-wide Prometheus registry.

func NewMetrics

func NewMetrics() *Metrics

NewMetrics builds a registry preloaded with the Go runtime and process collectors (go_*, process_* — the RSS/GC budget of §5.4 reads them).

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler serves the registry in the Prometheus text exposition format.

func (*Metrics) RegisterBrokerSessions

func (m *Metrics) RegisterBrokerSessions(fn func() float64)

RegisterBrokerSessions publishes astrate_broker_sessions, read on scrape from fn (broker.SessionCount).

func (*Metrics) RegisterDBPool

func (m *Metrics) RegisterDBPool(fn func() DBPoolStats)

RegisterDBPool publishes the astrate_db_pool_* gauges, read on scrape from fn (a snapshot of store.Stat()).

func (*Metrics) Registerer

func (m *Metrics) Registerer() prometheus.Registerer

Registerer is the engine's Prometheus.Registerer (engine + executor + stream bus collectors attach here).

Jump to

Keyboard shortcuts

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