1 Star 0 Fork 0

tym_hmm / eric-metrics

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
克隆/下载
statsviz.go 890 Bytes
一键复制 编辑 原始数据 按行查看 历史
天蝎儿 提交于 2022-11-10 13:56 . edit
package ericMetrics
import (
"gitee.com/tym_hmm/eric-metrics/internal/plot"
"time"
"github.com/gorilla/websocket"
)
var plots plot.List
// sendStats indefinitely send runtime statistics on the websocket connection.
func sendStats(conn *websocket.Conn, frequency time.Duration) error {
tick := time.NewTicker(frequency)
defer tick.Stop()
// If the websocket connection is initiated by an already open web ui
// (started by a previous process for example) then plotsdef.js won't be
// requested. So, call plots.config manually to ensure that the data
// structures inside 'plots' are correctly initialized.
plots.Config()
for range tick.C {
w, err := conn.NextWriter(websocket.TextMessage)
if err != nil {
return err
}
if err := plots.WriteValues(w); err != nil {
return err
}
if err := w.Close(); err != nil {
return err
}
}
panic("unreachable")
}
Go
1
https://gitee.com/tym_hmm/eric-metrics.git
git@gitee.com:tym_hmm/eric-metrics.git
tym_hmm
eric-metrics
eric-metrics
v1.0.3

搜索帮助

53164aa7 5694891 3bd8fe86 5694891