Add globalnet metrics
Related issue
@@ -58,6 +58,8 @@ func NewIpPool(cidr string) (*IpPool, error) {
pool.available[ip] = true
}
+ RecordAvailability(cidr, size)
+
return pool, nil
}
@@ -85,6 +87,7 @@ func (p *IpPool) Allocate(key string) (string, error) {
for k := range p.available {
p.allocated[key] = k
delete(p.available, k)
+ RecordAllocateGlobalIP(p.cidr)
return k, nil
}
@@ -101,6 +104,7 @@ func (p *IpPool) Release(key string) string {
if ip != "" {
p.available[ip] = true
delete(p.allocated, key)
+ RecordDeallocateGlobalIP(p.cidr)
}
p.Unlock()
@@ -132,6 +136,7 @@ func (p *IpPool) RequestIp(key, ip string) (string, error) {
p.Lock()
p.allocated[key] = ip
delete(p.available, ip)
+ RecordAllocateGlobalIP(p.cidr)
p.Unlock()
return ip, nil
