metrics

package
v1.7.0 Latest Latest
Warning

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

Go to latest
Published: Jun 6, 2026 License: MIT Imports: 5 Imported by: ? modules, 0 packages

The first number is the count of modules that contain a package that imports this one. The module count is a better indicator of popularity than the package count. A module with 100 importing packages is counted only once instead of 100 times, reflecting the fact that the choice to use the package was likely made only once, not 100 times.
A '?' means that the value hasn't been computed yet.

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

View Source
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

func (r *Recorder) Observe(ctx context.Context, gate string, ops []diff.PatchOp, err error)

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.

Jump to

Keyboard shortcuts

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