Documentation
¶
Overview ¶
Package metrics provides a Prometheus-compatible metrics endpoint and built-in framework metrics (HTTP request duration, active connections, etc.).
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Registry ¶
type Registry struct {
// HTTP metrics
RequestDuration *prometheus.HistogramVec
RequestsTotal *prometheus.CounterVec
ActiveRequests prometheus.Gauge
// Queue metrics
JobsProcessed *prometheus.CounterVec
JobsFailed *prometheus.CounterVec
// WebSocket metrics
WebSocketConns prometheus.Gauge
// contains filtered or unexported fields
}
Registry wraps a Prometheus registry with framework-specific metrics.
func (*Registry) Handler ¶
Handler returns the Prometheus /metrics HTTP handler, guarded by authorize.
/metrics discloses internal route names, traffic volumes, and process detail, so it must not be exposed unauthenticated. authorize runs on every scrape; return true to allow. Passing nil fails closed (every request gets 403) — to intentionally expose metrics without app-level auth (e.g. when the endpoint is isolated at the network layer), pass a function that always returns true.
func (*Registry) Middleware ¶
Middleware returns an HTTP middleware that records request duration and count.
func (*Registry) MustRegister ¶
func (r *Registry) MustRegister(cs ...prometheus.Collector)
MustRegister registers additional Prometheus collectors.