createtiming

package
v0.7.21 Latest Latest
Warning

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

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

Documentation

Overview

Package createtiming carries a per-request create-latency recorder on the request context so runtime drivers can attribute where a sandbox create spent its time, and the API handler can surface that attribution as Server-Timing response entries.

The recorder started life inside pkg/docker (runtime/toolbox wait attribution). Phase 0 of plans/firecracker-create-latency.md moved it here so the firecracker driver can record its boot stages without the runtime packages growing an import on each other; pkg/docker keeps thin aliases so its existing callers are untouched.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type CreateTiming

type CreateTiming struct {
	RuntimeWaitMS float64
	ToolboxWaitMS float64
	Source        string // "socket" or "health"; empty when not recorded
	// contains filtered or unexported fields
}

CreateTiming captures per-phase create latency for Server-Timing attribution. The docker fields are populated by the docker runtime's readiness wait; Stages carries the firecracker driver's per-stage boot breakdown (fc_driver, fc_verify, …).

func From

func From(ctx context.Context) *CreateTiming

From returns the recorder stashed on ctx, if any.

func With

func With(parent context.Context) (context.Context, *CreateTiming)

With returns a child context that carries a CreateTiming recorder. Reuses an existing recorder so nested calls share one instance.

func (*CreateTiming) RecordDockerWaits

func (t *CreateTiming) RecordDockerWaits(runtimeWait, toolboxWait time.Duration, source string)

RecordDockerWaits is the docker driver's original name for RecordReadinessWaits, kept so existing docker callers are untouched.

func (*CreateTiming) RecordReadinessWaits

func (t *CreateTiming) RecordReadinessWaits(runtimeWait, toolboxWait time.Duration, source string)

RecordReadinessWaits sets a runtime's readiness attribution: how long the container runtime and toolbox waits took, and which signal proved readiness ("socket" or "health"). Nil-safe so a driver can call it unconditionally. setCreateServerTiming renders Source as the "readiness;desc=" entry, so a driver that omits this leaves the create Server-Timing without a readiness source (the containerd UC-11 gap).

func (*CreateTiming) RecordStage

func (t *CreateTiming) RecordStage(name string, d time.Duration)

RecordStage appends a duration stage. Nil-safe; negative durations clamp to zero so a stage is never rendered with a nonsense value.

func (*CreateTiming) RecordStageDesc

func (t *CreateTiming) RecordStageDesc(name string, d time.Duration, desc string)

RecordStageDesc appends a duration stage that also carries a desc attribute (e.g. "fc_warm;dur=42.0;desc=hit"). Nil-safe.

func (*CreateTiming) Stages

func (t *CreateTiming) Stages() []Stage

Stages returns a copy of the recorded stages in record order. Nil-safe: a nil recorder has no stages.

type Stage

type Stage struct {
	Name  string
	DurMS float64
	Desc  string
}

Stage is one named Server-Timing entry. A duration stage renders as "name;dur=<ms>"; a marker stage (Desc set, no duration) renders as "name;desc=<desc>". Recorded stages are surfaced in record order.

Jump to

Keyboard shortcuts

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