runtimeops

package
v1.1.0 Latest Latest
Warning

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

Go to latest
Published: Sep 30, 2026 License: EPL-2.0 Imports: 7 Imported by: 0

Documentation

Overview

Package runtimeops provides structured runtime lifecycle logging for ProcessManager and container engines.

Index

Constants

View Source
const (
	EventPMStarted = "pm.started"
	EventPMStopped = "pm.stopped"

	EventTaskEnqueued  = "task.enqueued"
	EventTaskStarted   = "task.started"
	EventTaskCompleted = "task.completed"
	EventTaskFailed    = "task.failed"
	EventTaskRetry     = "task.retry"

	EventReconcileCycle    = "reconcile.cycle"
	EventReconcileDecision = "reconcile.decision"

	EventContainerPulling       = "container.pulling"
	EventContainerPullCompleted = "container.pull.completed"
	EventContainerCreating      = "container.creating"
	EventContainerCreated       = "container.created"
	EventContainerStarting      = "container.starting"
	EventContainerStarted       = "container.started"
	EventContainerStopping      = "container.stopping"
	EventContainerStopped       = "container.stopped"
	EventContainerRemoving      = "container.removing"
	EventContainerRemoved       = "container.removed"
	EventContainerUpdatePhase   = "container.update.phase"
	EventContainerDrift         = "container.drift"

	EventShutdownDrain = "shutdown.drain"
)

ProcessManager / ContainerManager events (typically Info).

View Source
const (
	EventEngineInit                = "engine.init"
	EventEngineCRISandboxCreated   = "engine.cri.sandbox.created"
	EventEngineCRIContainerCreated = "engine.cri.container.created"
	EventEngineContainerStart      = "engine.container.start"
	EventEngineContainerStop       = "engine.container.stop"
	EventEngineContainerRemove     = "engine.container.remove"
	EventEngineImagePulled         = "engine.image.pulled"
	EventEnginePrune               = "engine.prune"
	EventVolumeReclaim             = "volume.reclaim"

	EventContainerRuntimeEvent = "container.runtime.event"
)

Engine events (typically Debug unless failure).

View Source
const (
	LevelDebug = "debug"
	LevelInfo  = "info"
	LevelWarn  = "warn"
	LevelError = "error"
)

Log levels passed to the logging backend.

View Source
const (
	ReasonPullFailed           = "PULL_FAILED"
	ReasonPullCacheFallback    = "PULL_CACHE_FALLBACK"
	ReasonCreateFailed         = "CREATE_FAILED"
	ReasonStartFailed          = "START_FAILED"
	ReasonNonRestartableExit   = "NON_RESTARTABLE_EXIT"
	ReasonStopFailed           = "STOP_FAILED"
	ReasonRemoveFailed         = "REMOVE_FAILED"
	ReasonRuntimeDrift         = "RUNTIME_DRIFT"
	ReasonStuckInRestart       = "STUCK_IN_RESTART"
	ReasonTaskExhaustedRetries = "TASK_EXHAUSTED_RETRIES"
	ReasonShutdownDrainTimeout = "SHUTDOWN_DRAIN_TIMEOUT"
	ReasonVolumeKeepSet        = "VOLUME_KEEP_SET"
	ReasonVolumeInUse          = "VOLUME_IN_USE"
	ReasonVolumePathJail       = "VOLUME_PATH_JAIL"
)

Stable reason codes for alerting and SIEM rules.

View Source
const (
	SourceTask         = "task"
	SourceReconcile    = "reconcile"
	SourceShutdown     = "shutdown"
	SourceRuntimeWatch = "runtime_watch"
	SourceAPI          = "api"
	SourceWatchdog     = "watchdog"
)

Source identifies who initiated the operation.

View Source
const (
	ResultOK      = "ok"
	ResultFailed  = "failed"
	ResultSkipped = "skipped"
)

Result values for lifecycle events.

Variables

This section is empty.

Functions

func Emit

func Emit(ctx context.Context, e RuntimeEvent)

Emit logs a structured runtime event, merging context correlation fields with e.

func ResetDebugSampleRateForTest

func ResetDebugSampleRateForTest()

ResetDebugSampleRateForTest resets sampling state (tests only).

func SetDebugSampleRateForTest

func SetDebugSampleRateForTest(rate float64)

SetDebugSampleRateForTest sets the sample rate without reading the environment (tests only).

func SetMetricsHook

func SetMetricsHook(h MetricsHook)

SetMetricsHook installs an optional metrics hook (no-op when nil).

func SetTestSink

func SetTestSink(sink func(RuntimeEvent))

SetTestSink installs a test-only sink. Pass nil to clear.

func WithOperation

func WithOperation(ctx context.Context, operationID, engine, msUUID string) context.Context

WithOperation returns a child context carrying runtime operation correlation fields.

Types

type MetricsHook

type MetricsHook interface {
	OnRuntimeEvent(e RuntimeEvent, fields map[string]any)
}

MetricsHook is invoked after each emit for future Prometheus integration (PR-5a deferred).

type OperationMeta

type OperationMeta struct {
	OperationID string
	Engine      string
	MsUUID      string
}

OperationMeta holds correlation fields propagated through context.

func OperationFromContext

func OperationFromContext(ctx context.Context) OperationMeta

OperationFromContext returns correlation fields stored in ctx (empty strings if unset).

type RuntimeEvent

type RuntimeEvent struct {
	Event       string
	Level       string
	Module      string
	OperationID string
	Engine      string
	MsUUID      string
	ContainerID string
	SandboxID   string
	Image       string
	Phase       string
	Result      string
	DurationMs  int64
	ReasonCode  string
	Source      string
	Message     string
	Error       string
	Fields      map[string]any
}

RuntimeEvent is a structured log record for container runtime operations. Fields are merged with context (operationId, engine, msUUID) at emit time.

Jump to

Keyboard shortcuts

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