Documentation
¶
Overview ¶
Package metrics defines and registers all Prometheus metrics for sqi-worker.
Callers obtain a *Metrics via New and pass it to the components that record observations. A private prometheus.Registry is used rather than the global default to prevent cross-contamination between test instances.
Metric families defined here:
- Metrics.ActiveTasks — current in-flight task count
- Metrics.TasksTotal — cumulative completions by status
- Metrics.ExecDuration — per-task process execution histogram
- Metrics.NATSPublishedTotal — NATS publish count by subject
- Metrics.NATSConsumedTotal — NATS consume count by subject
- Metrics.UptimeSeconds — worker process uptime gauge
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
// ActiveTasks is the current number of task processes running on this
// worker. Incremented when a process starts, decremented when it exits.
ActiveTasks prometheus.Gauge
// TasksTotal counts task completions, labeled by terminal status:
// "succeeded", "failed", or "canceled".
TasksTotal *prometheus.CounterVec
// ExecDuration records the wall-clock execution time of each task process
// in seconds, labeled by terminal status so callers can separate fast
// failures from long-running successes.
ExecDuration *prometheus.HistogramVec
// NATSPublishedTotal counts messages published to the sqi-server NATS
// broker, labeled by subject. Populated by the NATS client.
NATSPublishedTotal *prometheus.CounterVec
// NATSConsumedTotal counts messages consumed from the sqi-server NATS
// broker, labeled by subject. Populated by the NATS client.
NATSConsumedTotal *prometheus.CounterVec
// UptimeSeconds is the wall-clock seconds since the worker process started.
// Updated by [Metrics.UpdateUptime].
UptimeSeconds prometheus.Gauge
// contains filtered or unexported fields
}
Metrics holds every Prometheus metric family for sqi-worker and the isolated registry they are registered against. Obtain one with New.
func New ¶
func New() *Metrics
New creates a *Metrics, registers all metric families plus the standard Go runtime and process collectors against a fresh prometheus.Registry, and returns it.
func (*Metrics) Handler ¶
Handler returns an http.Handler that serves the Prometheus text exposition format (and OpenMetrics when the client requests it) for all metrics in this *Metrics' private registry.
func (*Metrics) UpdateUptime ¶
func (m *Metrics) UpdateUptime()
UpdateUptime sets UptimeSeconds to the elapsed time since the worker started. Call this on a ticker in the observability server's goroutine.