Documentation
¶
Overview ¶
Package metrics exposes the agent's Prometheus collectors and a small HTTP server that serves /metrics. The collectors live in their own Registry rather than the global default so multiple agents in the same test process do not collide.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
Connected *prometheus.GaugeVec // labels: endpoint
ReconnectsTotal prometheus.Counter
EventsEmittedTotal *prometheus.CounterVec // labels: type
EventsDroppedTotal *prometheus.CounterVec // labels: type, reason
BufferSize *prometheus.GaugeVec // labels: type
ActiveSubscriptions prometheus.Gauge
HeartbeatsSent prometheus.Counter
StreamErrorsTotal *prometheus.CounterVec // labels: stage
// contains filtered or unexported fields
}
Metrics holds every collector the agent updates. Construct once via New and pass it down. Concurrency-safe by design (Prometheus collectors are).
func New ¶
func New() *Metrics
New returns a fully wired Metrics with all collectors registered in a fresh registry.
func (*Metrics) Handler ¶
Handler returns a stand-alone /metrics http.Handler. Use Server to mount it on a private port; use Handler directly to embed it in another mux.
func (*Metrics) Registry ¶
func (m *Metrics) Registry() *prometheus.Registry
Registry returns the underlying Prometheus registry. Useful for tests and for callers that want to expose admin-agent metrics from their own HTTP server (the framework's main /metrics, for example) instead of running the agent's standalone server.
type Server ¶
type Server struct {
// contains filtered or unexported fields
}
Server is a tiny HTTP server that serves /metrics and /healthz.