Documentation
¶
Overview ¶
Package metrics defines the Prometheus collectors of a Foreman client, the shared histogram buckets, and label capping for values derived from user data.
m, err := metrics.New(prometheus.DefaultRegisterer) m.Inserted.WithLabelValues(m.Queue(q), m.Kind(k)).Inc()
Index ¶
Constants ¶
const DefaultLabelCap = 50
DefaultLabelCap is the number of distinct user-derived label values (queue, kind, periodic name) kept per metric before others map to "other".
const Other = "other"
Other replaces label values beyond the cap.
Variables ¶
var ( // DurationBuckets covers job run times from 1 ms to ~1 h. DurationBuckets = []float64{ 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 300, 900, 3600, } // LatencyBuckets covers queue latency (scheduled_at to attempted_at) from 1 ms to 1 h. LatencyBuckets = []float64{ 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5, 10, 30, 60, 300, 3600, } // FetchBuckets covers fetch statements from 100 µs to 5 s. FetchBuckets = []float64{0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 1, 5} )
Histogram buckets, declared once for the project.
Functions ¶
This section is empty.
Types ¶
type Capper ¶
type Capper struct {
// contains filtered or unexported fields
}
Capper bounds the distinct values of a label: the first Max values are kept, later ones become "other".
type Metrics ¶
type Metrics struct {
Inserted *prometheus.CounterVec
Completed *prometheus.CounterVec
Duration *prometheus.HistogramVec
QueueLatency *prometheus.HistogramVec
QueueDepth *prometheus.GaugeVec
Running *prometheus.GaugeVec
Leader prometheus.Gauge
Rescued prometheus.Counter
Stale prometheus.Counter
PeriodicSkipped *prometheus.CounterVec
Unserved *prometheus.CounterVec
FetchDuration *prometheus.HistogramVec
MaintenanceRun *prometheus.GaugeVec
MaintenanceRows *prometheus.CounterVec
BuildInfo *prometheus.GaugeVec
// contains filtered or unexported fields
}
Metrics holds every Prometheus collector of a client.
func New ¶
func New(reg prometheus.Registerer) (*Metrics, error)
New creates the collectors and registers them with reg. A nil reg keeps them in a private registry. Collectors already registered by another client in the same process are shared, so several clients may use one registerer.
func (*Metrics) ObserveMaintenance ¶
ObserveMaintenance records a run of a leader service.