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 ¶
- type CreateTiming
- func (t *CreateTiming) RecordDockerWaits(runtimeWait, toolboxWait time.Duration, source string)
- func (t *CreateTiming) RecordReadinessWaits(runtimeWait, toolboxWait time.Duration, source string)
- func (t *CreateTiming) RecordStage(name string, d time.Duration)
- func (t *CreateTiming) RecordStageDesc(name string, d time.Duration, desc string)
- func (t *CreateTiming) Stages() []Stage
- type Stage
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.