deploytrace

package
v0.8.6 Latest Latest
Warning

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

Go to latest
Published: Oct 27, 2026 License: Apache-2.0 Imports: 8 Imported by: 0

Documentation

Overview

Package deploytrace records the step-by-step pipeline of a deploy, build or not, as rows the step stream, the log stream and the CLI all read.

Index

Constants

View Source
const (
	StepResolveDigest   = "resolve_digest"
	StepRegistryAuth    = "registry_auth"
	StepImagePull       = "image_pull"
	StepImagePullLayer  = "image_pull_layer"
	StepImageInspect    = "image_inspect"
	StepConfigValidate  = "config_validate"
	StepEnsureNetwork   = "ensure_network"
	StepEnsureVolume    = "ensure_volume"
	StepContainerCreate = "container_create"
	StepContainerStart  = "container_start"
	StepDockerEvent     = "docker_event"
	StepReadinessProbe  = "readiness_probe"
	StepReadinessGate   = "readiness_gate"
	StepStabilityGate   = "stability_gate"
	StepCutover         = "cutover"
	StepDrainOld        = "drain_old"
	StepRetainImage     = "retain_image"
	StepComposeParse    = "compose_parse"
	StepComposePlan     = "compose_plan"
	StepComposeService  = "compose_service"
	StepDependsOn       = "depends_on"
	StepSummary         = store.TraceSummaryKey
)

Step names. One constant per concept, shared by emitters and the viewer.

Variables

This section is empty.

Functions

func Bytes

func Bytes(n int64) string

Bytes renders n as a short human size.

func ConfigStep

func ConfigStep(ctx context.Context, tr *Tracer, svc store.DesiredService)

ConfigStep records what a deploy asks the node to run: env names (masked by source), port, volumes and resource limits, never values.

func EnvSummary

func EnvSummary(plain []string, tagged map[string]string) string

EnvSummary lists env var names, tagging non-plain sources. Values are never included: a secret, vault or database reference must not reach a log.

func FormatLine

func FormatLine(s store.DeployTraceStep) string

FormatLine renders s as one human log line for the deploy log stream.

Types

type Resolver

type Resolver interface {
	TraceTargetFor(ctx context.Context, serviceName, image string) (attemptID string, sealed bool, err error)
}

Resolver maps a reconcile pass (service, image) to its deploy attempt.

type Sink

type Sink interface {
	SaveDeployTraceStep(ctx context.Context, s store.DeployTraceStep) error
}

Sink persists steps. *store.DB satisfies it.

type Span

type Span struct {
	// contains filtered or unexported fields
}

Span is one running step.

func (*Span) Done

func (s *Span) Done(ctx context.Context, detail string)

Done ends the step successfully.

func (*Span) End

func (s *Span) End(ctx context.Context, status, reason, detail string)

End finishes the step with status, a short reason code and a detail line.

func (*Span) Fail

func (s *Span) Fail(ctx context.Context, reason string, err error)

Fail ends the step failed, carrying the underlying error text verbatim.

func (*Span) Progress

func (s *Span) Progress(ctx context.Context, detail string)

Progress updates a running step's detail without ending it.

type Tracer

type Tracer struct {
	// contains filtered or unexported fields
}

Tracer writes steps for one attempt. A nil *Tracer is valid and records nothing, so call sites never nil-check.

func ForImage

func ForImage(ctx context.Context, sink Sink, res Resolver, service, image string, logger *slog.Logger) *Tracer

ForImage resolves the attempt converging (service, image) and returns its tracer, or nil when none matches or the attempt's trace is already sealed.

func New

func New(sink Sink, attemptID string, logger *slog.Logger) *Tracer

New returns a tracer for attemptID, or nil when there is nothing to write to.

func NewBuffered

func NewBuffered() *Tracer

NewBuffered returns a tracer that holds steps in memory until Flush, for work that happens before the deploy attempt row (and so its id) exists.

func (*Tracer) AttemptID

func (t *Tracer) AttemptID() string

AttemptID reports which attempt t writes to.

func (*Tracer) Begin

func (t *Tracer) Begin(ctx context.Context, name, detail string) *Span

Begin starts a step keyed by its name.

func (*Tracer) BeginKey

func (t *Tracer) BeginKey(ctx context.Context, name, key, detail string) *Span

BeginKey starts a step whose key differs from its name (one per layer, probe).

func (*Tracer) Clone

func (t *Tracer) Clone() *Tracer

Clone copies a buffered tracer so one deploy's shared steps can gain per-service steps without leaking them to its siblings.

func (*Tracer) Flush

func (t *Tracer) Flush(ctx context.Context, sink Sink, attemptID, service string)

Flush writes every buffered step to sink under attemptID, labelled with service when the step has none. It can run once per attempt (a compose file's shared steps go to each service's attempt).

func (*Tracer) Has

func (t *Tracer) Has(key string) bool

Has reports whether a buffered step with key exists.

func (*Tracer) Note

func (t *Tracer) Note(ctx context.Context, name, status, reason, detail string)

Note records an instantaneous step.

func (*Tracer) NoteKey

func (t *Tracer) NoteKey(ctx context.Context, name, key, status, reason, detail string)

NoteKey is Note with an explicit key.

func (*Tracer) WithService

func (t *Tracer) WithService(name string) *Tracer

WithService labels steps with a compose service name.

Jump to

Keyboard shortcuts

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