metering

package
v0.4.3 Latest Latest
Warning

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

Go to latest
Published: May 28, 2026 License: MIT Imports: 4 Imported by: 0

Documentation

Overview

Package metering emits append-only VM/snapshot lifecycle endpoints; tenant attribution lives upstream. Recorder is the contract; backends live in subpackages (file, stderr, capture).

Index

Constants

View Source
const (
	KindVMComputeStart   Kind = "vm.compute.start"
	KindVMComputeStop    Kind = "vm.compute.stop"
	KindVMStorageStart   Kind = "vm.storage.start"
	KindVMStorageStop    Kind = "vm.storage.stop"
	KindSnapStorageStart Kind = "snap.storage.start"
	KindSnapStorageStop  Kind = "snap.storage.stop"

	ReasonBoot          Reason = "boot"
	ReasonRestart       Reason = "restart"
	ReasonClone         Reason = "clone"
	ReasonRestore       Reason = "restore"
	ReasonHibernateWake Reason = "hibernate-wake"
	ReasonStopUser      Reason = "stop-user"
	ReasonStopCrash     Reason = "stop-crash"
	ReasonVMRemove      Reason = "vm-rm"
	ReasonSnapRemove    Reason = "snap-rm"
)

Variables

This section is empty.

Functions

This section is empty.

Types

type Entry

type Entry struct {
	Kind             Kind      `json:"kind"`
	VMID             string    `json:"vm_id,omitempty"`
	SnapshotID       string    `json:"snapshot_id,omitempty"`
	SourceSnapshotID string    `json:"source_snapshot_id,omitempty"`
	Reason           Reason    `json:"reason,omitempty"`
	Hypervisor       string    `json:"hypervisor,omitempty"`
	Shape            Shape     `json:"shape"`
	EmittedAt        time.Time `json:"emitted_at"`
}

Entry is one append-only lifecycle event.

func (Entry) WriteTo added in v0.4.2

func (e Entry) WriteTo(w io.Writer) (int64, error)

WriteTo writes one JSONL record.

type Kind

type Kind string

Kind identifies a lifecycle endpoint; downstream pairs *.start with *.stop by id.

type NopRecorder

type NopRecorder struct{}

NopRecorder discards every entry; zero value is usable.

func (NopRecorder) Emit

type Reason

type Reason string

Reason annotates why an endpoint was emitted.

type Recorder

type Recorder interface {
	Emit(context.Context, Entry)
}

Recorder accepts lifecycle entries; implementations must be safe for concurrent use.

type Shape

type Shape struct {
	CPU          int   `json:"cpu,omitempty"`
	MemBytes     int64 `json:"mem_bytes,omitempty"`
	StorageBytes int64 `json:"storage_bytes,omitempty"`
}

Shape is the resource snapshot at the moment an Entry is emitted.

Directories

Path Synopsis
Package capture is a test-only metering recorder; Entries and Reset are testing helpers.
Package capture is a test-only metering recorder; Entries and Reset are testing helpers.

Jump to

Keyboard shortcuts

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