metrics

package
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 23, 2026 License: MIT Imports: 11 Imported by: 0

Documentation

Overview

Package metrics provides shared Prometheus metrics helpers for the unbounded-net controller and node agent.

Index

Constants

View Source
const LabelController = "controller"

LabelController is the standard label key for identifying a controller.

View Source
const LabelResult = "result"

LabelResult is the standard label key for operation outcomes.

Variables

View Source
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.

View Source
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 Handler

func Handler() http.Handler

Handler returns the default Prometheus HTTP handler for the /metrics endpoint.

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 Register

func Register(mux *http.ServeMux)

Register adds the /metrics endpoint to the given ServeMux.

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

func (m *HTTPMiddleware) Wrap(path string, next http.Handler) http.Handler

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.

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL