Documentation
¶
Overview ¶
Package obs provides the local observability HTTP server for sqi-worker.
The server listens on a loopback address (default 127.0.0.1:9091) so it is accessible to local monitoring agents and container orchestrators without being reachable from the network.
Endpoints ¶
- GET /healthz — liveness probe; always 200 while the HTTP event loop runs.
- GET /readyz — readiness probe; 200 when all registered [health.Checker]s pass, 503 when any fail (e.g. NATS connection is down).
- GET /metrics — Prometheus text/OpenMetrics exposition.
- GET /debug/pprof/* — Go runtime profiling (only when pprof is enabled).
Usage ¶
srv := obs.New(cfg, logger, metrics, health) go srv.Run(ctx) // starts listening; returns when ctx is canceled // ... after work is done ... srv.Shutdown(ctx) // graceful stop
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is the local observability HTTP server for sqi-worker. Create with New; start with [Run]; stop with [Shutdown].
func New ¶
func New( addr string, enablePprof bool, logger *slog.Logger, m *workmetrics.Metrics, h *health.Registry, tlsCfg TLSConfig, ) *Server
New creates a *Server with the given configuration.
- addr — TCP listen address, e.g. "127.0.0.1:9091"
- enablePprof — when true, registers /debug/pprof/* endpoints
- logger — used for request logging and startup/shutdown messages
- m — worker Prometheus metrics; /metrics serves this registry
- h — health registry consulted by /readyz
- tlsCfg — optional TLS termination; zero value serves plaintext
func (*Server) Run ¶
Run starts the HTTP server and blocks until the listener stops, which happens when Server.Shutdown is called, not when ctx is canceled. Canceling ctx alone stops the uptime goroutine and leaves the listener serving.
Run also starts a background goroutine that refreshes the uptime metric on [uptimeTick] intervals; that goroutine does exit when ctx is canceled.
type TLSConfig ¶ added in v0.4.0
TLSConfig terminates TLS on the worker's observability listener.
This listener serves metrics, health and optionally pprof. It defaults to loopback, where plaintext is fine, but an operator scraping it from Prometheus has to bind it wider, and then everything on it, pprof included, crosses the network in the clear. The zero value serves plaintext.