observability

package
v19.4.0 Latest Latest
Warning

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

Go to latest
Published: Sep 16, 2026 License: MIT Imports: 15 Imported by: 0

Documentation

Index

Constants

View Source
const (
	ModuleName = "observability"
)

Variables

View Source
var ErrNotEvaluated = fmt.Errorf("%w: probes have not run", ErrNotReady)

ErrNotEvaluated is what Readiness returns before the probes have run for the first time. Seeing it for longer than that means nothing is running the ProbeRegistry.

View Source
var ErrNotReady = errors.New("not ready")

ErrNotReady is what readiness probes return for expected states, e.g. before startup has finished or once shutdown has started. The readiness endpoint logs these rather than reporting them as processing errors, which would send one event per health check to Sentry on every deploy.

View Source
var ErrShuttingDown = fmt.Errorf("%w: shutting down", ErrNotReady)

ErrShuttingDown is what Readiness returns once readiness has been withdrawn.

Functions

This section is empty.

Types

type MetricServer

type MetricServer struct {
	Log *slog.Logger
	API modshared.API
	// Name is the name of the application.
	Name                  string
	Listener              net.Listener
	PrometheusURLPath     string
	LivenessProbeURLPath  string
	ReadinessProbeURLPath string
	Gatherer              prometheus.Gatherer
	Registerer            prometheus.Registerer
	ProbeRegistry         *ProbeRegistry
}

func (*MetricServer) ConstructHandler

func (s *MetricServer) ConstructHandler() http.Handler

func (*MetricServer) Run

func (s *MetricServer) Run(ctx context.Context) error

type Probe

type Probe func(context.Context) error

Probe is the expected type for probe functions

type ProbeRegistry

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

func NewProbeRegistry

func NewProbeRegistry() *ProbeRegistry

func (*ProbeRegistry) Liveness

func (p *ProbeRegistry) Liveness(ctx context.Context) error

func (*ProbeRegistry) Readiness

func (p *ProbeRegistry) Readiness() error

Readiness returns the verdict of the last probe run. Reading it is a memory access: readiness is served to whoever can reach the health endpoints, so a caller must not be able to drive a probe run - and a Redis round trip - per request. Every caller gets the same verdict, so all health endpoints agree.

Run() has to be running for the verdict to be updated.

func (*ProbeRegistry) Refresh added in v19.4.0

func (p *ProbeRegistry) Refresh(ctx context.Context)

Refresh runs the readiness probes and updates the verdict. Runs are serialized, so concurrent calls cannot publish out of order.

func (*ProbeRegistry) RegisterLivenessProbe

func (p *ProbeRegistry) RegisterLivenessProbe(key string, probe Probe)

func (*ProbeRegistry) RegisterReadiness added in v19.4.0

func (p *ProbeRegistry) RegisterReadiness(key string) *Readiness

RegisterReadiness registers a readiness probe for a component that reports its own readiness. The component is not ready until it says so, and can say it is not ready again, e.g. when it starts shutting down.

func (*ProbeRegistry) RegisterReadinessProbe

func (p *ProbeRegistry) RegisterReadinessProbe(key string, probe Probe)

func (*ProbeRegistry) Run added in v19.4.0

func (p *ProbeRegistry) Run(ctx context.Context) error

Run refreshes the readiness verdict until ctx is done.

func (*ProbeRegistry) WithdrawReadiness added in v19.4.0

func (p *ProbeRegistry) WithdrawReadiness()

WithdrawReadiness makes Readiness report that this instance is shutting down. It doesn't run the probes, so it takes effect immediately rather than at the end of a probe run, and it can't be undone: an instance that has begun shutting down doesn't become ready again.

type Readiness added in v19.4.0

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

Readiness is the readiness of one component, reported by the probe registered alongside it.

func (*Readiness) SetNotReady added in v19.4.0

func (r *Readiness) SetNotReady()

func (*Readiness) SetReady added in v19.4.0

func (r *Readiness) SetReady()

Directories

Path Synopsis

Jump to

Keyboard shortcuts

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