observability

package
v0.1.0 Latest Latest
Warning

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

Go to latest
Published: Jul 17, 2026 License: MIT Imports: 17 Imported by: 0

Documentation

Overview

Package observability owns low-cardinality process metrics and the redacted operational state served by the management endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewJSONLogger

func NewJSONLogger(w io.Writer, level slog.Level) *slog.Logger

func RedactText

func RedactText(value string) string

RedactText removes credential-bearing URLs, common secret assignments, and PEM/SSH material from errors before they reach logs or status responses.

func RedactingHandler

func RedactingHandler(next slog.Handler) slog.Handler

Types

type Collector

type Collector func()

type ComponentState

type ComponentState struct {
	Ready       bool       `json:"ready"`
	Required    bool       `json:"required"`
	Outcome     string     `json:"outcome"`
	LastChecked time.Time  `json:"last_checked"`
	LastSuccess *time.Time `json:"last_success,omitempty"`
	LastError   string     `json:"last_error,omitempty"`
}

type DNSResolution

type DNSResolution struct {
	Count           uint64
	DurationSeconds float64
}

type DNSSnapshot

type DNSSnapshot struct {
	EntriesPositive   int64
	EntriesNegative   int64
	EvictionsPositive uint64
	EvictionsNegative uint64
	Pending           int64
	RejectedPending   uint64
	Requests          map[string]uint64
	Resolutions       map[string]DNSResolution // outcome|egress_class
}

type GroupSnapshot

type GroupSnapshot struct {
	Name       string `json:"name"`
	State      string `json:"state"`
	Reason     string `json:"reason"`
	ActiveMark uint32 `json:"active_fwmark"`
}

type ManagementConfig

type ManagementConfig struct {
	Listen            string
	ReadHeaderTimeout time.Duration
	WriteTimeout      time.Duration
	IdleTimeout       time.Duration
	ShutdownTimeout   time.Duration
	MaxHeaderBytes    int
	Pprof             bool
}

type ManagementServer

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

func NewManagementServer

func NewManagementServer(config ManagementConfig, registry *Registry, collect Collector, logger *slog.Logger) (*ManagementServer, error)

func (*ManagementServer) Addr

func (m *ManagementServer) Addr() net.Addr

func (*ManagementServer) Shutdown

func (m *ManagementServer) Shutdown(ctx context.Context) error

func (*ManagementServer) Start

func (m *ManagementServer) Start() error

type ProbeSnapshot

type ProbeSnapshot struct {
	ObservedAt     time.Time `json:"observed_at"`
	Success        bool      `json:"success"`
	DurationSecond float64   `json:"duration_seconds"`
	LastError      string    `json:"last_error,omitempty"`
}

type ProxySnapshot

type ProxySnapshot struct {
	Active          int64
	Accepted        uint64
	Rejected        map[string]uint64 // protocol|reason|listener_class
	Completed       map[string]uint64 // completed|canceled|error|other
	DurationSeconds map[string]float64
	ClientBytes     map[string]uint64
	BackendBytes    map[string]uint64
	ConnectAttempts map[string]uint64 // outcome|egress_class
}

type Registry

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

func NewRegistry

func NewRegistry() *Registry

func (*Registry) Ready

func (r *Registry) Ready() (bool, []string)

func (*Registry) RecordPfSync

func (r *Registry) RecordPfSync(outcome string, resultErrors ...error)

func (*Registry) RecordReload

func (r *Registry) RecordReload(outcome string, duration time.Duration)

func (*Registry) SeriesCount

func (r *Registry) SeriesCount() int

func (*Registry) SetActiveGeneration

func (r *Registry) SetActiveGeneration(g lifecycle.Generation)

func (*Registry) SetComponent

func (r *Registry) SetComponent(name string, required, ready bool, outcome string, err error)

func (*Registry) SetDNS

func (r *Registry) SetDNS(snapshot DNSSnapshot)

func (*Registry) SetDrift

func (r *Registry) SetDrift(kernel, firewall int)

func (*Registry) SetGroups

func (r *Registry) SetGroups(snapshots []GroupSnapshot)

func (*Registry) SetProbe

func (r *Registry) SetProbe(snapshot ProbeSnapshot)

func (*Registry) SetProxy

func (r *Registry) SetProxy(snapshot ProxySnapshot)

func (*Registry) SetRouteSource

func (r *Registry) SetRouteSource(snapshot RouteSourceSnapshot)

func (*Registry) SetWG

func (r *Registry) SetWG(snapshots []WGSnapshot)

func (*Registry) Status

func (r *Registry) Status() Status

func (*Registry) WritePrometheus

func (r *Registry) WritePrometheus(w io.Writer)

WritePrometheus emits a stable, dependency-free Prometheus text exposition. Every label is either a fixed enum or a configuration-bounded tunnel/source name. Hostnames, addresses, URLs, routes, and peer keys are never labels.

func (*Registry) WriteStatus

func (r *Registry) WriteStatus(w io.Writer) error

type RouteSourceSnapshot

type RouteSourceSnapshot struct {
	Name        string    `json:"name"`
	LastSuccess time.Time `json:"last_success,omitempty"`
	LastOutcome string    `json:"last_outcome"`
	PrefixCount int       `json:"prefix_count"`
	LastError   string    `json:"last_error,omitempty"`
}

type Status

type Status struct {
	Live             bool                      `json:"live"`
	Ready            bool                      `json:"ready"`
	ReadinessReasons []string                  `json:"readiness_reasons,omitempty"`
	Generation       lifecycle.Generation      `json:"active_generation"`
	StartedAt        time.Time                 `json:"started_at"`
	Components       map[string]ComponentState `json:"components"`
	RouteSources     []RouteSourceSnapshot     `json:"route_sources,omitempty"`
	WireGuard        []WGSnapshot              `json:"wireguard,omitempty"`
	Groups           []GroupSnapshot           `json:"groups,omitempty"`
	ActiveProbe      *ProbeSnapshot            `json:"active_probe,omitempty"`
}

type WGSnapshot

type WGSnapshot struct {
	Tunnel        string  `json:"tunnel"`
	Signal        string  `json:"wg_session_recent"`
	HandshakeAge  float64 `json:"handshake_age_seconds"`
	ReceiveBytes  int64   `json:"receive_bytes"`
	TransmitBytes int64   `json:"transmit_bytes"`
}

Jump to

Keyboard shortcuts

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