wire

package
v1.2.0 Latest Latest
Warning

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

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

Documentation

Overview

Package wire converts between Stampede's in-memory metrics and the worker protocol messages, and holds the protocol version both sides negotiate. Keeping the conversions in one place means the worker and the coordinator cannot disagree on how a snapshot is encoded.

Index

Constants

View Source
const (
	ProtocolMajor = 1
	// 1.3: browser phases (fcp, lcp, cls, inp, load). 1.4: busy_elsewhere
	// heartbeats and mid-run takeover (StartRun resume_ns and attempt).
	// 1.5: error examples in step snapshots.
	ProtocolMinor = 5
)

Protocol version spoken by this build. Minor versions only add fields, so any minor of the same major interoperates.

Variables

This section is empty.

Functions

func CheckVersion

func CheckVersion(v *workerv1.ProtocolVersion) error

CheckVersion returns an error explaining why a peer speaking v cannot be served. A missing version is treated as incompatible: every build that speaks this protocol sends one.

func HealthToProto

func HealthToProto(h *Health) *workerv1.Health

HealthToProto encodes h. A nil h encodes as nil.

func MergePhases

func MergePhases(dst, src map[int]*[metrics.NumPhases]*metrics.Histogram)

MergePhases adds src into dst, creating entries as needed.

func PhasesFromProto

func PhasesFromProto(p map[int32]*workerv1.PhaseHistograms) (map[int]*[metrics.NumPhases]*metrics.Histogram, error)

PhasesFromProto decodes PhasesToProto output.

func PhasesToProto

func PhasesToProto(ph map[int]*[metrics.NumPhases]*metrics.Histogram) (map[int32]*workerv1.PhaseHistograms, error)

PhasesToProto encodes run-wide per-step phase histograms.

func SnapshotToProto

func SnapshotToProto(runID string, s *metrics.Snapshot, h *Health) (*workerv1.Snapshot, error)

SnapshotToProto encodes one worker snapshot for a run.

func Version

func Version() *workerv1.ProtocolVersion

Version is the protocol version as a message.

Types

type Health

type Health struct {
	Saturated   bool          `json:"saturated"`
	Reasons     []string      `json:"reasons,omitempty"`
	CPUPercent  float64       `json:"cpuPercent"`
	SchedLagP99 time.Duration `json:"schedLagP99"`
	GCPauseP99  time.Duration `json:"gcPauseP99"`
	OpenFDs     uint64        `json:"openFDs"`
	FDLimit     uint64        `json:"fdLimit"`
	Goroutines  int           `json:"goroutines"`
	Dropped     uint64        `json:"dropped"`
}

Health is a worker's self-monitoring for one sample (normally one second). Saturated means the worker itself, not the target, may be what limits the measured load.

func HealthFromProto

func HealthFromProto(p *workerv1.Health) *Health

HealthFromProto decodes p. A nil p decodes as nil.

func SnapshotFromProto

func SnapshotFromProto(worker string, p *workerv1.Snapshot) (*metrics.Snapshot, *Health, error)

SnapshotFromProto decodes a snapshot sent by worker. The returned snapshot's Worker field is set to worker.

Jump to

Keyboard shortcuts

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