mirror of
https://github.com/openziti/zrok.git
synced 2024-11-07 08:44:14 +01:00
parent
095024c179
commit
83c12e30cb
@ -36,15 +36,22 @@ type metricsAgent struct {
|
||||
cfg *MetricsConfig
|
||||
influx influxdb2.Client
|
||||
writeApi api.WriteAPIBlocking
|
||||
envCache map[string]*envCacheEntry
|
||||
zCtx ziti.Context
|
||||
zListener edge.Listener
|
||||
shutdown chan struct{}
|
||||
joined chan struct{}
|
||||
}
|
||||
|
||||
type envCacheEntry struct {
|
||||
env string
|
||||
lastAccess time.Time
|
||||
}
|
||||
|
||||
func newMetricsAgent(cfg *MetricsConfig) *metricsAgent {
|
||||
ma := &metricsAgent{
|
||||
cfg: cfg,
|
||||
envCache: make(map[string]*envCacheEntry),
|
||||
shutdown: make(chan struct{}),
|
||||
joined: make(chan struct{}),
|
||||
}
|
||||
|
@ -80,6 +80,7 @@ func (ma *metricsAgent) pushUpdate(mu metricsUpdate) {
|
||||
}
|
||||
|
||||
func (ma *metricsAgent) sendMetrics() error {
|
||||
if len(ma.accum) > 0 {
|
||||
m := &model.Metrics{
|
||||
Namespace: ma.cfg.Identity,
|
||||
Sessions: ma.accum,
|
||||
@ -103,5 +104,6 @@ func (ma *metricsAgent) sendMetrics() error {
|
||||
logrus.Infof("sent %d bytes of metrics data", n)
|
||||
ma.accum = make(map[string]model.SessionMetrics)
|
||||
ma.lastSend = time.Now()
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user