Popularity
8.1
Growing
Activity
6.6
-
1,711
21
59

Programming language: Go
License: MIT License
Tags: Performance    
Latest version: v0.4.0

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

Statsviz

go.dev reference Mentioned in Awesome Go Latest tag
Test Actions Status Test Actions Status codecov

Instant Live Visualization of your Go application runtime statistics Heap, Objects, Goroutines, GC, 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 that work?

Statsviz serves 2 HTTP handlers.

The first one (by default /debug/statsviz) serves an html/js user interface showing some initially empty plots.

When you points your browser to statsviz user interface page, it connects to statsviz second HTTP handler. This second handler then upgrades the connection to the websocket protocol and starts a goroutine that periodically calls runtime.ReadMemStats, sending the result to the user interface, which inturn, updates the plots.

Stats are stored in-browser inside a circular buffer which keep tracks of a predefined number of datapoints, 60, 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 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/.

Go version

You need at least go1.16 due to the use of go:embed.
However you can still use Statsviz with older Go versions, at least go1.12, by locking the module to [email protected] in your go.mod.

go get github.com/arl/[email protected]

Documentation

Check out the API documentation.

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

Examples

Have a look at the [_example](./_example/README.md) directory to see various ways to use Statsviz, such as:

  • using http.DefaultServeMux
  • using your own http.ServeMux
  • wrap HTTP handler behind a middleware
  • register at /foo/bar instead of /debug/statviz
  • use https:// rather than http://
  • using with various Go HTTP libraries/frameworks:
    • fasthttp
    • gin
    • and many others thanks to awesome contributors!

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
  • [x] 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.