metrics

package
v1.10.4 Latest Latest
Warning

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

Go to latest
Published: May 20, 2026 License: AGPL-3.0 Imports: 7 Imported by: 0 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 provides the lightweight Prometheus text-format metrics types and the Store that aggregates them for the registry server.

Index

Constants

This section is empty.

Variables

View Source
var DefaultDurationBuckets = []float64{
	0.0001, 0.00025, 0.0005, 0.001, 0.0025, 0.005, 0.01, 0.025, 0.05, 0.1, 0.25, 0.5, 1.0,
}

DefaultDurationBuckets are the default histogram buckets for request duration (seconds).

Functions

func FormatFloat

func FormatFloat(v float64) string

FormatFloat formats a float64 for Prometheus output. Integers are printed without decimal point for cleaner output.

Types

type Counter

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

Counter is a monotonically increasing atomic counter.

func (*Counter) Get

func (c *Counter) Get() float64

func (*Counter) Inc

func (c *Counter) Inc()

type CounterVec

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

CounterVec is a set of Counters keyed by a single label value.

func NewCounterVec

func NewCounterVec() *CounterVec

func (*CounterVec) Snapshot

func (cv *CounterVec) Snapshot() []LabelValue

func (*CounterVec) WithLabel

func (cv *CounterVec) WithLabel(val string) *Counter

type Gauge

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

Gauge is a numeric value that can go up and down.

func (*Gauge) Get

func (g *Gauge) Get() float64

func (*Gauge) Set

func (g *Gauge) Set(v float64)

type Histogram

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

Histogram tracks the distribution of observed values in predefined buckets.

func NewHistogram

func NewHistogram(buckets []float64) *Histogram

func (*Histogram) Observe

func (h *Histogram) Observe(v float64)

func (*Histogram) Snapshot

func (h *Histogram) Snapshot() (buckets []float64, counts []uint64, sum float64, count uint64)

Snapshot returns a copy; callers must not hold h.mu (deadlock) or retain pointers into the returned slices after mutation.

type HistogramVec

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

HistogramVec is a set of Histograms keyed by a single label value.

func NewHistogramVec

func NewHistogramVec(buckets []float64) *HistogramVec

func (*HistogramVec) Snapshot

func (hv *HistogramVec) Snapshot() []LabelHistogram

func (*HistogramVec) WithLabel

func (hv *HistogramVec) WithLabel(val string) *Histogram

type LabelHistogram

type LabelHistogram struct {
	Label   string
	Buckets []float64
	Counts  []uint64
	Sum     float64
	Count   uint64
}

type LabelValue

type LabelValue struct {
	Label string
	Value float64
}

type NetworkMetricSnapshot

type NetworkMetricSnapshot struct {
	Name       string
	Members    int
	Owners     int
	Admins     int
	Enterprise bool
	PolicySet  bool
}

NetworkMetricSnapshot holds per-network metrics computed on each scrape.

type Store

type Store struct {
	// Request metrics (labeled by message type)
	RequestsTotal   *CounterVec   // pilot_requests_total{type="..."}
	RequestDuration *HistogramVec // pilot_request_duration_seconds{type="..."}
	ErrorsTotal     *CounterVec   // pilot_errors_total{type="..."}

	// Gauge metrics (updated on each scrape)
	NodesOnline   Gauge // pilot_nodes_online
	NodesTotal    Gauge // pilot_nodes_total
	TrustLinks    Gauge // pilot_trust_links
	TaskExecutors Gauge // pilot_task_executors
	UptimeSeconds Gauge // pilot_uptime_seconds

	// Lifecycle counters
	Registrations     Counter // pilot_registrations_total
	Deregistrations   Counter // pilot_deregistrations_total
	TrustReports      Counter // pilot_trust_reports_total
	TrustRevocations  Counter // pilot_trust_revocations_total
	HandshakeRequests Counter // pilot_handshake_requests_total

	// Network gauges (updated on each scrape)
	NetworksTotal      Gauge // pilot_networks_total
	NetworksEnterprise Gauge // pilot_networks_enterprise
	InvitesPending     Gauge // pilot_invites_pending

	// Enterprise counters
	AuditEventsTotal Counter     // pilot_audit_events_total
	InvitesSent      Counter     // pilot_invites_sent_total
	InvitesAccepted  Counter     // pilot_invites_accepted_total
	InvitesRejected  Counter     // pilot_invites_rejected_total
	RbacOps          *CounterVec // pilot_rbac_operations_total{op="..."}
	PolicyChanges    Counter     // pilot_policy_changes_total
	KeyRotations     Counter     // pilot_key_rotations_total

	// Provisioning counters
	ProvisionsTotal    Counter // pilot_provisions_total
	AuditExportsTotal  Counter // pilot_audit_exports_total
	AuditExportErrors  Counter // pilot_audit_export_errors_total
	IdpVerifications   Counter // pilot_idp_verifications_total
	RbacPreAssignments Counter // pilot_rbac_pre_assignments_total

	// Reliability counters (Phase 3 wiring)
	WalFull      Counter // pilot_wal_full_total
	WalErrors    Counter // pilot_wal_errors_total
	SaveFailures Counter // pilot_save_failures_total

	NetworkMetrics []NetworkMetricSnapshot

	// Enterprise status gauges
	IdpConfigured     Gauge // pilot_idp_configured (0 or 1)
	WebhookConfigured Gauge // pilot_webhook_configured (0 or 1)
	AuditExportActive Gauge // pilot_audit_export_active (0 or 1)
	DirectorySynced   Gauge // pilot_directory_synced_networks

	// Runtime / saturation observability
	RuntimeGoroutines     Gauge // pilot_runtime_goroutines
	RuntimeConnectionsTCP Gauge // pilot_registry_tcp_connections
	HandshakeInboxSize    Gauge // pilot_handshake_inbox_size
	HandshakeRespSize     Gauge // pilot_handshake_responses_size

	// list_nodes cache observability
	ListNodesCacheHits     Gauge // pilot_list_nodes_cache_hits
	ListNodesCacheWaits    Gauge // pilot_list_nodes_cache_waits
	ListNodesCacheRebuilds Gauge // pilot_list_nodes_cache_rebuilds

	// PanicCountFn returns the total recovered-panic count since process start.
	// Injected at construction so WriteTo can surface it without importing server.
	PanicCountFn func() uint64
	// contains filtered or unexported fields
}

Store aggregates all Prometheus metrics for the registry server. It is intentionally zero-external-dependency.

func NewStore

func NewStore(panicCountFn func() uint64) *Store

NewStore creates a new Store with all vecs initialized.

func (*Store) GetNetworkMetrics

func (st *Store) GetNetworkMetrics() []NetworkMetricSnapshot

GetNetworkMetrics returns a copy of the per-network snapshot slice (thread-safe).

func (*Store) SetNetworkMetrics

func (st *Store) SetNetworkMetrics(snaps []NetworkMetricSnapshot)

SetNetworkMetrics replaces the per-network snapshot slice (thread-safe).

func (*Store) WriteTo

func (st *Store) WriteTo(w io.Writer) (int64, error)

Jump to

Keyboard shortcuts

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