obs

package
v1.1.3 Latest Latest
Warning

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

Go to latest
Published: Nov 20, 2026 License: AGPL-3.0 Imports: 6 Imported by: 0

Documentation

Overview

Package obs is grelot's /metrics page: the counters and histograms the server and store record into, and the gauges read from the store at scrape time. No label value is ever an agent name, path, subject or session.

Index

Constants

View Source
const (
	StartedEmptyCorrupt = "corrupt"
	StartedEmptyFormat  = "format"

	RefusedStoreFull   = "store_full"
	RefusedRateLimited = "rate_limited"
	RefusedScope       = "scope"

	SendAccepted = "accepted"
	SendRetry    = "retry"
	SendGaveUp   = "gave_up"
	SendGone     = "gone"

	AttemptFirst  = "first"
	AttemptRepeat = "repeat"
)

The bounded label values the record paths take.

Variables

This section is empty.

Functions

This section is empty.

Types

type Metrics

type Metrics struct {

	// SweepLastSuccess is the Unix time of the last sweep that committed.
	SweepLastSuccess *measure.Gauge
	SweepFailures    *measure.Counter
	// StoreStartedEmpty counts opens that started with no rows, by reason.
	StoreStartedEmpty *measure.LabeledCounter
	// Posts counts stored posts by thread kind.
	Posts *measure.LabeledCounter
	// PostsRefused counts refused posts by reason.
	PostsRefused *measure.LabeledCounter
	// WritesReplayed counts keyed writes that answered their stored first
	// result.
	WritesReplayed *measure.Counter
	// PushDoorUp is 1 for a door that pushes, 0 for one turned off.
	PushDoorUp *measure.LabeledGauge
	// PushSends counts push tries by door and outcome.
	PushSends *measure.LabeledCounter
	// ProvidersInvalid is the number of provider files skipped at load, 1
	// for a folder that cannot be read.
	ProvidersInvalid *measure.Gauge
	// Nudges counts recorded nudges by layer and attempt.
	Nudges *measure.LabeledCounter
	// NudgeDelay is the oldest-in-batch post-to-nudge delay by layer.
	NudgeDelay *measure.LabeledHistogram
	// contains filtered or unexported fields
}

Metrics holds every family on the page. Build it with New.

func New

func New() *Metrics

New builds the page with every family registered and the refusal and started-empty reasons seeded at 0, so a first one shows in increase().

func (*Metrics) Handler

func (m *Metrics) Handler() http.Handler

Handler serves the page, with the Go runtime and process families.

func (*Metrics) RecordHTTP

func (m *Metrics) RecordHTTP(rm httpserver.RequestMetric)

RecordHTTP records one completed request; it is the hook for httpserver.WithRecordRouteMetric, whose Path is a registered pattern.

func (*Metrics) ServeState

func (m *Metrics) ServeState(read func(context.Context) (State, bool), now func() time.Time)

ServeState registers the gauges read at each scrape from read, which reports false when it cannot count; the page then leaves them out. now is the clock the oldest unread age is taken against. Call it once.

type State

type State struct {
	Oldest                        time.Time
	Live, Dormant, Online         int
	Announce, Path, Direct, Cards int
	Held, Queued, Unread          int
	FileBytes, FreeBytes, InUse   int64
	MaxBytes                      int64
}

State is what the scrape-time gauges read.

Jump to

Keyboard shortcuts

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