Documentation
¶
Overview ¶
Package webvitals is how the page tells the server how fast it was: the time from opening Sinopia's home to every card drawn, and the largest contentful paint. The page sends one small POST per number; the hub counts it in a histogram (harnessly_hub_web_vital_seconds{name}) and a runtime without a hub writes it to its own journal. The set of names is closed: a name nobody listed is dropped, so a label never grows from what a client sends.
Index ¶
Constants ¶
const ( SinopiaHomeFull = "sinopia_home_full" // from opening the home to all its cards drawn LCP = "lcp" // largest contentful paint of the page )
The names the page may send.
const MaxSeconds = 120
MaxSeconds is the longest time taken as a measurement; a tab left in the background for an hour says nothing of speed.
Variables ¶
var Names = [...]string{SinopiaHomeFull, LCP}
Names is the closed set, in the order the metric lists them.
Functions ¶
func Serve ¶
Serve answers one report: POST {name, seconds}. A sample that passes is given to sink; a name nobody listed or a time that cannot be one is answered 204 and dropped (the page has nothing to fix), a bad body is 400, too many reports from one key 429. key names who sends (the person, the address).
Types ¶
type Limiter ¶
Limiter lets one key send so many reports in a window; the rest are dropped.
func NewLimiter ¶
func NewLimiter() *Limiter
NewLimiter is 60 reports a minute for one key: a page sends a couple in a visit.