zrok/endpoints/frontend/metrics.go

40 lines
699 B
Go
Raw Normal View History

package frontend
import (
"github.com/sirupsen/logrus"
"time"
)
2022-10-10 22:56:01 +02:00
type metricsAgent struct {
metrics map[string]sessionMetrics
updates chan metricsUpdate
}
2022-10-10 22:56:01 +02:00
type sessionMetrics struct {
bytesRead int64
bytesWritten int64
lastUpdate time.Time
}
2022-10-10 22:56:01 +02:00
type metricsUpdate struct {
id string
bytesRead int64
bytesWritten int64
}
2022-10-10 22:56:01 +02:00
func newMetricsAgent() *metricsAgent {
return &metricsAgent{
metrics: make(map[string]sessionMetrics),
updates: make(chan metricsUpdate, 10240),
}
}
2022-10-10 22:56:01 +02:00
func (ma *metricsAgent) run() {
for {
select {
case update := <-ma.updates:
logrus.Infof("update: [%v] read: %d, written: %d", update.id, update.bytesRead, update.bytesWritten)
}
}
}