statsview

package module
v0.1.0 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Nov 15, 2020 License: MIT Imports: 9 Imported by: 12

README

🚀 Statsview

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

Installation

$ go get -u github.com/go-echarts/statsview/...

Usage

Statsview is quite simple to use.

import (
    "time"

    "github.com/go-echarts/statsview"
)

func main() {
    go func() {
        mgr := statsview.New()

        // Start() runs a HTTP server at `localhost:10866` by default.
        mgr.Start()

        // Stop() will shutdown the http server gracefully
        // mgr.Stop()
    }()

    // busy working....
    time.Sleep(time.Minute)
}

// Visit your browser at http://localhost:10866/statsview/debug

Configuration

Statsview gets a variety of configurations for the users. Everyone could customzie thier favorite charts style.

// WithInterval sets the interval(in millisecond) of collecting and pulling metrics
// default -> 1500
WithInterval(interval int)

// WithMaxPoints sets the maximum points of each chart series
// default -> 40
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 listen address
// default -> "localhost:18066"
WithAddr(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
// * ThemeWalden
// * ThemeMacarons
WithTheme(theme Theme)
Set the options
import (
    "github.com/go-echarts/statsview/viewer"
)

// set configurations before calling the `Start()` method
viewer.SetConfiguration(viewer.WithTheme(viewer.ThemeWalden), view.WithAddr("localhost:8087"))

Viewers

Viewer is the abstraction of a Graph which in charge of collecting metrics from somewhere. Statsview provides some default viewers as below.

  • GCCPUFractionViewer
  • GCNumViewer
  • GCSizeViewer
  • GoroutinesViewer
  • HeapViewer
  • StackViewer

Viewer wraps a go-echarts Line instance that means you can use all of the options/features on it. To be honest, I think that is the most charming thing of this project.

Snapshot

ThemeMacarons

Macarons

ThemeWesteros

Westeros

License

MIT ©chenjiandongx

Documentation

Index

Constants

This section is empty.

Variables

This section is empty.

Functions

This section is empty.

Types

type ViewManager

type ViewManager struct {
	Views []viewer.Viewer
	// contains filtered or unexported fields
}

ViewManager

func New

func New() *ViewManager

New creates a new ViewManager instance

func (*ViewManager) Register

func (vm *ViewManager) Register(views ...viewer.Viewer)

Register registers views to the ViweManager

func (*ViewManager) Start

func (vm *ViewManager) Start()

Start runs a http server and begin to collect metrics

func (*ViewManager) Stop

func (vm *ViewManager) Stop()

Stop shutdown the http server gracefully

Directories

Path Synopsis

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL