Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/go-echarts/statsview
π A real-time Golang runtime stats visualization profiler
https://github.com/go-echarts/statsview
Last synced: 5 days ago
JSON representation
π A real-time Golang runtime stats visualization profiler
- Host: GitHub
- URL: https://github.com/go-echarts/statsview
- Owner: go-echarts
- License: mit
- Created: 2020-11-15T18:45:41.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-08-10T04:48:22.000Z (5 months ago)
- Last Synced: 2025-01-03T10:03:11.961Z (12 days ago)
- Language: Go
- Homepage:
- Size: 336 KB
- Stars: 580
- Watchers: 12
- Forks: 52
- Open Issues: 1
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
- go-awesome - statsview - Visual analyzer for real-time Go runtime stats (Open source library / Code Analysis)
README
# π Statsview
Statsview is a real-time Golang runtime stats visualization profiler. It is built top on another open-source project, [go-echarts](https://github.com/go-echarts/go-echarts), which helps statsview to show its graphs on the browser.
## π° Installation
```shell
$ go get -u github.com/go-echarts/statsview/...
```## π Usage
Statsview is quite simple to use and all static assets have been packaged into the project which makes it possible to run offline. It's worth pointing out that statsview has integrated the standard `net/http/pprof` hence statsview will be the only profiler you need.
```golang
package mainimport (
"time""github.com/go-echarts/statsview"
)func main() {
mgr := statsview.New()// Start() runs a HTTP server at `localhost:18066` by default.
go mgr.Start()// Stop() will shutdown the http server gracefully
// mgr.Stop()// busy working....
time.Sleep(time.Minute)
}// Visit your browser at http://localhost:18066/debug/statsview
// Or debug as always via http://localhost:18066/debug/pprof, http://localhost:18066/debug/pprof/heap, ...
```## βοΈ Configuration
Statsview gets a variety of configurations for the users. Everyone could customize their favorite charts style.
```golang
// WithInterval sets the interval(in Millisecond) of collecting and pulling metrics
// default -> 2000
WithInterval(interval int)// WithMaxPoints sets the maximum points of each chart series
// default -> 30
WithMaxPoints(n int)// WithTemplate sets the rendered template which fetching stats from the server and
// handling the metrics data
WithTemplate(t string)// WithAddr sets the listening address and link address
// default -> "localhost:18066"
WithAddr(addr string)// WithLinkAddr sets the html link address
// default -> "localhost:18066"
WithLinkAddr(addr string)// WithTimeFormat sets the time format for the line-chart Y-axis label
// default -> "15:04:05"
WithTimeFormat(s string)// WithTheme sets the theme of the charts
// default -> Macarons
//
// Optional:
// * ThemeWesteros
// * ThemeMacarons
WithTheme(theme Theme)
```#### Set the options
```golang
import (
"github.com/go-echarts/statsview"
"github.com/go-echarts/statsview/viewer"
)// set configurations before calling `statsview.New()` method
viewer.SetConfiguration(viewer.WithTheme(viewer.ThemeWesteros), viewer.WithAddr("localhost:8087"))mgr := statsview.New()
go mgr.Start()
```## π Viewers
Viewer is the abstraction of a Graph which in charge of collecting metrics from Runtime. Statsview provides some default viewers as below.
* `GCCPUFractionViewer`
* `GCNumViewer`
* `GCSizeViewer`
* `GoroutinesViewer`
* `HeapViewer`
* `StackViewer`Viewer wraps a go-echarts [*charts.Line](https://github.com/go-echarts/go-echarts/blob/master/charts/line.go) instance that means all options/features on it could be used. To be honest, I think that is the most charming thing about this project.
## π Snapshot
#### ThemeMacarons(default)
![Macarons](https://user-images.githubusercontent.com/19553554/99491359-92d9f680-29a6-11eb-99c8-bc333cb90893.png)
#### ThemeWesteros
![Westeros](https://user-images.githubusercontent.com/19553554/99491179-42629900-29a6-11eb-852b-694662fcd3aa.png)
## π License
MIT [Β©chenjiandongx](https://github.com/chenjiandongx)