Documentation
¶
Overview ¶
Package statsviz serves via its HTTP server an HTML page displaying live visualization of the application runtime statistics.
Either Register statsviz HTTP handlers with the http.ServeMux you're using (preferred method):
mux := http.NewServeMux() statsviz.Register(mux)
Or register them with the http.DefaultServeMux:
statsviz.RegisterDefault()
If your application is not already running an HTTP server, you need to start one. Add "net/http" and "log" to your imports and the following code to your main function:
go func() { log.Println(http.ListenAndServe("localhost:6060", nil)) }()
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Index = IndexAtRoot(defaultRoot)
Index responds to a request for /debug/statsviz with the statsviz HTML page which shows a live visualization of the statistics sent by the application over the websocket handler Ws.
Functions ¶
func IndexAtRoot ¶ added in v0.2.0
IndexAtRoot returns an index statsviz handler rooted at root. It's useful if you desire your server to responds with the statsviz HTML page at a path that is different than /debug/statsviz.
func Register ¶
func Register(mux *http.ServeMux, opts ...OptionFunc) error
Register registers statsviz HTTP handlers on the provided mux.
func RegisterDefault ¶
func RegisterDefault(opts ...OptionFunc)
RegisterDefault registers statsviz HTTP handlers on the default serve mux.
Note this is not advised on a production server, unless it only serves on localhost.
Types ¶
type OptionFunc ¶ added in v0.2.0
type OptionFunc func(s *server) error
An OptionFunc is a server configuration option.
func Root ¶ added in v0.2.0
func Root(root string) OptionFunc
Root sets the root of statsviz handlers.
func SendFrequency ¶ added in v0.2.0
func SendFrequency(freq time.Duration) OptionFunc
SendFrequency defines the frequency at which statistics are sent from the application to the HTML page.