Documentation
¶
Overview ¶
Package metrics provides shared Prometheus metrics helpers for the unbounded-net controller and node agent.
Index ¶
Constants ¶
const LabelController = "controller"
LabelController is the standard label key for identifying a controller.
const LabelResult = "result"
LabelResult is the standard label key for operation outcomes.
Variables ¶
var DefaultDurationBuckets = []float64{
0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 120,
}
DefaultDurationBuckets are histogram buckets suited for observing operation durations (e.g., reconciliation loops, network configuration). The range covers 5ms to 120s.
var DefaultSizeBuckets = []float64{
256, 1024, 4096, 16384, 65536, 262144, 1048576, 4194304, 10485760,
}
DefaultSizeBuckets are histogram buckets for observing byte sizes (e.g., HTTP response bodies, status push payloads). The range covers 256B to 10MB.
Functions ¶
func NewHistogramVec ¶
func NewHistogramVec(opts prometheus.HistogramOpts, labelNames []string) *prometheus.HistogramVec
NewHistogramVec is a convenience wrapper around prometheus.NewHistogramVec that uses DefaultDurationBuckets when no custom Buckets are set.
func RegisterClientGoMetrics ¶
func RegisterClientGoMetrics()
RegisterClientGoMetrics wires up the Kubernetes client-go REST client and workqueue metrics so they are exposed via the Prometheus default registry. Call this before creating any Kubernetes clients or workqueues.
Types ¶
type HTTPMiddleware ¶
type HTTPMiddleware struct {
// contains filtered or unexported fields
}
HTTPMiddleware holds the Prometheus metrics for HTTP handler instrumentation.
func NewHTTPMiddleware ¶
func NewHTTPMiddleware(namespace string) *HTTPMiddleware
NewHTTPMiddleware returns counters and histogram for HTTP handler instrumentation with the given metric namespace prefix. The returned InstrumentHandler wraps an http.Handler to record request count and duration.
This function is safe to call multiple times with the same namespace; subsequent calls return a middleware backed by the same collectors.
func (*HTTPMiddleware) Wrap ¶
Wrap returns an http.Handler that records metrics and delegates to next.
func (*HTTPMiddleware) WrapFunc ¶
func (m *HTTPMiddleware) WrapFunc(path string, next http.HandlerFunc) http.Handler
WrapFunc is a convenience method that wraps an http.HandlerFunc.