🚀Statsview is a real-time Golang runtime stats visualization profiler

Overview

🚀 Statsview

Statsview is a real-time Golang runtime stats visualization profiler. It is built top on another open-source project, go-echarts, which helps statsview to show its graphs on the browser.

Contributions welcome Go Report Card MIT License GoDoc

🔰 Installation

$ 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.

package main

import (
    "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.

"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) ">
// 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

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 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

ThemeWesteros

Westeros

📄 License

MIT ©chenjiandongx

Comments
  • Optimize: passive polling by HTTP Server

    Optimize: passive polling by HTTP Server

    ping @xiaochai1027

    Please review this PR.

    Now statsview only calls the runtime.ReadMemStats function when receiving the HTTP requests which means that it has no overhead without visiting the /debug/statsview related routes.

    And the Start method returns the error hence you can handle it by yourself.

    opened by chenjiandongx 17
  • Performance issues & Production environment use

    Performance issues & Production environment use

    hi. I want to integrate it into my services。 My service is a high performance live streaming service。 I see that your program will call periodically (Runtime.ReadMemStats()).

    This method says in the source code:

    	stopTheWorld("read mem stats")
    
    	systemstack(func() {
    		readmemstats_m(m)
    	})
    
    	startTheWorld()
    

    Looks like it will pause the program to collect information, shouldn't it be used in production?

    opened by xiaochai1027 6
  • GC Number

    GC Number

    Hi, this isn't exactly an issue, I'd just like to have an explaination about what is the "GC Number" in the charts. Is it the number of garbage collection cycles? My app have an always increasing "GC Number" and I would like to know if this could be a problem.

    Thank you.

    opened by gandaldf 4
  •  Can add custom routing function

    Can add custom routing function

    Can add a custom routing function, like this

    viewer.SetConfiguration(viewer.WithTheme(viewer.ThemeWalden), viewer.WithAddr("localhost:8087"),viewer.WithViewPath("/"))
    
    opened by sxueck 4
  • The stop method blocks the program

    The stop method blocks the program

    I'm calling this method

    ViewManager.Stop()

    ViewManager.Start() also calls the stop method internally

    for {
    		select {
    		case <-ticker.C:
    			viewer.StartRTCollect()
    		case <-vm.done:
    			vm.Stop()
    			ticker.Stop()
    			return
    		}
    	}
    
    opened by xiaochai1027 2
  • feat: separate listening address from access address.

    feat: separate listening address from access address.

    Hi: Our golang applications are deployed in an intranet environment. Users need to access pprof interface by proxy. So we need separate listening address from access address. I have a commit https://github.com/ocean2811/statsview/commit/38d0c35dc2599141d426eab34bbcb6883c7914c9 that implements the feature.

    opened by ocean2811 2
  • Missing Charts

    Missing Charts

    One of my users is reporting that he cannot see all the statsview charts on Windows. He's tried it on a couple of browsers with the same results. These are the screenshots he's given me:

    firefox

    chrome

    I don't have access to Windows here so it is difficult to debug. Is this a known problem?

    Project here:

    https://github.com/JetSetIlly/Gopher2600

    opened by JetSetIlly 2
  • feature request: instead of port number have a route

    feature request: instead of port number have a route

    Hi!

    The access to the graphs is now by using a special port number. This is ok for local apps, but difficult for apps deployed remotely. Because those are behind firewalls and stuff. Or, in the case of Heroku, it is not possible to open (or select) a second port. A special route like '/debug/vars' would work better in those cases.

    opened by Gys 2
  • Customize chart by rewrite templates.ChartTpl, but it seems not work

    Customize chart by rewrite templates.ChartTpl, but it seems not work

    I customize page (add some buttons) successfully by setting templates.PageTpl . However, templates.ChartTpl seems not work. How can i customize part of charts (add button) as my page has a lot of charts? Thanks in advance!

    opened by chaokw 1
  • ThemeWalden not declared by package viewer

    ThemeWalden not declared by package viewer

    Running statsview with the recomended configuration is giving me an error ThemeWalden not declared by package viewer

    I'm adding it as suggested before calling Start() but it seems to be missing something.

    go func() {
    	mgr := statsview.New()
    
    	viewer.SetConfiguration(viewer.WithTheme(viewer.ThemeWalden), view.WithAddr("localhost:8087"))
    
    	// Start() runs a HTTP server at `localhost:18066` by default.
    	mgr.Start()
    

    Gives me ThemeWalden not declared by package viewer

    When expecting to see a different theme and port.

    Also not seeing more than two views when omitting the viewer line. I'm seeing Goroutines and Heap but not the others listed.

    opened by robtrooper 1
  • Change documentation to avoid confusion

    Change documentation to avoid confusion

    After debugging for about an hour, i found that i was calling

    mgr := statsview.New()
    viewer.setConfiguration(viewer.WithAddr("192.168.1.2:18066"))
    go mgr.Start()
    

    which created unexpected results, example a log message on statsview.go#36

    func (vm *ViewManager) Start() error {
        fmt.Printf("Server Addr: %s Expected: %v\n", vm.srv.Addr, viewer.Addr()) // Server Addr: localhost:18066 Expected: 192.168.1.2:18066
        return vm.srv.ListenAndServe()
    }
    

    I want to make sure that the documentation is extremely clear in which the order of the configuration is called.

    opened by Squwid 0
Owner
go-echarts
go-echarts dev team
go-echarts
Callgraph analysis and visualization for Go

Gocyto A Go SSA callgraph builder and visualizer, by @protolambda. Features: output to generic Cytoscape JSON format. (list of nodes, list of edges) o

Diederik Loerakker 137 Nov 3, 2022
gosivy - Another visualization tool for Go process metrics

gosivy Another visualization tool for Go process metrics. Gosivy tracks Go process's metrics and plot their evolution over time right into your termin

Ryo Nakao 448 Nov 9, 2022
Interactive Terraform visualization. State and configuration explorer.

Rover - Terraform Visualizer Rover is a Terraform visualizer. In order to do this, Rover: generates a plan file and parses the configuration in the ro

Tu Nguyen 2.3k Nov 23, 2022
entviz is an ent extension that provides visualization of the schema graph

entviz entviz is an ent extension that creates visual graph (html file) of your ent's schema. install go get github.com/hedwigz/entviz add this exten

Amit Shani 82 Nov 8, 2022
Sloop - Kubernetes History Visualization

Sloop - Kubernetes History Visualization Sloop monitors Kubernetes, recording histories of events and resource state changes and providing visualizati

Salesforce 1.2k Nov 19, 2022
Data visualization with chart, Create CSV file, Read Write CSV file

Data visualization with chart, Create CSV file, Read Write CSV file, Read from json file and many more in single project ......

MD FAISAL PORAG 1 Jan 13, 2022
go chart is a basic charting library in native golang.

Package chart is a very simple golang native charting library that supports timeseries and continuous line charts.

Will Charczuk 3.6k Nov 27, 2022
🎨 The adorable charts library for Golang

go-echarts ?? The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

go-echarts 5k Nov 28, 2022
Globe wireframe visualizations in Golang

globe Globe wireframe visualizations in Golang backed by pinhole. Getting Started Install globe with $ go get -u github.com/mmcloughlin/globe Start wi

Michael McLoughlin 1.6k Nov 10, 2022
go-echarts 🎨 The adorable charts library for Golang

go-echarts ?? The adorable charts library for Golang. If a language can be used to build web scrapers, it definitely needs to provide a graceful data

go-echarts 5k Nov 22, 2022
Ltree Visualizer - A golang library to visualize postgres ltree type data using DOT language and Graphviz

Ltree Visualizer A golang library to visualize postgres ltree type data using DOT language and Graphviz What is Ltree? Ltree is a data type which is u

Vasubabu Jinagam 8 Jun 12, 2022
A golang implementation of endlessh exporting Prometheus metrics, visualized by a Grafana dashboard.

endlessh-go A golang implementation of endlessh exporting Prometheus metrics, visualized by a Grafana dashboard. Introduction Endlessh is a great idea

Shizun Ge 65 Oct 29, 2022
A charts library for Golang

go-charts go-charts基于go-chart生成数据图表,无其它模块的依赖纯golang的实现,支持svg与png的输出,Apache ECharts在前端开发中得到众多开发者的认可,go-charts兼容Apache ECharts的配置参数,简单快捷的生成相似的图表(svg或png

Tree Xie 95 Nov 24, 2022
Gfx - Golang file system extension library

gfx Golang文件操作扩展库,包含工作和生活中关于文件操作的各种有用的使用方法,包括 更友好的API 文件创建 文件删除 文件复制 一切皆可配置 文件名

张川 0 Mar 10, 2022
Nats-subject-profiler - NATS Subject Profiler With Golang

NATS Subject Profiler Example Connect it to the demo NATS server. nats-subject-p

Byron Ruth 2 Feb 7, 2022
Real-time Map displays real-time positions of public transport vehicles in Helsinki

Real-time Map Real-time Map displays real-time positions of public transport vehicles in Helsinki. It's a showcase for Proto.Actor - an ultra-fast dis

ASYNKRON 31 Oct 20, 2022
A simple go application that uses Youtube Data API V3 to show the real-time stats for a youtube channel such as the subs, views, avg. earnings etc.

Youtube-channel-monitor A simple go application that uses Youtube Data API V3 to show the real-time stats for a youtube channel such as the subs, view

null 0 Dec 30, 2021
gosivy - Real-time visualization tool for Go process metrics

Gosivy tracks Go process's metrics and plot their evolution over time right into your terminal, no matter where it's running on. It helps you understand how your application consumes the resources.

Ryo Nakao 448 Nov 9, 2022
🚀 fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together.

?? fgprof - The Full Go Profiler fgprof is a sampling Go profiler that allows you to analyze On-CPU as well as Off-CPU (e.g. I/O) time together. Go's

Felix Geisendörfer 2.3k Nov 19, 2022
A LoRaWAN nodes' and network simulator that works with a real LoRaWAN environment (such as Chirpstack) and equipped with a web interface for real-time interaction.

LWN Simulator A LoRaWAN nodes' simulator to simulate a LoRaWAN Network. Table of Contents General Info Requirements Installation General Info LWN Simu

ARSLab 32 Nov 16, 2022