Documentation
¶
Overview ¶
Package metrics provides a lightweight HTTP server for per-component Prometheus metrics with isolated registries.
Index ¶
- type Server
- func (s *Server) MeterProvider() *sdkmetric.MeterProvider
- func (s *Server) RegisterHeartbeatAge(timeFn func() time.Time)
- func (s *Server) RegisterSubsystems(subsystems []SubsystemStatus)
- func (s *Server) SetReadinessFunc(fn func() error)
- func (s *Server) Start()
- func (s *Server) Stop(ctx context.Context)
- type SubsystemStatus
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 a per-component HTTP server that serves /metrics, /health, and /health/ready with an isolated Prometheus registry and OTEL MeterProvider.
func New ¶
New creates a new metrics server on the given port with an isolated Prometheus registry and OTEL MeterProvider.
func (*Server) MeterProvider ¶
func (s *Server) MeterProvider() *sdkmetric.MeterProvider
MeterProvider returns the isolated OTEL MeterProvider for this server. Components use this to create instruments that appear on this server's /metrics endpoint.
func (*Server) RegisterHeartbeatAge ¶
RegisterHeartbeatAge registers an osapi_heartbeat_age_seconds gauge that reports the time since the last successful heartbeat write. The timeFn should return the timestamp of the last heartbeat, or zero time if none.
func (*Server) RegisterSubsystems ¶
func (s *Server) RegisterSubsystems( subsystems []SubsystemStatus, )
RegisterSubsystems registers an osapi_subsystem_up gauge that reports 1 when each subsystem status function returns "ok" and 0 otherwise. All subsystems are emitted in a single callback with a "subsystem" attribute.
func (*Server) SetReadinessFunc ¶
SetReadinessFunc sets a function called by /health/ready to determine whether this component is ready to serve traffic. If fn returns an error the endpoint responds 503; if nil it responds 200.
type SubsystemStatus ¶
SubsystemStatus holds a subsystem name and a function that returns its current status string (e.g., "ok", "disabled", "error").