obs

package
v1.0.21 Latest Latest
Warning

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

Go to latest
Published: Jul 23, 2026 License: MIT Imports: 10 Imported by: 0

Documentation

Overview

Package obs holds the observability primitives: structured audit log middleware and Prometheus metrics.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewAuditMiddleware

func NewAuditMiddleware(w io.Writer) func(http.Handler) http.Handler

NewAuditMiddleware writes one JSON line per state-changing request to w. It logs nothing for safe methods (GET/HEAD/OPTIONS).

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 New

func New() *Metrics

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler is the http.Handler for the /metrics endpoint.

func (*Metrics) Middleware

func (m *Metrics) Middleware() func(http.Handler) http.Handler

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.

Jump to

Keyboard shortcuts

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