nettrace

package
v0.7.2 Latest Latest
Warning

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

Go to latest
Published: Nov 12, 2025 License: Apache-2.0 Imports: 4 Imported by: 0

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Budget

type Budget struct {
	Total     time.Duration
	Tolerance time.Duration
	Phases    map[PhaseKind]time.Duration
}

func (Budget) Clone

func (b Budget) Clone() Budget

Clone produces a deep copy of the budget to prevent shared mutations.

type BudgetBreach

type BudgetBreach struct {
	Kind   PhaseKind
	Limit  time.Duration
	Actual time.Duration
	Over   time.Duration
}

type BudgetReport

type BudgetReport struct {
	Breaches []BudgetBreach
}

func EvaluateBudget

func EvaluateBudget(tl *Timeline, b Budget) BudgetReport

func (BudgetReport) WithinLimit

func (r BudgetReport) WithinLimit() bool

type Collector

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

func NewCollector

func NewCollector() *Collector

func (*Collector) Begin

func (c *Collector) Begin(kind PhaseKind, ts time.Time)

func (*Collector) Complete

func (c *Collector) Complete(ts time.Time)

func (*Collector) End

func (c *Collector) End(kind PhaseKind, ts time.Time, err error)

func (*Collector) Fail

func (c *Collector) Fail(err error)

func (*Collector) Merge

func (c *Collector) Merge(other *Collector) error

func (*Collector) SortedPhases

func (c *Collector) SortedPhases() []Phase

func (*Collector) Timeline

func (c *Collector) Timeline() *Timeline

func (*Collector) UpdateMeta

func (c *Collector) UpdateMeta(kind PhaseKind, fn func(*PhaseMeta))

type Phase

type Phase struct {
	Kind     PhaseKind
	Start    time.Time
	End      time.Time
	Duration time.Duration
	Err      string
	Meta     PhaseMeta
}

type PhaseKind

type PhaseKind string
const (
	PhaseDNS      PhaseKind = "dns"
	PhaseConnect  PhaseKind = "connect"
	PhaseTLS      PhaseKind = "tls"
	PhaseReqHdrs  PhaseKind = "request_headers"
	PhaseReqBody  PhaseKind = "request_body"
	PhaseTTFB     PhaseKind = "ttfb"
	PhaseTransfer PhaseKind = "transfer"
	PhaseTotal    PhaseKind = "total"
)

type PhaseMeta

type PhaseMeta struct {
	Addr   string
	Reused bool
	Cached bool
}

type Report

type Report struct {
	Timeline     *Timeline
	Budget       Budget
	BudgetReport BudgetReport
}

Report summarises a collected timeline along with evaluated budgets.

func NewReport

func NewReport(tl *Timeline, budget Budget) *Report

NewReport builds a trace report for the provided timeline and budget. The timeline is cloned to keep the report immutable.

func (*Report) Clone

func (r *Report) Clone() *Report

Clone returns a deep copy of the report so callers can safely mutate it.

type Timeline

type Timeline struct {
	Started   time.Time
	Completed time.Time
	Duration  time.Duration
	Err       string
	Phases    []Phase
}

func (*Timeline) Clone

func (tl *Timeline) Clone() *Timeline

Jump to

Keyboard shortcuts

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