Documentation
¶
Overview ¶
Package metrics defines and registers all Prometheus metrics for sqi-server.
Callers obtain a *Metrics via New and pass it to the components that record observations. Using a private prometheus.Registry rather than the global default registry prevents cross-contamination between test instances and avoids collision with Go runtime metrics.
Many of the metric families defined here are stubs whose values are set to zero until the corresponding component lands:
- Metrics.SchedulerQueueDepth, Metrics.SchedulerTasksTotal, Metrics.SchedulerAssignmentDuration, Metrics.SchedulerIdleWorkers — populated by the scheduler.
- Metrics.WorkersTotal — populated by the worker registry.
- Metrics.NATSPublishedTotal, Metrics.NATSConsumedTotal — populated by the typed NATS client wrapper.
- Metrics.DBQueryDuration — populated by the SQLite store.
Index ¶
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Metrics ¶
type Metrics struct {
// HTTPRequestsTotal counts completed HTTP requests, labeled by HTTP
// method, request path, and response status code.
//
// TODO: switch the "path" label to chi's route pattern
// (chi.RouteContext(r.Context()).RoutePattern()) to avoid high cardinality
// from parameterised segments such as /api/v1/jobs/{id}.
HTTPRequestsTotal *prometheus.CounterVec
// HTTPRequestDuration records request latency in seconds, labeled by HTTP
// method and request path.
HTTPRequestDuration *prometheus.HistogramVec
// SchedulerQueueDepth is the current number of ready tasks waiting for
// assignment in each named queue. Set by the scheduler.
SchedulerQueueDepth *prometheus.GaugeVec
// SchedulerTasksTotal counts task completions, labeled by queue name and
// terminal status (succeeded, failed, canceled). Incremented by the
// scheduler.
SchedulerTasksTotal *prometheus.CounterVec
// SchedulerAssignmentDuration records the wall-clock time spent in a
// single call to tryAssign, labeled by result:
// - "assigned" — a worker was found and the task was dispatched.
// - "deferred" — no eligible worker or policy blocked; task stays ready.
// - "error" — an unexpected error aborted the attempt.
//
// Populated by the scheduler assignment loop.
SchedulerAssignmentDuration *prometheus.HistogramVec
// SchedulerIdleWorkers is the current count of online workers that have no
// task in 'assigned' or 'running' state, partitioned by farm ID.
// Updated by the scheduler after each worker-registry or sweep event.
SchedulerIdleWorkers *prometheus.GaugeVec
// WorkersTotal is the current number of registered workers, partitioned by
// status: online, offline, or disabled. Set by the worker registry.
WorkersTotal *prometheus.GaugeVec
// NATSPublishedTotal counts messages published to the embedded NATS broker,
// labeled by subject. Incremented by the typed bus client.
NATSPublishedTotal *prometheus.CounterVec
// NATSConsumedTotal counts messages consumed from the embedded NATS broker,
// labeled by subject. Incremented by the typed bus client.
NATSConsumedTotal *prometheus.CounterVec
// DBQueryDuration records SQLite query execution time in seconds, labeled
// by operation name (e.g. "job.insert", "task.list"). Observed by the store
// implementation.
DBQueryDuration *prometheus.HistogramVec
// UsageActiveClaims is the current number of active (unreleased)
// usage-pool claims for each named pool. Updated by the scheduler on every
// dispatch tick.
UsageActiveClaims *prometheus.GaugeVec
// contains filtered or unexported fields
}
Metrics holds every Prometheus metric family for sqi-server and the isolated registry they are registered against. Obtain one with New.
func New ¶
func New() *Metrics
New creates a *Metrics and registers all metric families — plus the standard Go runtime and process collectors — against a fresh prometheus.Registry.