Documentation
¶
Overview ¶
Package obs holds the observability primitives: structured audit log middleware and Prometheus metrics.
Index ¶
- func NewAuditMiddleware(w io.Writer) func(http.Handler) http.Handler
- type JobMetrics
- func (m *JobMetrics) ChildFailure(kind string)
- func (m *JobMetrics) JobEnqueued(kind string)
- func (m *JobMetrics) JobFinished(kind, result string)
- func (m *JobMetrics) JobStarted(kind string)
- func (m *JobMetrics) ObserveDuration(kind string, d time.Duration)
- func (m *JobMetrics) Rollback(kind string)
- type Metrics
- type PruneMetrics
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
Types ¶
type JobMetrics ¶
type JobMetrics struct {
// contains filtered or unexported fields
}
JobMetrics implements jobs.Metrics with Prometheus collectors. Created with an explicit Registerer so production registers on the default registry (NewJobMetrics(prometheus.DefaultRegisterer)) and tests use a private one.
func NewJobMetrics ¶
func NewJobMetrics(reg prometheus.Registerer) *JobMetrics
NewJobMetrics builds and registers the collectors on reg.
func (*JobMetrics) ChildFailure ¶
func (m *JobMetrics) ChildFailure(kind string)
ChildFailure records an evacuate child migration failure.
func (*JobMetrics) JobEnqueued ¶
func (m *JobMetrics) JobEnqueued(kind string)
JobEnqueued records a new job being enqueued.
func (*JobMetrics) JobFinished ¶
func (m *JobMetrics) JobFinished(kind, result string)
JobFinished records a terminal job outcome (succeeded/failed/canceled).
func (*JobMetrics) JobStarted ¶
func (m *JobMetrics) JobStarted(kind string)
JobStarted records a job being claimed and started.
When JobEnqueued is wired at dispatch sites, restore m.enqueued.Dec() here so the queue-depth gauge increments on enqueue and decrements on start.
func (*JobMetrics) ObserveDuration ¶
func (m *JobMetrics) ObserveDuration(kind string, d time.Duration)
ObserveDuration records a job handler's wall-clock duration.
func (*JobMetrics) Rollback ¶
func (m *JobMetrics) Rollback(kind string)
Rollback records a migrate rollback event.
type Metrics ¶
type Metrics struct {
// contains filtered or unexported fields
}
Metrics holds the Prometheus collectors. New() registers them with the default registry; call Handler() to expose /metrics.
func (*Metrics) Middleware ¶
Middleware returns an HTTP middleware that records request count and duration. The route label uses r.Pattern (the registered mux pattern, available in Go 1.22+) to avoid label cardinality explosion from path parameters. Falls back to "_other" when the pattern is not populated.
type PruneMetrics ¶
type PruneMetrics struct {
// contains filtered or unexported fields
}
PruneMetrics implements the prune.Metrics interface (structurally — obs must not import prune) with Prometheus counters. Created with an explicit Registerer so production registers on the default registry (NewPruneMetrics(prometheus.DefaultRegisterer)) and tests use a private one.
func NewPruneMetrics ¶
func NewPruneMetrics(reg prometheus.Registerer) *PruneMetrics
NewPruneMetrics builds and registers the prune collectors on reg.
func (*PruneMetrics) Reclaimed ¶
func (m *PruneMetrics) Reclaimed(host, scope string, bytes int64)
Reclaimed adds reclaimed bytes for a scope.
func (*PruneMetrics) RunDone ¶
func (m *PruneMetrics) RunDone(host, result string)
RunDone records one finished prune run.