Documentation ¶
Overview ¶
Package statsviz serves via its HTTP server an HTML page displaying live visualization of the application runtime statistics.
The package is typically only imported for the side effect of registering its HTTP handler. The handled path is /debug/statsviz/.
To use statsviz, link this package into your program:
import _ "github.com/arl/statsviz"
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)) }()
If you are not using DefaultServeMux, you will have to register handlers with the mux you are using.
Then open your browser at http://localhost:6060/debug/statsviz/
Index ¶
Constants ¶
This section is empty.
Variables ¶
var Index = http.StripPrefix(RootDir, http.FileServer(assets))
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.
The package initialization registers it as /debug/statsviz/.
var (
RootDir = "/debug/statsviz/"
)
Functions ¶
func RegisterDefault ¶
func RegisterDefault()
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.
func SetRootDir ¶
func SetRootDir(prefix string)
func Ws ¶
func Ws(w http.ResponseWriter, r *http.Request)
Ws upgrades the HTTP server connection to the WebSocket protocol and sends application statistics every second.
If the upgrade fails, an HTTP error response is sent to the client. The package initialization registers it as /debug/statsviz/ws.
Types ¶
This section is empty.