stats: Follow stats.interval on reload, interface gauges ride the capture loop (#1919)

This commit is contained in:
Nate Brown authored and GitHub committed 2026-10-08 10:00:48 -05:00
1 parent f3705cbb67
commit 5bb0622192
5 files changed
+350 -53

No files matched your search

+5 -3
View File
@@ -300,6 +300,7 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
}
var ifce *Interface
var emitStats func()
if !configTest {
ifce, err = NewInterface(ctx, ifConfig)
if err != nil {
@@ -318,9 +319,12 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
go handshakeManager.Run(ctx)
punchy.Start(ctx, ifce, hostMap, lightHouse)
// On the stats server's loop, so the gauges follow the interval it accepted
emitStats = ifce.statsEmitter()
}
stats, err := newStatsServerFromConfig(ctx, l, c, buildVersion, configTest)
stats, err := newStatsServerFromConfig(ctx, l, c, buildVersion, configTest, emitStats)
if err != nil {
return nil, util.ContextualizeIfNeeded("Failed to start stats emitter", err)
}
@@ -329,8 +333,6 @@ func Main(c *config.C, configTest bool, buildVersion string, l *slog.Logger, dev
return nil, nil
}
go ifce.emitStats(ctx, c.GetDuration("stats.interval", time.Second*10))
attachCommands(l, c, ssh, ifce)
networkChanges := udp.NewNetworkChangeMonitor(ctx, l, c)