metrics

package
v0.51.0 Latest Latest
Warning

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

Go to latest
Published: Jun 30, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package metrics provides Prometheus metrics collection for the unikernel engine daemon.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func Serve

func Serve(ctx context.Context, addr string, c *Collectors) error

Serve starts an HTTP server serving Prometheus metrics on the given address. This is a blocking call; use with a goroutine or context cancellation.

Types

type Collectors

type Collectors struct {
	// VM states gauge
	VMCreated  prometheus.Gauge
	VMStarting prometheus.Gauge
	VMRunning  prometheus.Gauge
	VMStopping prometheus.Gauge
	VMStopped  prometheus.Gauge

	// VM lifecycle counters
	VMStartsTotal   prometheus.Counter
	VMStopsTotal    prometheus.Counter
	VMRestartsTotal prometheus.Counter
	VMErrorsTotal   prometheus.Counter

	// Build info
	BuildInfo *prometheus.GaugeVec

	// Registry counts
	ImagesTotal     prometheus.Gauge
	PushTotal       prometheus.Counter
	PullTotal       prometheus.Counter
	PushErrorsTotal prometheus.Counter
	PullErrorsTotal prometheus.Counter

	// Network
	PortForwardsActive prometheus.Gauge
	BridgeCount        prometheus.Gauge

	// Up
	StartTime prometheus.Gauge
	// contains filtered or unexported fields
}

Collectors holds all Prometheus metric collectors for the daemon.

func NewCollectors

func NewCollectors(version string) *Collectors

NewCollectors creates and registers all Prometheus metric collectors.

func (*Collectors) Handler

func (c *Collectors) Handler() http.Handler

Handler returns an http.Handler that serves Prometheus metrics.

type VMStateCounts

type VMStateCounts struct {
	Created  atomic.Int64
	Starting atomic.Int64
	Running  atomic.Int64
	Stopping atomic.Int64
	Stopped  atomic.Int64
}

VMStateCounts tracks the number of VMs in each state.

type VMStateUpdater

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

VMStateUpdater periodically polls a vm.Manager and updates Prometheus gauges with the current count of VMs in each state.

func NewVMStateUpdater

func NewVMStateUpdater(collectors *Collectors, mgr vm.Manager, interval time.Duration) *VMStateUpdater

NewVMStateUpdater creates an updater that polls the manager at the given interval.

func (*VMStateUpdater) Run

func (u *VMStateUpdater) Run(ctx context.Context)

Run starts the polling loop. It blocks until ctx is canceled.

Jump to

Keyboard shortcuts

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