report

package
v0.5.0 Latest Latest
Warning

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

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

Documentation

Overview

Package report turns a flow's live counters into streaming interval reports and an end-of-run summary, emitted to a pluggable sink (human/json/...). See DESIGN.md §7.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type Human

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

Human writes human-readable lines to w.

func NewHuman

func NewHuman(w io.Writer) *Human

NewHuman returns a Human reporter writing to w.

func (*Human) Sample

func (h *Human) Sample(s Sample)

Sample implements Reporter.

func (*Human) Summary

func (h *Human) Summary(s Summary)

Summary implements Reporter.

type JSON

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

JSON writes one JSON object per line (json-lines).

func NewJSON

func NewJSON(w io.Writer) *JSON

NewJSON returns a JSON reporter writing to w.

func (*JSON) Sample

func (j *JSON) Sample(s Sample)

Sample implements Reporter.

func (*JSON) Summary

func (j *JSON) Summary(s Summary)

Summary implements Reporter.

type Reporter

type Reporter interface {
	Sample(Sample)
	Summary(Summary)
}

Reporter consumes interval samples and a final summary.

type Sample

type Sample struct {
	Elapsed    time.Duration
	Bytes      uint64
	Packets    uint64
	BitsPerSec float64 // windowed throughput at this sample
}

Sample is a point-in-time reading during a run.

type Summary

type Summary struct {
	Duration      time.Duration
	Bytes         uint64
	Packets       uint64
	AvgBitsPerSec float64
}

Summary is the end-of-run total.

func Collect

func Collect(ctx context.Context, c *accounting.Counters, interval time.Duration, r Reporter, done <-chan struct{}) Summary

Collect samples c every interval and emits to r until done is closed or ctx is cancelled, then emits and returns the final Summary.

Jump to

Keyboard shortcuts

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