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