Documentation
¶
Overview ¶
Package metrics holds the shared domain comparison metrics recorded by every component that diffs live/shadow responses: the mroki-api server (API mode), the standalone mroki-proxy, and the caddy module. Defining them once here lets every host emit identical series regardless of where the diff is computed, so a standalone proxy exposes the same metrics the API exposes in API mode.
Index ¶
Constants ¶
const ( ResultMatch = "match" ResultDiff = "diff" ResultError = "error" )
Comparison outcome values for the result label on mroki_responses_compared_total.
Variables ¶
This section is empty.
Functions ¶
This section is empty.
Types ¶
type Recorder ¶
type Recorder struct {
// contains filtered or unexported fields
}
Recorder records the shared domain comparison metrics via the OTel Meter API:
- mroki_responses_compared_total{gate,result} — every comparison, by outcome
- mroki_diff_operations{gate} — JSON-Patch op count, on diff
A nil *Recorder is a no-op so callers can record unconditionally.
func New ¶
func New(mp metric.MeterProvider) (*Recorder, error)
New constructs the comparison Recorder from mp's Meter.
func (*Recorder) Observe ¶
Observe records a single comparison. The result is derived from err and ops: a non-nil err records result="error"; a non-empty ops records result="diff" and observes len(ops) on the diff_operations histogram; otherwise result="match". gate may be empty (e.g. when the caller is not bound to a gate). A nil Recorder is a no-op.