File tree Expand file tree Collapse file tree 1 file changed +8
-3
lines changed
Expand file tree Collapse file tree 1 file changed +8
-3
lines changed Original file line number Diff line number Diff line change 11package metrics
22
33import (
4+ "sync"
45 "time"
56
67 "github.com/prometheus/client_golang/prometheus"
@@ -163,14 +164,18 @@ func init() {
163164 metrics .Registry .MustRegister (TunnelBytesByProtocol )
164165}
165166
167+ var registerAgentOnce sync.Once
168+
166169// RegisterAgentMetrics registers agent-only metrics (info and uptime) with the
167170// controller-runtime metrics registry. This must be called explicitly by agent
168171// processes — server processes (tunnelproxy) should NOT call this, as they
169172// re-export agent metrics via the AgentScraper/ReexportCollector path instead.
170173func RegisterAgentMetrics () {
171- TunnelAgentInfo .WithLabelValues (build .BuildVersion , build .BuildDate , build .CommitHash ).Set (1 )
172- metrics .Registry .MustRegister (TunnelAgentInfo )
173- metrics .Registry .MustRegister (TunnelAgentUptimeSeconds )
174+ registerAgentOnce .Do (func () {
175+ TunnelAgentInfo .WithLabelValues (build .BuildVersion , build .BuildDate , build .CommitHash ).Set (1 )
176+ metrics .Registry .MustRegister (TunnelAgentInfo )
177+ metrics .Registry .MustRegister (TunnelAgentUptimeSeconds )
178+ })
174179}
175180
176181// ProtocolFromIPHeader returns a protocol label from the IP next-header/protocol byte.
You can’t perform that action at this time.
0 commit comments