Help us shape the future of Go! Take the 2026 Go Developer Survey

diagnostics

package
v0.5.3 Latest Latest
Warning

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

Go to latest
Published: Nov 3, 2026 License: MIT Imports: 16 Imported by: 0

Documentation

Overview

Package diagnostics exposes bounded, payload-free operational views through ordinary authenticated Foundry routes. It owns no listeners or dependencies.

Index

Constants

View Source
const (
	MaxProfileSeconds     = 20
	DefaultProfileSeconds = 5
)

Profile endpoint query parameters. name selects heap (default), goroutine, allocs, block, mutex, threadcreate, cpu or trace. seconds (1-20, default 5) bounds cpu and trace capture. debug=1 selects the text form of named profiles. One profile runs at a time per Runtime; others receive 503.

View Source
const DefaultReadinessCache = time.Second

DefaultReadinessCache is how long a public readiness route reuses one dependency check.

Variables

This section is empty.

Functions

func Module

Module borrows readiness dependencies and the application's recorder. Include the readiness provider in requires. It starts no goroutines or HTTP servers; resolve the returned service in the ordinary HTTP handler factory.

func PublicProbe

func PublicProbe(runtime *Runtime, id foundryhttp.RouteID, path string, endpoint Endpoint, options ...PublicProbeOption) foundryhttp.RouteRegistration

PublicProbe registers an unauthenticated GET route for load balancers and orchestrators. Liveness reports only whether the application is still live and performs no dependency checks. Readiness reads lifecycle and maintenance state live and answers dependencies from the result of one check reused for ReadinessCache (DefaultReadinessCache): a single request refreshes it while others receive the previous answer, so a flood of unauthenticated requests cannot multiply dependency I/O. Responses are 200 or 503 without detail. Public probes never use the diagnostics operation slots.

func Route

Route requires a concrete authenticated GET route. Configure its permissions and scopes with normal auth APIs before binding. No implicit public route, credential bypass, configuration dump or listener is created. The profiler is available only through an explicitly bound Profile route with Profiling set.

Types

type Config

type Config struct {
	MaxConcurrent int
	Profiling     bool
}

Config bounds diagnostics requests. Profiling additionally enables the Profile endpoint; it stays disabled unless explicitly configured.

func DefaultConfig

func DefaultConfig() Config

DefaultConfig returns a diagnostics concurrency limit of eight.

func (Config) Validate

func (c Config) Validate() error

Validate checks that diagnostic concurrency is between one and 64.

type Endpoint

type Endpoint string

Endpoint identifies a diagnostics endpoint.

const (
	Liveness  Endpoint = "liveness"
	Readiness Endpoint = "readiness"
	Status    Endpoint = "status"
	Metrics   Endpoint = "metrics"
	// Profile serves runtime/pprof profiles. It additionally requires
	// Config.Profiling; see ProfileQuery for the accepted parameters.
	Profile Endpoint = "profile"
)

type LivenessReport

type LivenessReport struct {
	Live  bool             `json:"live"`
	State foundation.State `json:"state"`
}

LivenessReport reports application liveness and lifecycle state.

type PublicProbeOption

type PublicProbeOption func(*publicProbeOptions) error

PublicProbeOption adjusts a public probe route.

func ReadinessCache

func ReadinessCache(ttl time.Duration) PublicProbeOption

ReadinessCache sets how long public readiness reuses one dependency check, from 100ms to one minute.

type ReadinessReport

type ReadinessReport struct {
	Ready        bool             `json:"ready"`
	State        foundation.State `json:"state"`
	Mode         maintenance.Mode `json:"mode"`
	Dependencies health.Report    `json:"dependencies"`
}

ReadinessReport reports readiness, lifecycle state, maintenance mode, and dependency health.

type Runtime

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

Runtime borrows its application recorder and readiness registry. Their owners must outlive admitted diagnostics requests. Do not copy a Runtime.

func New

func New(app *foundation.App, probes *health.Registry, config Config) (*Runtime, error)

New binds an already built app. Module supports ordinary service resolution while the app is still being assembled, binding its lifecycle at boot.

func (*Runtime) Liveness

func (r *Runtime) Liveness() LivenessReport

Liveness reads lifecycle state only. Dependency failures and reversible maintenance never cause a restart signal. A stopped app is no longer live.

func (*Runtime) Readiness

func (r *Runtime) Readiness(ctx context.Context) (ReadinessReport, error)

Readiness checks dependencies only while the app can admit new work. A shutdown/maintenance transition during the check is reflected in the result.

func (*Runtime) Snapshot

func (r *Runtime) Snapshot() Snapshot

Snapshot returns application state and observations, including the application's maintenance mode.

type Snapshot

type Snapshot struct {
	State        foundation.State       `json:"state"`
	Observations observability.Snapshot `json:"observations"`
}

Snapshot contains application state and observability data.

Jump to

Keyboard shortcuts

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