mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
parent
339f07510d
commit
69c44bdd51
@ -131,7 +131,7 @@ func (mh *metricsHandler) run() {
|
||||
if err := bson.Unmarshal(mtrBuf.Bytes(), &mtr); err == nil {
|
||||
out := "metrics = {\n"
|
||||
for k, v := range mtr.Sessions {
|
||||
out += fmt.Sprintf("\t[%v]: %v/%v (%v)\n", k, util.BytesToSize(v.BytesRead), util.BytesToSize(v.BytesWritten), time.Duration(mtr.Now-v.LastUpdate)*time.Millisecond)
|
||||
out += fmt.Sprintf("\t[%v.%v]: %v/%v (%v)\n", mtr.Namespace, k, util.BytesToSize(v.BytesRead), util.BytesToSize(v.BytesWritten), time.Duration(mtr.LocalNow-v.LastUpdate)*time.Millisecond)
|
||||
}
|
||||
out += "}"
|
||||
logrus.Info(out)
|
||||
|
@ -36,7 +36,7 @@ func newMetricsAgent(identityName, metricsServiceName string) (*metricsAgent, er
|
||||
logrus.Infof("loaded '%v' identity", identityName)
|
||||
return &metricsAgent{
|
||||
metricsServiceName: metricsServiceName,
|
||||
metrics: &model.Metrics{},
|
||||
metrics: &model.Metrics{Namespace: identityName},
|
||||
updates: make(chan metricsUpdate, 10240),
|
||||
zCtx: ziti.NewContextWithConfig(zCfg),
|
||||
}, nil
|
||||
@ -61,7 +61,7 @@ func (ma *metricsAgent) run() {
|
||||
}
|
||||
|
||||
func (ma *metricsAgent) sendMetrics() error {
|
||||
ma.metrics.Now = time.Now().UnixMilli()
|
||||
ma.metrics.LocalNow = time.Now().UnixMilli()
|
||||
metricsJson, err := bson.Marshal(ma.metrics)
|
||||
if err != nil {
|
||||
return errors.Wrap(err, "error marshaling metrics")
|
||||
|
@ -1,8 +1,9 @@
|
||||
package model
|
||||
|
||||
type Metrics struct {
|
||||
Now int64 `json:"now"`
|
||||
Sessions map[string]SessionMetrics
|
||||
LocalNow int64
|
||||
Namespace string
|
||||
Sessions map[string]SessionMetrics
|
||||
}
|
||||
|
||||
func (m *Metrics) PushSession(svcName string, sm SessionMetrics) {
|
||||
|
Loading…
Reference in New Issue
Block a user