gitmyhub

statsviz

Go ★ 3.6k updated 8d ago

Visualise Go runtime metrics in real time

A Go library that adds a live, real-time browser dashboard showing memory, goroutines, and garbage collection inside your running program.

GoWebSocketsHTTPsetup: easycomplexity 2/5

Statsviz is a library for Go programs that adds a live dashboard showing what the program is doing internally while it runs. You add a few lines of code to your application, open a URL in a browser, and see a set of real-time charts that update every second without any manual instrumentation.

The charts cover the internal health of a running Go program: how much memory is allocated on the heap, how many objects are alive, how many goroutines are active, how often the garbage collector runs and how long its pauses last, how the CPU is split between your application code and the runtime's own housekeeping work, and more. Goroutines are a core Go concept for running concurrent tasks; the garbage collector is the automatic memory cleanup system built into Go. If either of these starts misbehaving, it often shows up in the charts before it causes visible problems.

The technical setup is simple. Statsviz registers two HTTP endpoints alongside your existing server: one serves the dashboard web page and the other is a websocket connection that streams the metrics. When you open the dashboard, your browser connects to the websocket and starts receiving data points. Everything runs inside your own program on your own machine or server, so no external service is involved.

The dashboard UI lets you filter charts by category, adjust how much time history is shown, toggle visibility of garbage collection events on the timeline, and pause the live feed if you want to examine a specific moment. You can also define your own custom plots and send your application's own data into the same dashboard.

The library works with most Go HTTP frameworks and can be placed behind authentication middleware or served at a custom path if the default location does not fit your setup. The repository includes working examples for several popular frameworks.

Where it fits