package stats

import "golang.org/x/pkgsite/internal/middleware/stats"

Index

Functions

func Elapsed

func Elapsed(ctx context.Context, name string) func()

Elapsed records as a stat the elapsed time for a function execution. Invoke like so:

defer Elapsed(ctx, "FunctionName")()

The resulting stat will be called "FunctionName ms" and will be the wall-clock execution time of the function in milliseconds.

func Stats

func Stats() func(http.Handler) http.Handler

Stats returns a Middleware that, instead of serving the page, serves statistics about the page.

Types

type PageStats

type PageStats struct {
	MillisToFirstByte int64
	MillisToLastByte  int64
	Hash              uint64 // hash of page contents
	Size              int    // total size of data written
	StatusCode        int    // HTTP status
	Other             map[string]any
}

Source Files

stats.go

Version
v0.0.0-20250218150137-224a1368cf02 (latest)
Published
Feb 18, 2025
Platform
linux/amd64
Imports
6 packages
Last checked
2 months ago

Tools for package owners.