Documentation
¶
Overview ¶
Package runtimeops provides structured runtime lifecycle logging for ProcessManager and container engines.
Index ¶
- Constants
- func Emit(ctx context.Context, e RuntimeEvent)
- func ResetDebugSampleRateForTest()
- func SetDebugSampleRateForTest(rate float64)
- func SetMetricsHook(h MetricsHook)
- func SetTestSink(sink func(RuntimeEvent))
- func WithOperation(ctx context.Context, operationID, engine, msUUID string) context.Context
- type MetricsHook
- type OperationMeta
- type RuntimeEvent
Constants ¶
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).
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" EventContainerRuntimeEvent = "container.runtime.event" )
Engine events (typically Debug unless failure).
const ( LevelDebug = "debug" LevelInfo = "info" LevelWarn = "warn" LevelError = "error" )
Log levels passed to the logging backend.
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" )
Stable reason codes for alerting and SIEM rules.
const ( SourceTask = "task" SourceReconcile = "reconcile" SourceShutdown = "shutdown" SourceRuntimeWatch = "runtime_watch" SourceAPI = "api" SourceWatchdog = "watchdog" )
Source identifies who initiated the operation.
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.
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 ¶
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.