reporter

package
v0.0.0-...-e6b30e8 Latest Latest
Warning

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

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

Documentation

Index

Constants

View Source
const (
	// EnvFramesToken is sent as `Authorization: Bearer <token>` with every
	// frames request. Unset means no Authorization header.
	EnvFramesToken = "DEVTOOLS_FRAMES_TOKEN"
	// EnvWorkerID names this machine in every envelope; the hostname is
	// used when it is unset.
	EnvWorkerID = "DEVTOOLS_WORKER_ID"
)

Environment variables the frame reporter reads.

View Source
const (
	ReportFormatConsole = "console"
	ReportFormatJSON    = "json"
	ReportFormatJUnit   = "junit"
	// ReportFormatFrames streams a load run's interval frames, and posts its
	// final report, to an HTTP endpoint: --report frames:<url>.
	ReportFormatFrames = "frames"
)
View Source
const CleanupStepPrefix = "[cleanup] "

CleanupStepPrefix is prepended to cleanup step names in the console table and JUnit test case names.

View Source
const (
	DefaultDeadManAfter = 60 * time.Second
)

Frame reporter defaults.

View Source
const LoadMetricsScope = "Counts HTTP request steps only; GraphQL, WebSocket and sub-flow steps run but are neither counted nor memory-bounded."

LoadMetricsScope states what a load run measures, and by extension what it keeps memory-flat. It is surfaced in both the console output and the JSON report so nobody has to infer the boundary from a suspiciously empty table.

Variables

This section is empty.

Functions

func DisplayStepName

func DisplayStepName(name string, cleanup bool) string

DisplayStepName is the name reporters show for a step.

func FormatDuration

func FormatDuration(d time.Duration) string

FormatDuration formats a duration for display

func FormatLoadHeader

func FormatLoadHeader(meta LoadRunMeta) string

FormatLoadHeader renders the one-off context lines printed above the table. It is deliberately separate so the table itself stays exactly as published.

func FormatLoadTable

func FormatLoadTable(report LoadReport) string

FormatLoadTable renders the aggregate console table: one row per step plus a TOTAL row, sorted by step name so the output is stable across runs.

func FormatLoadVerdicts

func FormatLoadVerdicts(meta LoadRunMeta) string

FormatLoadVerdicts renders what is printed below the table: each threshold's verdict and, for a run stopped early, why. It is empty for an exploratory run that ran its course.

func FrameFromProto

func FrameFromProto(pb *load_metricsv1.LoadMetricFrame) (loadmetrics.Frame, error)

FrameFromProto is the inverse of LoadMetricFrameProto, for a collector that merges frames from several machines with loadmetrics.Combine or loadmetrics.Merge.

func LoadMetricFrameProto

func LoadMetricFrameProto(frame loadmetrics.Frame) (*load_metricsv1.LoadMetricFrame, error)

LoadMetricFrameProto converts an interval frame to the wire model: one entry per (step, status class), sorted, each carrying its compressed HDR histogram alongside the derived percentiles.

func LoadStatusClassFromProto

func LoadStatusClassFromProto(class load_metricsv1.LoadStatusClass) loadmetrics.StatusClass

LoadStatusClassFromProto is the inverse of LoadStatusClassToProto. UNSPECIFIED, and any value this build does not know, yield "".

func LoadStatusClassToProto

func LoadStatusClassToProto(class loadmetrics.StatusClass) load_metricsv1.LoadStatusClass

LoadStatusClassToProto converts an aggregation status class to the wire enum. An unrecognized class yields UNSPECIFIED rather than guessing.

Types

type FlowStartInfo

type FlowStartInfo struct {
	FlowID     string
	FlowName   string
	TotalNodes int
	NodeNames  []string
}

type FrameSink

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

FrameSink streams a load run's interval frames to an HTTP endpoint and posts the final report when the run is flushed. It implements Reporter, so it rides in a ReporterGroup like any other report target, and it is the reporter behind `--report frames:<url>`.

Every POST body is a JSON envelope. A frame:

{"kind":"frame","worker":"...","scenario":"...","flow":"...","seq":0,
 "final":false,"active_vus":4,"dropped_iterations":0,
 "frame":<LoadMetricFrame as protojson, one entry per (step, status class)
          with its compressed HDR histogram>}

and the final report:

{"kind":"report","worker":"...","scenario":"...","flow":"...",
 "frames_sent":12,"frames_dropped":0,"load_report":<the JSON reporter's load_report>}

Sending never blocks the caller: frames are queued and posted by a single background goroutine, retried with exponential backoff on network errors, 408, 429 and 5xx responses.

func NewFrameSink

func NewFrameSink(opts FrameSinkOptions) *FrameSink

NewFrameSink returns a sink for opts. Call Start when the run starts.

func (*FrameSink) Dropped

func (s *FrameSink) Dropped() int64

Dropped is how many frames were given up on: the queue was full, every retry failed, or the run ended before they could be sent.

func (*FrameSink) Flush

func (s *FrameSink) Flush() error

Flush drains the queued frames and posts the final report, within FinalTimeout. Without a load report (a run that never executed) it posts nothing. It returns an error when the final report could not be delivered; undelivered frames are only counted.

func (*FrameSink) HandleFlowResult

func (s *FrameSink) HandleFlowResult(model.FlowRunResult)

HandleFlowResult implements Reporter; functional runs stream nothing.

func (*FrameSink) HandleFlowStart

func (s *FrameSink) HandleFlowStart(FlowStartInfo)

HandleFlowStart implements Reporter; functional runs stream nothing.

func (*FrameSink) HandleNodeStatus

func (s *FrameSink) HandleNodeStatus(NodeStatusEvent)

HandleNodeStatus implements Reporter; functional runs stream nothing.

func (*FrameSink) SendFrame

func (s *FrameSink) SendFrame(seq int64, frame loadmetrics.Frame, activeVUs, dropped int64, final bool)

SendFrame queues one interval frame for delivery and returns at once. A frame that finds the queue full is dropped and counted.

func (*FrameSink) Sent

func (s *FrameSink) Sent() int64

Sent is how many frames the endpoint accepted.

func (*FrameSink) SetDeadMan

func (s *FrameSink) SetDeadMan(after time.Duration, onDeadMan func(reason string))

SetDeadMan installs the dead-man callback and its timeout; it must be called before Start. A zero after keeps the configured timeout.

func (*FrameSink) SetLoadReport

func (s *FrameSink) SetLoadReport(report *LoadReport)

SetLoadReport implements loadReportSink: the report is posted on Flush.

func (*FrameSink) SetRunInfo

func (s *FrameSink) SetRunInfo(scenario, flow, version string)

SetRunInfo names the run in every envelope and the User-Agent.

func (*FrameSink) Start

func (s *FrameSink) Start()

Start begins the dead-man clock. Frames may be sent only after Start.

type FrameSinkOptions

type FrameSinkOptions struct {
	// URL receives every frame and the final report, as JSON POSTs.
	URL string
	// Token is the bearer token; NewReporterGroup reads EnvFramesToken.
	Token string
	// WorkerID identifies this machine; NewReporterGroup reads EnvWorkerID,
	// falling back to the hostname.
	WorkerID string
	// Client is the HTTP client used for every request.
	Client *http.Client
	// QueueSize bounds the frames waiting to be sent. A frame that finds the
	// queue full is dropped (and counted), never waited for.
	QueueSize int
	// RetryBase is the first retry's backoff; each retry doubles it, up to
	// 5s.
	RetryBase time.Duration
	// FinalTimeout bounds Flush: draining queued frames plus posting the
	// final report.
	FinalTimeout time.Duration
	// DeadManAfter is how long the endpoint may go without accepting a
	// request, once the sink has started, before OnDeadMan fires.
	DeadManAfter time.Duration
	// OnDeadMan is called at most once, when the endpoint has been
	// unreachable for DeadManAfter. A load run uses it to stop itself, so a
	// generator whose controller has gone away cannot keep hitting a target.
	OnDeadMan func(reason string)
}

FrameSinkOptions configures a FrameSink. Zero values mean the defaults.

type LoadReport

type LoadReport struct {
	Meta   LoadRunMeta
	Report loadmetrics.Report
	ByStep loadmetrics.Report
}

LoadReport is a completed load run in the shape the reporters need: metadata, the full (step, status-class) breakdown, and the same data folded to one row per step for the console table.

type LoadRunMeta

type LoadRunMeta struct {
	// ScenarioName is the `load:` block entry the profile came from, empty
	// for a run configured entirely from flags.
	ScenarioName string
	FlowName     string
	VUs          int
	// Duration and MaxIterations are the configured stop conditions.
	Duration      time.Duration
	MaxIterations int64
	// Iterations, Errors and Elapsed are what actually happened.
	Iterations int64
	Errors     int64
	Elapsed    time.Duration
	// Requests is how many HTTP requests the report counts. Only request
	// steps are counted - never the manual_start node or other non-request
	// nodes (see LoadMetricsScope).
	Requests int64
	// Interrupted counts iterations cut short by a graceful ramp-down or
	// stop; Dropped counts arrival-rate iterations that found no free VU.
	Interrupted int64
	Dropped     int64
	// WorkerVersion identifies the binary that produced the numbers, so
	// baselines from different builds are not silently compared.
	WorkerVersion string

	// Executor is the scheduling strategy; "" means constant-vus.
	Executor string
	// Profile describes a non-constant-vus schedule in one line, e.g.
	// "0->20 VUs over 3 stages (2m0s)". Unused for constant-vus, whose VUs
	// and stop conditions have their own fields.
	Profile string
	// Thresholds are the run's threshold verdicts, in configuration order.
	Thresholds []LoadThresholdResult
	// AbortReason says why the run stopped early, or is "".
	AbortReason string
}

LoadRunMeta describes the load run that produced a report: which profile ran, and what the scheduler actually managed to do.

func (LoadRunMeta) ThresholdsPassed

func (m LoadRunMeta) ThresholdsPassed() bool

ThresholdsPassed reports whether every threshold held; true when there are none.

type LoadThresholdResult

type LoadThresholdResult struct {
	// Expression is the threshold in its canonical form, e.g. p95<300ms.
	Expression string
	Passed     bool
	// Observed is the measured value as text, or "no data".
	Observed string
}

LoadThresholdResult is one threshold's verdict, ready to print.

type NodeStatusEvent

type NodeStatusEvent struct {
	FlowID   string
	FlowName string
	Status   runner.FlowNodeStatus
	// Cleanup marks a step from the flow's cleanup: block.
	Cleanup bool
	// SkipReason is set when the step did not run; Status.State is then not
	// meaningful.
	SkipReason string
}

type ReportSpec

type ReportSpec struct {
	Format string
	Path   string
}

func ParseReportSpecs

func ParseReportSpecs(values []string) ([]ReportSpec, error)

type Reporter

type Reporter interface {
	HandleFlowStart(info FlowStartInfo)
	HandleNodeStatus(event NodeStatusEvent)
	HandleFlowResult(result model.FlowRunResult)
	Flush() error
}

type ReporterGroup

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

func NewReporterGroup

func NewReporterGroup(specs []ReportSpec, opts ReporterOptions) (*ReporterGroup, error)

func (*ReporterGroup) Flush

func (g *ReporterGroup) Flush() error

func (*ReporterGroup) FrameSink

func (g *ReporterGroup) FrameSink() *FrameSink

FrameSink returns the group's frames reporter, or nil when --report has no frames target. The load runner feeds it interval frames directly.

func (*ReporterGroup) HandleFlowResult

func (g *ReporterGroup) HandleFlowResult(result model.FlowRunResult)

func (*ReporterGroup) HandleFlowStart

func (g *ReporterGroup) HandleFlowStart(info FlowStartInfo)

func (*ReporterGroup) HandleNodeStatus

func (g *ReporterGroup) HandleNodeStatus(event NodeStatusEvent)

func (*ReporterGroup) HasConsole

func (g *ReporterGroup) HasConsole() bool

func (*ReporterGroup) SetLoadReport

func (g *ReporterGroup) SetLoadReport(report *LoadReport)

SetLoadReport hands the load report to every reporter that can use it. It must be called before Flush. Reporters that never receive one behave exactly as they did before load mode existed.

type ReporterOptions

type ReporterOptions struct {
	ShowOutput bool // Show node output data in console reporter
}

ReporterOptions contains configuration options for reporters.

Jump to

Keyboard shortcuts

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