Documentation
¶
Index ¶
- func Observe[T any](r *OperationRecorder, operation string, fn func() (T, error)) (T, error)
- func ObserveErr(r *OperationRecorder, operation string, fn func() error) error
- func RegisterPoolStats(reg prometheus.Registerer, metricName, help string, pools map[string]any) error
- type OperationRecorder
- type PoolStatter
Constants ¶
This section is empty.
Variables ¶
This section is empty.
Functions ¶
func Observe ¶
func Observe[T any](r *OperationRecorder, operation string, fn func() (T, error)) (T, error)
Observe runs fn, recording its duration under operation (e.g. "store.BatchUpsert") and a status of "ok" or "error" based on whether fn returned an error.
func ObserveErr ¶
func ObserveErr(r *OperationRecorder, operation string, fn func() error) error
ObserveErr is Observe for operations that return only an error.
func RegisterPoolStats ¶
func RegisterPoolStats(reg prometheus.Registerer, metricName, help string, pools map[string]any) error
RegisterPoolStats registers a collector exporting connection-pool saturation (labeled "pool"/"state") for each named pool. Pools that don't implement PoolStatter (e.g. test fakes) are silently skipped.
Types ¶
type OperationRecorder ¶
type OperationRecorder struct {
// contains filtered or unexported fields
}
OperationRecorder times repository/store-level calls into a histogram labeled "operation"/"status". The histogram is lazily created, so Observe/ObserveErr are safe to call even before Init has run.
func NewOperationRecorder ¶
func NewOperationRecorder(name, help string) *OperationRecorder
NewOperationRecorder returns an independent recorder for a DB-operation-duration histogram with the given name/help.
func (*OperationRecorder) Init ¶
func (r *OperationRecorder) Init(reg prometheus.Registerer) error
Init registers r's histogram with reg. Call once, before serving traffic.
type PoolStatter ¶
PoolStatter is satisfied by pkg/storage/internal/driver.SqlDB. Declared in terms of primitive values, not a driver-specific stat type, so this package stays driver-agnostic. ok is false if the pool isn't connected yet or has already been closed — an expected state, not an error.