ericMetrics

package module
v1.0.3 Latest Latest
Warning

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

Go to latest
Published: Nov 11, 2022 License: MIT Imports: 10 Imported by: 0

README

eric-metrics

golang runtime 监控

实时可视化Go程序运行时度量数据:堆、对象、goroutines、GC暂停、调度器等。

使用

包下载:

go get -u gitee.com/tym_hmm/eric-metrics

注册组件 更多使用见example

ericMetrics.RegisterDefault()
log.Println(http.ListenAndServe(":6060", nil))

查看数据 http://<server:port>/debug/eric-metrics

Documentation

Overview

Package eric-metrics allows to visualise Go program runtime metrics data in real time: heap, objects, goroutines, GC pauses, scheduler, etc. in your browser.

Register eric-metrics endpoint on your server http.ServeMux (preferred method):

mux := http.NewServeMux()
ericMetrics.Register(mux)

Or register on `http.DefaultServeMux`:

ericMetrics.RegisterDefault()

By default eric-metrics is served at `/debug/eric-metrics/`.

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))
}()

Then open your browser at http://localhost:6060/debug/eric-metrics/.

Index

Constants

This section is empty.

Variables

View Source
var Index = IndexAtRoot(defaultRoot)

Index responds to a request for /debug/eric-metrics with the eric-metrics HTML page which shows a live visualization of the statistics sent by the application over the websocket handler Ws.

View Source
var Ws = NewWsHandler(defaultSendFrequency)

Ws is a default Websocket handler, created with NewWsHandler, sending statistics at the default frequency of 1 message per second.

Functions

func IndexAtRoot

func IndexAtRoot(root string) http.HandlerFunc

IndexAtRoot returns an index eric-metrics handler rooted at root. It's useful if you desire your server to responds with the eric-metrics HTML page at a path that is different than /debug/eric-metrics.

func NewWsHandler

func NewWsHandler(frequency time.Duration) http.HandlerFunc

NewWsHandler returns a handler that upgrades the HTTP server connection to the WebSocket protocol and sends application statistics at the given frequency.

If the upgrade fails, an HTTP error response is sent to the client.

func Register

func Register(mux *http.ServeMux, opts ...OptionFunc) error

Register registers eric-metrics HTTP handlers on the provided mux.

func RegisterDefault

func RegisterDefault(opts ...OptionFunc) error

RegisterDefault registers eric-metrics HTTP handlers on the default serve mux.

Note this is not advised on a production server, unless it only serves on localhost.

Types

type OptionFunc

type OptionFunc func(s *server) error

An OptionFunc is a server configuration option.

func Root

func Root(root string) OptionFunc

Root sets the root path of eric-metrics handlers.

func SendFrequency

func SendFrequency(freq time.Duration) OptionFunc

SendFrequency defines the frequency at which statistics are sent from the application to the HTML page.

Directories

Path Synopsis
internal

Jump to

Keyboard shortcuts

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