web

package
v0.3.2 Latest Latest
Warning

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

Go to latest
Published: Aug 3, 2026 License: MIT Imports: 22 Imported by: 0

Documentation

Overview

Package web renders isutools measurements: a live report, a self-contained downloadable snapshot.html, machine-readable JSON, and a reset endpoint.

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

func NewHandler

func NewHandler(p Provider) http.Handler

NewHandler returns the report handler. Routes are relative: GET / (run index), GET /<run-id> (stored run detail), GET /live, GET /snapshot.html, GET /json, GET /files/<name>, POST /reset, POST /collect, POST /save.

Types

type Meta

type Meta struct {
	SchemaVersion int    `json:"schema_version"`
	Time          string `json:"time"`
	Generation    int64  `json:"generation"`
	Revision      string `json:"revision"`
	Dirty         bool   `json:"dirty"`
	// Score is the benchmark score supplied via POST /save?score=; persisted
	// snapshots always carry it so every report is attributable to a result.
	Score   string         `json:"score,omitempty"`
	Host    sysinfo.Info   `json:"host"`
	Partial bool           `json:"partial"`
	Health  []health.Entry `json:"health,omitempty"`
}

Meta identifies when, on which host, and from which revision a snapshot was taken. Generation increments on every reset so runs are comparable.

type Provider

type Provider struct {
	SQL sqlSnapshotter
	// SQLGeneration and RotateSQL opt into atomic generation boundaries. They
	// are separate callbacks so simple aggregation tables remain usable in
	// tests and custom integrations.
	SQLGeneration  func() int64
	RotateSQL      func() (generation int64, entries []agg.Entry)
	Health         *health.Registry
	HTTP           httpCollector
	AccessLog      accessLogCollector
	AccessLogQuiet time.Duration
	AccessLogPoll  time.Duration
	CollectTimeout time.Duration
	Proc           processCollector
	// DB captures the database schema (tables/indexes). Called at handler
	// startup and on every reset so each generation records the pre-run state.
	DB func(context.Context) *dbinspect.Schema
	// DataDir persists snapshots for the dashboard history ("" = disabled).
	DataDir string
}

Provider supplies the collectors to render. Nil fields are skipped.

type Snapshot

type Snapshot struct {
	Meta      Meta                `json:"meta"`
	DB        *dbinspect.Schema   `json:"db,omitempty"`
	SQL       []agg.Entry         `json:"sql"`
	HTTP      httpstats.Snapshot  `json:"http,omitempty"`
	AccessLog *accesslog.Snapshot `json:"accesslog,omitempty"`
	Proc      *procstats.Snapshot `json:"proc,omitempty"`
}

Snapshot is the complete state of all measurements at one point in time.

Jump to

Keyboard shortcuts

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