Popularity
7.6
Growing
Activity
8.2
Declining
1,032
16
42

Programming language: JavaScript
License: MIT License
Tags: Performance    
Latest version: v0.2.1

statsviz alternatives and similar packages

Based on the "Performance" category.
Alternatively, view statsviz alternatives based on common mentions on social networks and blogs.

Do you think we are missing an alternative of statsviz or a related project?

Add another 'Performance' Package

README

go.dev reference Test Actions Status Go Report Card codecov

Statsviz

Instant live visualization of your Go application runtime statistics (GC, MemStats, etc.).

  • Import "github.com/arl/statsviz"
  • Register statsviz HTTP handlers
  • Start your program
  • Open your browser at http://host:port/debug/statsviz
  • Enjoy...

How does it work?

What statsviz does is actually quite simple...

It's composed of 2 HTTP handlers.

When the first one is called(by default /debug/statsviz), it serves an html/js user interface showing some plots, initially empty, in your browser.

The browser then connects to statsviz second HTTP handler. The second one upgrades the connection to the websocket protocol and starts a goroutine that periodically calls runtime.ReadMemStats.

Stats are sent, via websocket, to the user interface, which inturn, updates the plots.

Stats are stored in-browser inside a circular buffer which keep tracks of 60 datapoints, so one minute-worth of data by default. You can change the frequency at which stats are sent by passing SendFrequency to Register.

Usage

go get -u github.com/arl/statsviz

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))
}()

By default the handled path is /debug/statsviz/.

Then open your browser at http://localhost:6060/debug/statsviz/

Examples

Using http.DefaultServeMux:

  • [_example/default/main.go](./_example/default/main.go)

Using your own http.ServeMux:

  • [_example/mux/main.go](./_example/mux/main.go)

Serve statsviz on /foo/bar instead of default /debug/statsviz:

  • [_example/root/main.go](./_example/root/main.go)

Serve on https (and wss for websocket):

  • [_example/https/main.go](./_example/https/main.go)

With gorilla/mux router:

  • [_example/gorilla/main.go](./_example/gorilla/main.go)

Using labstack/echo router:

  • [_example/echo/main.go](./_example/echo.go)

With gin-gonic/gin web framework:

  • [_example/gin/main.go](./_example/gin/main.go)

With go-chi/chi router:

  • [_example/chi/main.go](./_example/chi/main.go)

Plots

On the plots where it matters, garbage collections are shown as vertical lines.

Heap

MSpans / MCaches

Size classes heatmap

Objects

Goroutines

GC/CPU fraction

Contributing

Pull-requests are welcome! More details in [CONTRIBUTING.md](CONTRIBUTING.md)

Roadmap

  • [ ] add stop-the-world duration heatmap
  • [ ] increase data retention
  • [ ] light/dark mode selector
  • [ ] plot image export as png
  • [ ] save timeseries to disk
  • [ ] load from disk previously saved timeseries

Changelog

See [CHANGELOG.md](./CHANGELOG.md).

License

  • [MIT License](LICENSE)


*Note that all licence references and agreements mentioned in the statsviz README section above are relevant to that project's source code only.