Documentation
¶
Overview ¶
Package server wires up the HTTP endpoints exposed by the exporter.
Endpoints:
GET /metrics Prometheus, never 500 GET /healthz 200 if process is alive GET /readyz 200 once every source has produced its first sync GET / landing page
Index ¶
- func Build(opts Options) *http.Server
- func BuildPprof(opts PprofOptions) *http.Server
- func BuildProbe(opts ProbeOptions) *http.Server
- func Run(ctx context.Context, srv *http.Server, logger *slog.Logger) error
- func RunPprof(ctx context.Context, srv *http.Server, logger *slog.Logger)
- type Aggregate
- type Options
- type PprofOptions
- type ProbeOptions
- type Readiness
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Build ¶
Build constructs the main *http.Server (everything the chart's /metrics scrape needs). Caller starts and stops it; exporter-toolkit wraps it for TLS / mTLS / basic_auth when webConfiguration is set.
func BuildPprof ¶
func BuildPprof(opts PprofOptions) *http.Server
BuildPprof constructs an isolated *http.Server exposing the standard net/http/pprof routes on its own dedicated ServeMux. Our metrics server (server.Build) uses a separate mux and never serves http.DefaultServeMux, so the pprof endpoints stay confined to this listener even though importing net/http/pprof unavoidably registers the same handlers on DefaultServeMux via its init().
func BuildProbe ¶
func BuildProbe(opts ProbeOptions) *http.Server
BuildProbe constructs a separate *http.Server exposing **only** /healthz and /readyz, plain HTTP — no /metrics, no auth, no TLS. It shares the Readiness latch with the main server, so /readyz reflects the same state.
Run alongside the main server when the chart sets a non-empty `--probe.listen-address`. Default unused — when the flag is empty, the binary falls back to serving probes on the main port (current behaviour).
Types ¶
type Aggregate ¶
type Aggregate struct {
// contains filtered or unexported fields
}
Aggregate collects readiness signals from N sources. The Reach method returns a function that the source's OnReady callback can call. Once all sources have called success or failure, Mark is invoked.
func NewAggregate ¶
NewAggregate prepares an Aggregate for n sources.
type Options ¶
type Options struct {
Listen string
ReadTimeout time.Duration
WriteTimeout time.Duration
Registry prometheus.Gatherer
Readiness *Readiness
Logger *slog.Logger
EnableStats bool
Stats *registry.Registry
}
Options drives the server.
type PprofOptions ¶
PprofOptions configure the optional debugging endpoint.
type ProbeOptions ¶
type ProbeOptions struct {
Listen string
ReadTimeout time.Duration
WriteTimeout time.Duration
Readiness *Readiness
}
ProbeOptions drives the probe-only server. Used when the main server is auth-gated (webConfiguration / kube-rbac-proxy sidecar) and kubelet probes can't reach /healthz on the main port over plain HTTP.