metrics

package
v0.2.0 Latest Latest
Warning

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

Go to latest
Published: Jul 13, 2026 License: AGPL-3.0 Imports: 5 Imported by: 0

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:

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

func (m *Metrics) Handler() http.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.

Jump to

Keyboard shortcuts

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