mirror of
https://github.com/cloudflare/cloudflared.git
synced 2025-07-27 19:39:57 +00:00
TUN-3738: Refactor observer to avoid potential of blocking on tunnel notifications
This commit is contained in:

committed by
Arég Harutyunyan

parent
8c9d725eeb
commit
04b1e4f859
@@ -299,7 +299,7 @@ func convertRTTMilliSec(t time.Duration) float64 {
|
||||
}
|
||||
|
||||
// Metrics that can be collected without asking the edge
|
||||
func newTunnelMetrics() *tunnelMetrics {
|
||||
func initTunnelMetrics() *tunnelMetrics {
|
||||
maxConcurrentRequestsPerTunnel := prometheus.NewGaugeVec(
|
||||
prometheus.GaugeOpts{
|
||||
Namespace: MetricsNamespace,
|
||||
@@ -403,3 +403,15 @@ func (t *tunnelMetrics) registerServerLocation(connectionID, loc string) {
|
||||
t.serverLocations.WithLabelValues(connectionID, loc).Inc()
|
||||
t.oldServerLocations[connectionID] = loc
|
||||
}
|
||||
|
||||
var tunnelMetricsInternal struct {
|
||||
sync.Once
|
||||
metrics *tunnelMetrics
|
||||
}
|
||||
|
||||
func newTunnelMetrics() *tunnelMetrics {
|
||||
tunnelMetricsInternal.Do(func() {
|
||||
tunnelMetricsInternal.metrics = initTunnelMetrics()
|
||||
})
|
||||
return tunnelMetricsInternal.metrics
|
||||
}
|
Reference in New Issue
Block a user