// Package metrics exposes Prometheus counters/gauges/histograms for HTTP, // TCP/UDP, backend, and TLS activity. package metrics import ( "net/http" "github.com/prometheus/client_golang/prometheus" "github.com/prometheus/client_golang/prometheus/promauto" "github.com/prometheus/client_golang/prometheus/promhttp" ) var ( HTTPRequestsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "vibeproxy_http_requests_total", Help: "Total HTTP requests handled by the proxy.", }, []string{"proxy_host", "method", "status"}) HTTPRequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "vibeproxy_http_request_duration_seconds", Help: "HTTP request latency observed by the proxy, end to end.", Buckets: prometheus.DefBuckets, }, []string{"proxy_host"}) BackendRequestDuration = promauto.NewHistogramVec(prometheus.HistogramOpts{ Name: "vibeproxy_backend_request_duration_seconds", Help: "Backend response latency as observed by the proxy.", Buckets: prometheus.DefBuckets, }, []string{"proxy_host", "backend"}) BytesTransferred = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "vibeproxy_bytes_transferred_total", Help: "Bytes transferred through the proxy.", }, []string{"direction", "protocol"}) // direction=in|out, protocol=http|tcp|udp ActiveConnections = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "vibeproxy_active_connections", Help: "Currently active connections.", }, []string{"protocol"}) // http|tcp|udp BackendHealth = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "vibeproxy_backend_healthy", Help: "1 if the backend is currently considered healthy, else 0.", }, []string{"proxy_host", "backend"}) TCPConnectionsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "vibeproxy_tcp_connections_total", Help: "Total TCP stream connections accepted.", }, []string{"stream"}) UDPPacketsTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "vibeproxy_udp_packets_total", Help: "Total UDP packets proxied.", }, []string{"stream", "direction"}) TLSHandshakesTotal = promauto.NewCounterVec(prometheus.CounterOpts{ Name: "vibeproxy_tls_handshakes_total", Help: "Total TLS handshakes, by result.", }, []string{"result"}) // ok|error CertificateExpirySeconds = promauto.NewGaugeVec(prometheus.GaugeOpts{ Name: "vibeproxy_certificate_expiry_seconds", Help: "Seconds until certificate expiry (negative if already expired).", }, []string{"name"}) ) func Handler() http.Handler { return promhttp.Handler() }