metrics

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Oct 25, 2026 License: Apache-2.0 Imports: 3 Imported by: 0

Documentation

Overview

Package metrics records per-stage durations from internal/handler and exposes p50/p95 via cmd/rinwall's /metrics endpoint, so the latency claims in docs/REFERENCE.md are numbers rather than assertions. Deliberately not Prometheus/OTel yet - an export is on the roadmap; this is the minimum needed to measure.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Recorder

type Recorder struct {
	// contains filtered or unexported fields
}

func New

func New() *Recorder

func (*Recorder) IncrementCounter

func (r *Recorder) IncrementCounter(name string)

IncrementCounter tracks a discrete event rather than a duration - e.g. "vault_unavailable", so an operator can tell "Vault specifically is failing" apart from a generic slow stage in /metrics without having to grep logs for it.

func (*Recorder) Record

func (r *Recorder) Record(stage string, d time.Duration)

func (*Recorder) Snapshot

func (r *Recorder) Snapshot() Snapshot

func (*Recorder) Timer

func (r *Recorder) Timer(stage string) func()

Timer returns a func to call at the end of a stage: `defer r.Timer("policy")()`.

type Snapshot

type Snapshot struct {
	Stages   map[string]StageStats `json:"stages"`
	Counters map[string]int64      `json:"counters"`
}

Snapshot is stages (latency distributions) plus counters (discrete event totals) - separate shapes because they answer different questions: "how slow" vs. "how often did this specific bad thing happen."

type StageStats

type StageStats struct {
	Count int     `json:"count"`
	P50Ms float64 `json:"p50_ms"`
	P95Ms float64 `json:"p95_ms"`
	AvgMs float64 `json:"avg_ms"`
	MaxMs float64 `json:"max_ms"`
}

Jump to

Keyboard shortcuts

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