observability

package
v0.6.0 Latest Latest
Warning

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

Go to latest
Published: Sep 13, 2026 License: MIT Imports: 6 Imported by: 0

Documentation

Overview

Package observability is LadyM's internal metrics facade over prometheus/client_golang (the de-facto standard, kept behind this package so api/engine/cli share one metric surface without import cycles). Each Registry owns a private prometheus.Registry — the global default is never used, which keeps tests isolated.

Index

Constants

This section is empty.

Variables

View Source
var HistogramBuckets = []float64{0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1, 2.5, 5}

HistogramBuckets are the ladym_http_request_duration_seconds bucket upper bounds (seconds).

Functions

This section is empty.

Types

type EndpointStats

type EndpointStats struct {
	Requests int `json:"requests"`
	Errors   int `json:"errors"` // non-2xx responses
}

EndpointStats is the /api/metrics JSON read-out for one endpoint.

type Registry

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

Registry is a concurrency-safe metrics facade. The process-wide Default() serves production; tests build isolated instances with New().

func Default

func Default() *Registry

Default returns the process-wide registry (api handler and worker share it).

func New

func New() *Registry

New returns a registry with all ladym_* metrics registered.

func (*Registry) DecInFlight

func (r *Registry) DecInFlight()

func (*Registry) DurationSumCount

func (r *Registry) DurationSumCount(endpoint string) (sum float64, count int)

DurationSumCount returns the histogram _sum (seconds) and _count for one endpoint — the /api/metrics JSON face derives recall_avg_ms from it.

func (*Registry) EndpointStatsSnapshot

func (r *Registry) EndpointStatsSnapshot() map[string]EndpointStats

EndpointStatsSnapshot exports per-endpoint request/error counts for the /api/metrics JSON face (errors = all non-2xx classes).

func (*Registry) HTTPHandler

func (r *Registry) HTTPHandler() http.Handler

HTTPHandler serves the Prometheus text exposition of this registry.

func (*Registry) IncInFlight

func (r *Registry) IncInFlight()

IncInFlight / DecInFlight track ladym_http_requests_in_flight.

func (*Registry) IncRequests

func (r *Registry) IncRequests(endpoint, statusClass string)

IncRequests increments ladym_http_requests_total{endpoint,status}; status is a class string ("2xx"/"4xx"/"5xx"), not a raw code.

func (*Registry) IncSystem2Cycle

func (r *Registry) IncSystem2Cycle(result string)

IncSystem2Cycle increments ladym_system2_cycles_total{result} with result in ran/skipped/failed.

func (*Registry) ObserveDuration

func (r *Registry) ObserveDuration(endpoint string, seconds float64)

ObserveDuration records one request duration into ladym_http_request_duration_seconds{endpoint}.

func (*Registry) System2Cycles

func (r *Registry) System2Cycles() map[string]uint64

System2Cycles returns the per-result cycle counts (tests compare deltas).

Jump to

Keyboard shortcuts

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