Documentation
¶
Overview ¶
Package metrics is the private port: Prometheus counters and pprof, bound to loopback and nothing else.
It is a separate listener rather than a route on the public server because the two have different audiences. The public port is the internet; this one is the operator's own machine, and putting a profiler behind the same timeouts and the same address as a driver's upload would be a mistake in both directions.
There is no vendor here and no agent to install. An operator who wants dashboards points their own Prometheus at this port; one who does not, does not notice it.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// Requests counts finished HTTP requests by route and status.
Requests *prometheus.CounterVec
// RequestDuration is how long they took.
RequestDuration *prometheus.HistogramVec
// SetupAttempts counts setup token attempts, by outcome. It is the signal
// that someone is guessing at a server that has not been set up yet.
SetupAttempts *prometheus.CounterVec
// AdminLogins counts admin sign-in attempts, by outcome.
AdminLogins *prometheus.CounterVec
// DatabasePoolConns reports the pool's state, sampled when scraped.
DatabasePoolConns *prometheus.GaugeVec
// contains filtered or unexported fields
}
Registry is this server's metrics. It is its own registry rather than the default one, so that a dependency registering a collector cannot silently change what this server publishes.
func New ¶
func New() *Registry
New builds the registry with the process and Go collectors already in it.
func (*Registry) Handler ¶
Handler serves /metrics and the pprof endpoints. It is only ever mounted on the loopback listener; internal/config refuses a metrics address that is not a loopback one, so this cannot be exposed by a configuration mistake.
func (*Registry) Observe ¶
Observe records one finished request. route is the ServeMux pattern rather than the path, so a page per driver does not become a metric per driver.
func (*Registry) SamplePool ¶
SamplePool records the database pool's state.