Documentation
¶
Overview ¶
Package diagnostics exposes bounded, payload-free operational views through ordinary authenticated Foundry routes. It owns no listeners or dependencies.
Index ¶
- Constants
- func Module(name foundation.ProviderID, key foundation.Key[*Runtime], ...) foundation.Module
- func PublicProbe(runtime *Runtime, id foundryhttp.RouteID, path string, endpoint Endpoint, ...) foundryhttp.RouteRegistration
- func Route[M any](runtime *Runtime, route foundryhttp.AuthenticatedRoute[foundryhttp.NoPath, M], ...) foundryhttp.RouteRegistration
- type Config
- type Endpoint
- type LivenessReport
- type PublicProbeOption
- type ReadinessReport
- type Runtime
- type Snapshot
Constants ¶
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.
const DefaultReadinessCache = time.Second
DefaultReadinessCache is how long a public readiness route reuses one dependency check.
Variables ¶
This section is empty.
Functions ¶
func Module ¶
func Module(name foundation.ProviderID, key foundation.Key[*Runtime], probes foundation.Key[*health.Registry], config Config, requires []foundation.ProviderID) foundation.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 ¶
func Route[M any](runtime *Runtime, route foundryhttp.AuthenticatedRoute[foundryhttp.NoPath, M], endpoint Endpoint) foundryhttp.RouteRegistration
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 ¶
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.
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 ¶
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.
type Snapshot ¶
type Snapshot struct {
State foundation.State `json:"state"`
Observations observability.Snapshot `json:"observations"`
}
Snapshot contains application state and observability data.