mirror of
https://github.com/Gouryella/drip.git
synced 2026-02-23 21:00:44 +00:00
feat(tunnel/manager): update tunnel IP metrics statistics
- Synchronously delete corresponding Prometheus metrics when removing IP records - Update metric values when the number of IP tunnels changes - Ensure accuracy and real-time nature of the tunnelsByIP metric
This commit is contained in:
@@ -233,6 +233,9 @@ func (m *Manager) RegisterWithIP(conn *websocket.Conn, customSubdomain string, r
|
||||
m.tunnelsByIP[remoteIP]--
|
||||
if m.tunnelsByIP[remoteIP] == 0 {
|
||||
delete(m.tunnelsByIP, remoteIP)
|
||||
metrics.TunnelsByIP.DeleteLabelValues(remoteIP)
|
||||
} else {
|
||||
metrics.TunnelsByIP.WithLabelValues(remoteIP).Set(float64(m.tunnelsByIP[remoteIP]))
|
||||
}
|
||||
}
|
||||
m.ipMu.Unlock()
|
||||
@@ -410,6 +413,9 @@ func (m *Manager) CleanupStale(timeout time.Duration) int {
|
||||
m.tunnelsByIP[remoteIP]--
|
||||
if m.tunnelsByIP[remoteIP] == 0 {
|
||||
delete(m.tunnelsByIP, remoteIP)
|
||||
metrics.TunnelsByIP.DeleteLabelValues(remoteIP)
|
||||
} else {
|
||||
metrics.TunnelsByIP.WithLabelValues(remoteIP).Set(float64(m.tunnelsByIP[remoteIP]))
|
||||
}
|
||||
}
|
||||
m.ipMu.Unlock()
|
||||
|
||||
Reference in New Issue
Block a user